Grid typesetting

From ConTeXt wiki
(Redirected from Working on Grid)
Jump to: navigation, search

Contents

Introduction

Grid typesetting ensures the same vertical position of typeset lines:

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.

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
\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)

C O N T E X T G A R D E N

Personal tools
Namespaces
Variants
Actions
Help
External Help
Installation
Navigation
Toolbox