https://wiki.contextgarden.net/api.php?action=feedcontributions&user=Momomimachli&feedformat=atomWiki - User contributions [en]2024-03-29T15:43:14ZUser contributionsMediaWiki 1.34.1https://wiki.contextgarden.net/index.php?title=Page_Layout&diff=22482Page Layout2014-05-11T13:32:20Z<p>Momomimachli: Added the horoffset and voroffset setuplayout parameters</p>
<hr />
<div>{{todo | Merge with [[PaperSetup]] and [[Paper sizes]] }}<br />
< [[Visuals]] | [[Layers]] | [[Columns]] | [[Visual Debugging]] ><br />
<br />
For more on [http://context.aanhet.net/svn/contextman/context-reference/en/co-pagedesign.pdf layout and page design] see the [http://context.aanhet.net/svn/contextman/context-reference/en/co-pagedesign.pdf manual chapter].<br />
<br />
<div style="border: 3px solid red; background: #ffaaaa; padding: 0.4em;"><br />
<div style="font-size: 1.3em; fontweight: bold">Warning!</div><br />
At the moment a layoutchange (setuplayout) inside a page is not proper working in mkiv duplex mode.<br />
For more details and actual state see mailing list and [http://wiki.contextgarden.net/User_talk:Zenlima Bug Layoutchange inside page while duplexmode].<br />
</div><br />
<br />
<br />
== Typesetting areas ==<br />
<br />
The 25 typesetting areas of a ConTeXt page are divided into 5 columns and 5 rows. From left to right, one encounters {{code|leftedge}}, {{code|leftmargin}}, {{code|text}}, {{code|rightmargin}}, and {{code|rightedge}}. From top to bottom, the areas are called: {{code|top}}, {{code|header}}, {{code|text}}, {{code|footer}}, {{code|bottom}}. E.g. {{code|leftmargin}} is the margin area to the left of the main text area; {{code|{leftmargin,bottom}|}} is below it, at the same height as the {{code|bottom}} area. In between the two lies the area {{code|{leftmargin,footer}|}}.<br />
<br />
The graphic below illustrates the areas and dimensions. The row and column names are written<br />
along the edges of the page. The arrows correspond to layout dimensions; the<br />
more important a dimension is (i.e. the more of the layout is pushed around<br />
when you change it), the thicker its arrow and the larger its name.<br />
<br />
[[Image:layout.svg||||Diagram of \setuplayout[] dimensions]]<br />
<br />
== Defining the layout ==<br />
<br />
Positioning the areas is by setting the following dimensions using {{cmd|setuplayout|[backspace=5cm,...]}}. The dimensions are mentioned in order of how ‘primitive’ they are: e.g. altering the {{code|topspace}} pushes around all other vertical dimensions, but altering the {{code|header}} affects only the {{code|headerdistance}} and the {{code|textheight}}.<br />
<br />
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 {{cmd|setuppagenumbering|[alternative=doublesided]}}.<br />
<br />
# Set the {{code|backspace}} and {{code|width}}, and the {{code|topspace}} and {{code|height}}. The {{code|width}} is the width of the main typesetting area; the {{code|backspace}} is its distance from the left edge of the page. The {{code|height}} is the distance ''from the top of the header to the bottom of the footer''; the {{code|topspace}} is the distance from the top edge of the page to the top of the header.<br />
# Set the {{code|header}} and {{code|headerdistance}}, and the {{code|footer}} and {{code|footerdistance}}. The {{code|header}} is the vertical size of the header area; the {{code|headerdistance}} is the distance from the header area to the text area. The {{code|footer}} and {{code|footerdistance}} work likewise.<br />
# Once the header(distance) and footer(distance) are subtracted from the {{code|height}}, what remains is the {{code|textheight}}: the height of the main typesetting area. Although it would be very useful, you cannot set this dimension directly.<br />
# If you want to typeset anything above the header, define {{code|topdistance}} (the distance from the top of the header to the bottom of the topmost typesetting area) and {{code|top}} (the height of the topmost typesetting area). For typesetting below the footer, define {{code|bottomdistance}} and {{code|bottom}}.<br />
# As for the horizontal dimensions apart from the {{code|width}}: starting at the left edge of the main text area, and moving away from the center, one first sets the {{code|leftmargindistance}}; then one sets the width {{code|leftmargin}} of the margin typesetting area; then one sets the {{code|leftedgedistance}}; and then there is the {{code|leftedge}} typesetting area. On the right: {{code|rightmargindistance}}, {{code|rightmargin}}, {{code|rightedgedistance}}, {{code|rightedge}}.<br />
<br />
== Paper size ==<br />
<br />
Page size and paper size are set with {{cmd|setuppapersize}}. Many paper sizes are already defined by name; see the list of [[PaperSizes|paper sizes]]. To define a new paper size, use {{cmd|definepapersize}}.<br />
<br />
== Example layout ==<br />
<br />
<texcode><br />
\setuppapersize[A4][A4] % this is the default and may be omitted<br />
\setuplayout[backspace=20mm,<br />
width=160mm,<br />
topspace=20mm,<br />
header=0mm, <br />
footer=0mm,<br />
height=250mm]<br />
</texcode><br />
<br />
== Multiple layouts ==<br />
<br />
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.<br />
<br />
To switch to a different layout, call it up in the appropriate place in the document. To revert back to the global layout, use {{cmd|setuplayout|[reset]}}.<br />
<br />
<texcode><br />
\setuplayout[...] % global layout<br />
\definelayout[wide][...] % layout of the first page<br />
<br />
\setuplayout[wide] % switch to layout called 'wide'<br />
\setuplayout[reset] % switch back to the global layout<br />
</texcode><br />
<br />
To specify in advance that you want to change layouts starting from page 4 (e.g.), use {{cmd|definelayout|[4][...]}}. Resetting the layout must be done explicitly; else, the new layout will be used until the end of the document.<br />
<br />
<texcode><br />
% different layout for first two pages<br />
\definelayout[1][wide]<br />
\definelayout[3][reset]<br />
</texcode><br />
<br />
== Advanced features ==<br />
<br />
* To allow Acrobat Reader users (among others?) to make layers visible/invisible at will, add the following command at the start of your file:<br />
<texcode><br />
\showlayoutcomponents<br />
</texcode><br />
<br />
* 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 {{cmd|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 {{cmd|testpage}} command.<br />
<br />
* If you need absolute positioning of objects (text, pictures) on the page, but ad-hoc rather than systematic, the [[Layers]] mechanism is more suitable.<br />
<br />
* For layout from a [[Formatting Objects|XML/FO]] perspective, with some descriptive pictures, see At [http://getfo.sourceforge.net/context_xml/index.html Paul Tremblay's] [[XML]] ConTeXt site.<br />
<br />
== Table of Parameters ==<br />
<br />
The first colum is the name by which the variable is set in {{cmd|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 <code>The paper's height is \the\paperheight.</code> Any remarks (usually a short description) are given in the third column.<br />
<br />
{| class=wikitable<br />
! \setuplayout[...] !! dimension !! Remarks<br />
|-<br />
| paperheight<br />
| {{cmd|paperheight}}<br />
| height of paper page<br />
|-<br />
| paperwidth<br />
| {{cmd|paperwidth}}<br />
| width of paper page<br />
|-<br />
| printpaperheight<br />
| {{cmd|printpaperheight}}<br />
| differs from paperheight when using [[Imposition]] (arranging)<br />
|-<br />
| printpaperwidth<br />
| {{cmd|printpaperwidth}}<br />
| differs from paperwidth when using [[Imposition]] (arranging)<br />
|-<br />
| topspace<br />
| {{cmd|topspace}}<br />
| above header: from top rim of paper to to top rim of header<br />
|-<br />
| backspace<br />
| {{cmd|backspace}}<br />
| from left rim of paper to left rim of main text area<br />
|-<br />
| height<br />
| {{cmd|makeupheight}}<br />
| sum of heights of text area, header and footer (plus distances)<br />
|-<br />
| width<br />
| {{cmd|makeupwidth}}<br />
| width of the main text area. {{cmd|makeupwidth}} is normally same as {{cmd|textwidth}}, but it can be different, for example in columns<br />
|-<br />
| top<br />
| {{cmd|topheight}}<br />
| height of the top area<br />
|-<br />
| topdistance<br />
| {{cmd|topdistance}}<br />
| between top and header<br />
|-<br />
| header<br />
| {{cmd|headerheight}}<br />
| height of header area<br />
|-<br />
| headerdistance<br />
| {{cmd|headerdistance}}<br />
| between header and text<br />
|-<br />
| textheight<br />
| {{cmd|textheight}}<br />
| height of text area<br />
|-<br />
| footerdistance<br />
| {{cmd|footerdistance}}<br />
| between text and footer<br />
|-<br />
| footer<br />
| {{cmd|footerheight}}<br />
| height of footer area<br />
|-<br />
| bottomdistance<br />
| {{cmd|bottomdistance}}<br />
| between footer and bottom<br />
|-<br />
| bottom<br />
| {{cmd|bottomheight}}<br />
| space below footer (but isn't calculated automatically)<br />
|-<br />
| bottomspace<br />
| {{cmd|bottomspace}}<br />
| space from bottom footer to bottom rim of paper<br />
|-<br />
| cutspace<br />
| {{cmd|cutspace}}<br />
| from right rim of paper to right rim of main text area<br />
|-<br />
| leftedge<br />
| {{cmd|leftedgewidth}}<br />
| from left rim of paper to left rim of left margin<br />
|-<br />
| leftedgedistance<br />
| {{cmd|leftedgedistance}}<br />
| between leftegde and left margin<br />
|-<br />
| leftmargin<br />
| {{cmd|leftmarginwidth}}<br />
| width of left margin (marginals space)<br />
|-<br />
| leftmargindistance<br />
| {{cmd|leftmargindistance}}<br />
| between left margin and text<br />
|-<br />
| textwidth<br />
| {{cmd|textwidth}}<br />
| width of text area. when columns are used, the value of {{cmd|textwidth}} can differ from {{cmd|makeupwidth}}<br />
|-<br />
| rightmargindistance<br />
| {{cmd|rightmargindistance}}<br />
| between text area and right margin<br />
|-<br />
| rightmargin<br />
| {{cmd|rightmarginwidth}}<br />
| width of right margin (marginals area)<br />
|-<br />
| rightedgedistance<br />
| {{cmd|rightedgedistance}}<br />
| between right margin and right edge<br />
|-<br />
| rightedge<br />
| {{cmd|rightedgewidth}}<br />
| from right margin to right rim of paper<br />
|-<br />
| horoffset<br />
| ?<br />
| bleed from left of paper<br />
|-<br />
| voroffset<br />
| ?<br />
| bleed from top of paper<br />
|}<br />
<br />
'''Note:'''<br />
<br />
*width=middle<br />
<code><br />
if cutspace == 0pt then<br />
cutspace = backspace<br />
end<br />
makeupwidth = paperwidth- backspace -cutspace<br />
</code><br />
*width=fit<br />
<code> <br />
if cutspace == 0pt then<br />
cutspace = backspace<br />
end<br />
makeupwidth = paperwidth-cutspace<br />
scratchdimen = backspace - leftedgewidth-leftedgedistance-leftmarginwidth-leftmargindistance<br />
if scratchdimen< 0pt then<br />
scratchdimen = 0pt<br />
end<br />
makeupwidth = makeupwidth - rightmargindistance-rightmarginwidth- rightedgedistance-rightedgewidth- scratchdimen<br />
</code><br />
* otherwise:<br />
<code><br />
makeupwidth=width<br />
if cutspace == 0pt then<br />
cutspace = paperwidth-makeupwidth-backspace<br />
else<br />
% A kind of inconsistent specification, but used<br />
% in for instance s-pre-19.tex; the cutspace is<br />
% used only for determining some kind of right<br />
% margin; don't use this in doublesided mode<br />
pass <br />
end<br />
</code><br />
(From {{src|page-lay.mkiv}}.)<br />
<br />
{{Getting started navbox}}<br />
<br />
[[Category:ConTeXt-Issues]]</div>Momomimachli