Difference between revisions of "Page Layout"
Momomimachli (talk | contribs) (Added the horoffset and voroffset setuplayout parameters) |
m (removed whitespace in texcode) |
||
Line 45: | Line 45: | ||
width=160mm, | width=160mm, | ||
topspace=20mm, | topspace=20mm, | ||
− | header=0mm, | + | header=0mm, |
footer=0mm, | footer=0mm, | ||
height=250mm] | height=250mm] |
Revision as of 23:50, 24 December 2017
![]() |
TODO: Merge with PaperSetup and Paper sizes (See: To-Do List) |
< Visuals | Layers | Columns | Visual Debugging >
For more on layout and page design see the manual chapter.
At the moment a layoutchange (setuplayout) inside a page is not proper working in mkiv duplex mode. For more details and actual state see mailing list and Bug Layoutchange inside page while duplexmode.
Contents
Typesetting areas
The 25 typesetting areas of a ConTeXt page are divided into 5 columns and 5 rows. From left to right, one encounters leftedge
, leftmargin
, text
, rightmargin
, and rightedge
. From top to bottom, the areas are called: top
, header
, text
, footer
, bottom
. E.g. leftmargin
is the margin area to the left of the main text area; {leftmargin,bottom}
is below it, at the same height as the bottom
area. In between the two lies the area {leftmargin,footer}
.
The graphic below illustrates the areas and dimensions. The row and column names are written along the edges of the page. The arrows correspond to layout dimensions; the more important a dimension is (i.e. the more of the layout is pushed around when you change it), the thicker its arrow and the larger its name.
Defining the layout
Positioning the areas is by setting the following dimensions using \setuplayout. The dimensions are mentioned in order of how ‘primitive’ they are: e.g. altering the topspace
pushes around all other vertical dimensions, but altering the header
affects only the headerdistance
and the textheight
.
You always define a right page; if you use a double page layout, 'right' and 'left' values are mirrored on a left page. Doublesided typesetting is activated with \setuppagenumbering.
- Set the
backspace
andwidth
, and thetopspace
andheight
. Thewidth
is the width of the main typesetting area; thebackspace
is its distance from the left edge of the page. Theheight
is the distance from the top of the header to the bottom of the footer; thetopspace
is the distance from the top edge of the page to the top of the header. - Set the
header
andheaderdistance
, and thefooter
andfooterdistance
. Theheader
is the vertical size of the header area; theheaderdistance
is the distance from the header area to the text area. Thefooter
andfooterdistance
work likewise. - Once the header(distance) and footer(distance) are subtracted from the
height
, what remains is thetextheight
: the height of the main typesetting area. Although it would be very useful, you cannot set this dimension directly. - If you want to typeset anything above the header, define
topdistance
(the distance from the top of the header to the bottom of the topmost typesetting area) andtop
(the height of the topmost typesetting area). For typesetting below the footer, definebottomdistance
andbottom
. - As for the horizontal dimensions apart from the
width
: starting at the left edge of the main text area, and moving away from the center, one first sets theleftmargindistance
; then one sets the widthleftmargin
of the margin typesetting area; then one sets theleftedgedistance
; and then there is theleftedge
typesetting area. On the right:rightmargindistance
,rightmargin
,rightedgedistance
,rightedge
.
Paper size
Page size and paper size are set with \setuppapersize. Many paper sizes are already defined by name; see the list of paper sizes. To define a new paper size, use \definepapersize.
Example layout
\setuppapersize[A4][A4] % this is the default and may be omitted \setuplayout[backspace=20mm, width=160mm, topspace=20mm, header=0mm, footer=0mm, height=250mm]
Multiple layouts
If you need to use different layouts in some parts of the document, you can set up a global layout, and then define additional named layouts for the deviating parts. You only need to specify the dimensions that differ: unspecified dimensions will be inherited from the global layout.
To switch to a different layout, call it up in the appropriate place in the document. To revert back to the global layout, use \setuplayout[reset].
\setuplayout[...] % global layout \definelayout[wide][...] % layout of the first page \setuplayout[wide] % switch to layout called 'wide' \setuplayout[reset] % switch back to the global layout
To specify in advance that you want to change layouts starting from page 4 (e.g.), use \definelayout[4][...]. Resetting the layout must be done explicitly; else, the new layout will be used until the end of the document.
% different layout for first two pages \definelayout[1][wide] \definelayout[3][reset]
Advanced features
- To allow Acrobat Reader users (among others?) to make layers visible/invisible at will, add the following command at the start of your file:
\showlayoutcomponents
- If you have a certain run of text that you want to keep together, you can test for the number of lines available on the current page with \testpage[n], where n is the number of lines required. If there are not n lines available, a page break will be inserted at the location of the \testpage command.
- If you need absolute positioning of objects (text, pictures) on the page, but ad-hoc rather than systematic, the Layers mechanism is more suitable.
- For layout from a XML/FO perspective, with some descriptive pictures, see At Paul Tremblay's XML ConTeXt site.
Table of Parameters
The first colum is the name by which the variable is set in \setuplayout. The second column is the name by which TeX stores the variable. This name is usually the same, but sometimes different; knowing it allows you to invoke it with code like The paper's height is \the\paperheight.
Any remarks (usually a short description) are given in the third column.
\setuplayout[...] | dimension | Remarks |
---|---|---|
paperheight | \paperheight | height of paper page |
paperwidth | \paperwidth | width of paper page |
printpaperheight | \printpaperheight | differs from paperheight when using Imposition (arranging) |
printpaperwidth | \printpaperwidth | differs from paperwidth when using Imposition (arranging) |
topspace | \topspace | above header: from top rim of paper to to top rim of header |
backspace | \backspace | from left rim of paper to left rim of main text area |
height | \makeupheight | sum of heights of text area, header and footer (plus distances) |
width | \makeupwidth | width of the main text area. \makeupwidth is normally same as \textwidth, but it can be different, for example in columns |
top | \topheight | height of the top area |
topdistance | \topdistance | between top and header |
header | \headerheight | height of header area |
headerdistance | \headerdistance | between header and text |
textheight | \textheight | height of text area |
footerdistance | \footerdistance | between text and footer |
footer | \footerheight | height of footer area |
bottomdistance | \bottomdistance | between footer and bottom |
bottom | \bottomheight | space below footer (but isn't calculated automatically) |
bottomspace | \bottomspace | space from bottom footer to bottom rim of paper |
cutspace | \cutspace | from right rim of paper to right rim of main text area |
leftedge | \leftedgewidth | from left rim of paper to left rim of left margin |
leftedgedistance | \leftedgedistance | between leftegde and left margin |
leftmargin | \leftmarginwidth | width of left margin (marginals space) |
leftmargindistance | \leftmargindistance | between left margin and text |
textwidth | \textwidth | width of text area. when columns are used, the value of \textwidth can differ from \makeupwidth |
rightmargindistance | \rightmargindistance | between text area and right margin |
rightmargin | \rightmarginwidth | width of right margin (marginals area) |
rightedgedistance | \rightedgedistance | between right margin and right edge |
rightedge | \rightedgewidth | from right margin to right rim of paper |
horoffset | ? | bleed from left of paper |
voroffset | ? | bleed from top of paper |
Note:
- width=middle
if cutspace == 0pt then
cutspace = backspace
end
makeupwidth = paperwidth- backspace -cutspace
- width=fit
if cutspace == 0pt then
cutspace = backspace
end
makeupwidth = paperwidth-cutspace
scratchdimen = backspace - leftedgewidth-leftedgedistance-leftmarginwidth-leftmargindistance
if scratchdimen< 0pt then
scratchdimen = 0pt
end
makeupwidth = makeupwidth - rightmargindistance-rightmarginwidth- rightedgedistance-rightedgewidth- scratchdimen
- otherwise:
makeupwidth=width
if cutspace == 0pt then
cutspace = paperwidth-makeupwidth-backspace
else
% A kind of inconsistent specification, but used
% in for instance s-pre-19.tex; the cutspace is
% used only for determining some kind of right
% margin; don't use this in doublesided mode
pass
end
(From page-lay.mkiv.)