Difference between revisions of "Grid typesetting"

From Wiki
Jump to navigation Jump to search
(Clone of Working on Grid with an introduction)
 
(3 intermediate revisions by one other user not shown)
Line 10: Line 10:
  
 
Alternative grid snapping methods are discussed in the description of
 
Alternative grid snapping methods are discussed in the description of
[[Command/setuplayout#Grid Setups|{{cmd|setuplayout|link=no}}]].
+
[[Command/setuplayout#Grid Setups|{{cmd|setuplayout|link=no}}]], and also in [[snaptogrid]] (to merge ?)
 +
 
 +
[[Category:ToDo]]
  
 
==Placing titles on the grid==
 
==Placing titles on the grid==
Line 53: Line 55:
 
\unprotect
 
\unprotect
 
\newdimen\section_frame_width
 
\newdimen\section_frame_width
\def\section_command#number#title{%
+
\unexpanded\def\section_command#number#title{%
 
   \section_frame_width\hsize            % we need to calculate the remaining
 
   \section_frame_width\hsize            % we need to calculate the remaining
 
   \setbox\scratchbox\hbox{#number\space} % horizontal space
 
   \setbox\scratchbox\hbox{#number\space} % horizontal space
Line 102: Line 104:
  
 
{{todo|this page is too short}}
 
{{todo|this page is too short}}
 +
 +
[[Category:Basics]]
 +
[[Category:Layout]]

Revision as of 03:17, 10 October 2020

Introduction

Grid typesetting ensures the same vertical position of typeset lines:

  • in case of multiple columns it ensures the same vertical position of adjacent lines
  • in case of duplex printing it ensures the same vertical position of lines on front and back side of the page. This approach prevents disturbing the reader by dark tint between the lines if the medium is translucent.

Enable grid typesetting

Grid typesetting is enabled with \setuplayout [grid=yes] and visualized with \showgrid.

Alternative grid snapping methods are discussed in the description of \setuplayout, and also in snaptogrid (to merge ?)

Placing titles on the grid

As title font sizes and baseline distances differ from the body text, only the last baseline is placed on the grid. The baseline distance of preceding lines (in case of multi-line titles) is not affected by the grid settings.

Example

\setuplayout [grid=yes, width=12cm]
\definefont  [BigFont]  [Bold at 20pt] [24pt]
\setuphead   [section]  [style=\BigFont]

\showgrid
\starttext

  \startsection [title=Lorem ipsum dolor]
    \input ward
  \stopsection

  \startsection [title=Lorem ipsum dolor sit amet consectetur adipisicing elit]
    \input ward
  \stopsection

\stoptext

Adjusting the section head placement

Lots of examples and the commands and options for head placement are provided in the manual It's in the details!. However, it is not covered how to place the first line of a multi-line structure head onto the grid. The solution is to frame the structure head and instruct to typeset the first line on the grid.

Example

% macros=mkvi
\setuplayout [grid=yes]
\definefont  [BigFont]  [Bold at 20pt] [24pt]

\unprotect
\newdimen\section_frame_width
\unexpanded\def\section_command#number#title{%
  \section_frame_width\hsize             % we need to calculate the remaining
  \setbox\scratchbox\hbox{#number\space} % horizontal space
  \advance\section_frame_width by -\wd\scratchbox
  #number\space
  \framed [
       width=\section_frame_width,
      before=,
    location=top,
       align=right,]{#title}%
}

\setuphead [section] [
    style=\BigFont,
    after=,
   before={\blank[2*line]},
  command=\section_command,
]
\protect

\showgrid
\starttext
  \startsection [title=Lorem ipsum dolor]
    \input ward
  \stopsection

  \dorecurse{4}{%
    \startsection [title=Lorem ipsum dolor sit amet consectetur adipisicing elit]
      \input ward
    \stopsection}
\stoptext

Typesetting non grid aligned content

See the page design chapter of the new reference manual!

You can wrap that whole stuff inside

\startlinecorrection
...
\stoplinecorrection

The stuff inside that environment will not be grid-aligned, but the final resulting box will be.


TODO: this page is too short (See: To-Do List)