Changes

Jump to navigation Jump to search
3,821 bytes added ,  21:44, 10 August 2013
new page
{{Reference
|name=snaptogrid
|attributes=
}}

== [[Help:Reference|Syntax]] ==
<table cellspacing="4" cellpadding="2" class="cmd">
<tr>
<td colspan="2" class="cmd">\snaptogrid<span class="first" style="color:red;">[...,...,...]</span>\{h,v}box</td>
</tr>
<tr valign="top" class="first">
<td class="cmd">[...,...,...]</td>
<td>top both bottom -top -both -bottom text high middle low page none <strong>standard</strong> broad fit depth line dimension </td>
</tr>
</table>


== Description ==

Adjust the placement of a box on the grid.
The mandatory argument is an explicit TeX box; box registers defined by
{{cmd|link=no|newbox}} will not work.
That leaves {{cmd|link=no|hbox}}:

<texcode>
\snaptogrid \hbox \bgroup
content that should be grid aligned
\egroup
</texcode>

and {{cmd|link=no|vbox}}:

<texcode>
\snaptogrid \vbox {\externalfigure [cow]}
</texcode>

The optional first argument determines the snap method which can be one
of the following:

{|cellpadding="10" style="border:2px solid #addeff"
! style="background:#addeff;" | Argument !! Description
|-
| normal
| height: rounded up; depth: rounded up; enlarge by line height and depth
|-
| standard
| synonym for <code>normal</code>
|-
| yes
| synonym for <code>normal</code>
|-
| strict
| height: rounded up to 0.8 times the line height; depth: rounded up to 0.8times the line height; enlarge by line height and depth
|-
| tolerant
| height: rounded up to 1.2 times the line height; depth: rounded up to 1.2 times the line height; enlarge by line height and depth
|-
| top
| height: rounded down; depth: rounded up; enlarge by line height and depth
|-
| bottom
| height: rounded up; depth: rounded down; enlarge by line height and depth
|-
| both
| height: rounded down; depth: rounded down; enlarge by line height and depth
|-
| broad
| height: rounded up; depth: rounded up; enlarge by line height and depth; snap height and depth reduced by 0.8
|-
| fit
| height: rounded up; depth: rounded up; enlarge by line height and depth; snap height and depth reduced by 1.2
|-
| first
| align to top line
|-
| last
| align to bottom line
|-
| high
| height: rounded down; depth: rounded up; don’t enlarge
|-
| one
| height: rounded down; depth: rounded down
|-
| low
| height: rounded up; depth: rounded down; don’t enlarge
|-
| none
| don’t enlarge
|-
| line
| enlarge both height and depth by one line depth
|-
| strut
| enlarge by height and depth (default)
|-
| max
| synonym for <code>normal</code>
|-
| min
| synonym for <code>both</code>
|-
| middle
| height: rounded up; depth: rounded up
|-
|}

Where ''snap height'' and ''snap depth'' are the dimensions
{{cmd|globalbodyfontstrutheight}} and {{cmd|globalbodyfontstrutdepth}},
respectively.

== Example ==
<!-- taken from my answer: http://tex.stackexchange.com/a/127632/14066 -->

<context source="yes" mode="mkiv" text="... yields ...">
\useMPlibrary [dum]
\setuppapersize [A6]
\showgrid
\setuplayout [grid=yes] %% set the global snap method

\def \makedummy {
%% create a dummy figure with a vsize that is not a multiple of the
%% leading
\externalfigure [dummy] [height=\dimexpr4.25\lineheight]%
}

\starttext
\input ward \par

method: default
\snaptogrid\vbox{\makedummy} \par
\input ward \par

method: top
\snaptogrid [top] \vbox{\makedummy} \par
\input ward \par

method: line
\snaptogrid [line] \vbox{\makedummy} \par
\input ward \par
\stoptext
</context>

== See also ==
* The page builder: {{src|spac-ver.mkiv}} and {{src|space-ver.lua}}.
* Line correction macros: {{src|spac-grd.mkiv}}.
* {{cmd|placeongrid}}.
* [http://www.pragma-ade.com/general/manuals/details.pdf It’s in the Details] by Hans Hagen.

== Help from ConTeXt-Mailinglist/Forum ==
All issues with:
{{Forum|{{SUBPAGENAME}}}}

[[Category:Command/Grid Typesetting|snaptogrid]]
188

edits

Navigation menu