Changes

Jump to navigation Jump to search
1,439 bytes removed ,  17:44, 19 February 2018
Hints about different layouts
< [[Visuals]] | [[Layers]] | [[Columns]] | [[Visual Debugging]] | [[Paper sizes]] >
There is now a 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 on page design]!.
== Location of Areas Typesetting areas ==
You can use these design The 25 typesetting areas in your of a ConTeXt pageare 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}|}}.
<table> <tr style="background:#ccccff;"> <td style="background:#ffffff;"></td> <td style="text-align:center;"><tt>leftedge</tt> </td> <td style="text-align:center;width:15%;"><tt>leftmargin</tt> </td> <td style="text-align:center;width:50%;"><tt>width</tt> </td> <td style="text-align:center;width:15%;"><tt>rightmargin</tt> </td> <td style="text-align:center;">rightedge </td> </tr> <tr style="background:#cccccc;"> <td style="background:#ccccff;"><tt>top</tt></td> <td style="text-align:center;">. </td> <td style="text-align:center;">. </td> <td style="text-align:center;">&uarr; topspace &darr;</td> <td style="text-align:center;">. </td> <td style="text-align:center;">. </td> </tr> <tr style="background:#cccccc;"> <td style="background:#ccccff;"><tt>header</tt></td> <td style="text-align:center;">. </td> <td style="text-align:center;">. </td> <td style="text-align:center;background:#DDDDDD;">HEADER<br />&uarr; headerheight &darr;</td> <td style="text-align:center;">. </td> <td style="text-align:center;">. </td> </tr> <tr style="background:#cccccc;"> <td style="background:#ccccff;"><tt>textheight</tt></td> <td style="text-align:center;">&larr;leftedgewidth&rarr;</td> <td style="text-align:center;background:#DDDDDD;">MARGINALS<br />&larr;leftmarginwidth&rarr;</td> <td style="text-align:center;height:20em;background:#EEEEEE;">TEXT<br />&larr;textwidth&rarr;<br />&times;<br />&uarr; textheight &darr;</td> <td style="text-align:center;background:#DDDDDD;">MARGINALS<br />&larr;rightmarginwidth&rarr;</td> <td style="text-align:center;">&larr;rightedgewidth&rarr;</td> </tr> <tr style="background:#cccccc;"> <td style="background:#ccccff;"><tt>footer</tt></td> <td style="text-align:center;">. </td> <td style="text-align:center;">. </td> <td style="text-align:center;background:#DDDDDD;">FOOTER<br />&uarr; footerheight &darr;</td> <td style="text-align:center;">The graphic below illustrates the areas and dimensions. </td>The row and column names are written <td style="text-align:center;">along the edges of the page. </td> </tr> <tr style="background:#cccccc;"> <td style="background:#ccccff;"><tt>bottom</tt></td> <td style="text-align:centerThe arrows correspond to layout dimensions;">. </td>the <td style="text-align:center;">more important a dimension is (i. </td> <td style="text-align:center;">&uarr; bottomspace &darr;</td> <td style="text-align:center;">e. </td>the more of the layout is pushed around <td style="text-align:center;">when you change it), the thicker its arrow and the larger its name. </td> </tr></table>
[[Image:layout.svg||||Diagram of \setuplayout[] dimensions]]
The names in == Defining the column and row headers are the keywords for {{cmd|setuplayout}}, the words inside of the table are given to clarify ConTeXT terminology. There are also keywords suffixed by "distance" to set the distancebetween each of the areas, e.g. <tt>leftedgedistance</tt>, <tt>leftmargindistance</tt> (from the named area to the inner). layout ==
<tt>height</tt> Positioning the areas is normally used instead by setting the following dimensions using {{cmd|setuplayout|[backspace=5cm,...]}}. The dimensions are mentioned in order of <tt>textheight</tt>how ‘primitive’ they are: e.g. altering the {{code|topspace}} pushes around all other vertical dimensions, it is but altering the {{code|header}} affects only the {{code|headerdistance}} and the sum of <tt>footer + footerdistance + {{code|textheight + headerdistance + header</tt>}}.
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]}}. # 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 size {{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 margins does not affect header.# 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. Control The {{code|footer}} and {{code|footerdistance}} work likewise.# Once the size 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.# 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}}.# 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}}. == Paper size == 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}}. {{todo | Merge with [[PaperSetup]] }} == Example layout == <texcode>\setuppapersize[A4][A4] % this is the default and may be omitted\setuplayout[backspace=20mm, width=160mm, topspace=20mm, header=0mm, footer=0mm, height =250mm]</texcode> == 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 {{cmd|setuplayout|[reset]}}. <texcode>\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</texcode> 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. <texcode>% different layout for first two pages\definelayout[1][wide]\definelayout[3][reset]</texcode> For the page numbers you can use absolute numbers (as above), relative numbers (like +1, -2) or the keywords odd, even, first and widthlast. <texcode>\setuplayout[ % default layout (right page)...]\definelayout[even][ % different layout on left pages...]</texcode> If you define additional layouts in a doublepage (duplex) setup, remember to think mirrored: leftmargin defines the right margin, backspace is the distance from the spine to the right edge of the text area etc. .<div style="border: 3px solid red; background: #ffcccc; padding: 0.4em;"><div style="font-size: 1.3em; fontweight: bold">Warning!</div>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 [http://wiki.contextgarden.net/User_talk:Zenlima Bug Layoutchange inside page while duplexmode].</div> == 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:<texcode>\showlayoutcomponents</texcode> * 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. * 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 [[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.
== Table of Parameters ==
<table><tr style="background:#ccccccThe 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;vertical-align=top;">knowing it allows you to invoke it with code like <thcode>ParameterThe paper's height is \the\paperheight.</th><th>Variable</th><thcode>Any remarks (usually a short description) are given in the third column. {| class=wikitable! \setuplayout[...] !! dimension !! Remarks</th></tr>|-<tr> <td>| paperheight</td> <td>| {{cmd|paperheight}}</td> <td>| height of paper page</td></tr>|-<tr> <td>| paperwidth</td> <td>| {{cmd|paperwidth}}</td> <td>| width of paper page</td></tr>|-<tr> <td>| printpaperheight</td> <td>| {{cmd|printpaperheight}}</td> <td>| differs from paperheight when using [[Imposition]] (arranging)</td></tr>|-<tr> <td>| printpaperwidth</td> <td>| {{cmd|printpaperwidth}}</td> <td>| differs from paperwidth when using [[Imposition]] (arranging)</td></tr>|-<tr> <td>| topspace</td> <td>| {{cmd|topspace}}</td> <td>| above header: from top rim of paper to to top rim of header</td></tr>|-<tr> <td>| backspace</td> <td>| {{cmd|backspace}}</td> <td>| from left rim of paper to left rim of main text area</td></tr>|-<tr> <td>| height</td> <td>| {{cmd|makeupheight}}</td> <td>| sum of heights of text area, header and footer (plus distances)</td></tr>|-<tr> <td>| width</td> <td>| {{cmd|makeupwidth}}</td> <td>| width of the main text area. {{cmd|makeupwidth}} is normally same as {{cmd|textwidth}}, but it can be different, for example in columns</td></tr>|-<tr> <td>| top</td> <td>| {{cmd|topheight}}</td> <td>| height of the top area</td></tr>|-<tr> <td>| topdistance</td> <td>| {{cmd|topdistance}}</td> <td>| between top and header</td></tr>|-<tr> <td>| header</td> <td>| {{cmd|headerheight}}</td> <td>| height of header area</td></tr>|-<tr> <td>| headerdistance</td> <td>| {{cmd|headerdistance}}</td> <td>| between header and text</td></tr>|-<tr> <td>| textheight</td> <td>| {{cmd|textheight}}</td> <td>| height of text area</td></tr>|-<tr> <td>| footerdistance</td> <td>| {{cmd|footerdistance}}</td> <td>| between text and footer</td></tr>|-<tr> <td>| footer</td> <td>| {{cmd|footerheight}}</td> <td>| height of footer area</td></tr>|-<tr> <td>| bottomdistance</td> <td>| {{cmd|bottomdistance}}</td> <td>| between footer and bottom</td></tr>|-<tr> <td>| bottom</td> <td>| {{cmd|bottomheight}}</td> <td>| space below footer (but isn't calculated automatically)</td></tr>|-<tr> <td>| bottomspace</td> <td>| {{cmd|bottomspace}}</td> <td>| space from bottom footer to bottom rim of paper</td></tr>|-<tr> <td>| cutspace</td> <td>| {{cmd|cutspace}}</td> <td>| from right rim of paper to right rim of main text area</td></tr>|-<tr> <td>| leftedge</td> <td>| {{cmd|leftedgewidth}}</td> <td>| from left rim of paper to left rim of left margin</td></tr>|-<tr> <td>| leftedgedistance</td> <td>| {{cmd|leftedgedistance}}</td> <td>| between leftegde and left margin</td></tr>|-<tr> <td>| leftmargin</td> <td>| {{cmd|leftmarginwidth}}</td> <td>| width of left margin (marginals space)</td></tr>|-<tr> <td>| leftmargindistance</td> <td>| {{cmd|leftmargindistance}}</td> <td>| between left margin and text</td></tr>|-<tr> <td>| textwidth</td> <td>| {{cmd|textwidth}}</td> <td>| width of text area. when columns are used, the value of {{cmd|textwidth}} can differ from {{cmd|makeupwidth}}</td></tr>|-<tr> <td>| rightmargindistance</td> <td>| {{cmd|rightmargindistance}}</td> <td>| between text area and right margin</td></tr>|-<tr> <td>| rightmargin</td> <td>| {{cmd|rightmarginwidth}}</td> <td>| width of right margin (marginals area)</td></tr>|-<tr> <td>| rightedgedistance</td> <td>| {{cmd|rightedgedistance}}</td> <td>| between right margin and right edge</td></tr>|-<tr> <td>| rightedge</td> <td>| {{cmd|rightedgewidth}}</td> <td>| from right margin to right rim of paper</td></tr>|-| horoffset| ?| bleed from left of paper|-| voroffset| ?| bleed from top of paper|}</table>
'''Note:'''
end
</code>
(from <tt>From {{src|page-lay.mkiv</tt>, 2009-11-17 - 23:59). == Setup / Paper Size == You define always a right page; if you use a double page layout 'right' and 'left' values are mirrored on a left page. <texcode>\setuppapersize[A4][A4] % this is default and may be omitted\setuplayout[backspace=20mm, width=160mm, topspace=20mm, top=0mm, header=0mm, footer=0mm, height=250mm]</texcode> ConTeXt users in the United States might use<texcode>\setuppapersize[letter][letter]</texcode>for standard US Letter-sized paper (8.5" &times; 11.0") If you need a special paper size, have a look at our list of [[PaperSizes|paper sizes]] (ConTeXt's, standardized and traditional), and use {{cmd|definepapersize}} if it's not already defined. You can make all the geometry information visible with {{cmd|showlayout}} and the [[Visual Debugging|related commands]]. See {{cmd|setuplayout}} and {{cmd|setuppapersize}} in the manual. === How to setup your layout === Define the placement and size of your type area by first defining '''backspace''', '''topspace''', '''width''' and '''height'''.The height includes header and footer. The width of the margins has ''no'' influence on the location of the type area! Details are in the [http://context.aanhet.net/svn/contextman/context-reference/en/co-pagedesign.pdf page design chapter] of the new reference manual. == Keep ==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.  == Multiple layouts == If you need to use different layouts in some parts of the document, you can set up a global layout for the overall and then define additional named layouts for the deviating parts. These settings go into the setup area of your document. <texcode>\setuplayout[key=value,key=value,...] %global layout\definelayout[wide][key=value,key=value,...] %different layout called 'wide'\definelayout[short][key=value,key=value,...]%different layout called 'short'</texcode> That takes care of the global layout. When you want to switch to a different layout, you just call it up in the appropriate place in the document: <texcode>\setuplayout[wide] % switches to layout called 'wide'</texcode> '''Note.''' Use reset to revert back to the global layout: <texcode>\setuplayout[reset] % reverts to the global layout</texcode> ''This text is based on [http://archive.contextgarden.net/message/20080926.111520.9db86904.en.html a thread on the mailing list], answers and examples are given there by Hans and Wolfgang.'' Defining layouts with a number as their name allows to specify the layout of the page with that specific number. For example, to use a different layout for the first page, you can use this code: <texcode>\setuplayout[key=value,key=value,...] % global layout\definelayout[1][key=value,key=value,...] % layout of the first page\definelayout[2][reset] % revert to the global layout starting from the second page</texcode> Do not forget to reset the layout on the second page. Note that keys that are not set in the layout of the first page will be conveniently inherited from the global layout. A typical example of the above is the following:<texcode>\setuplayout[% default layout for all the pages backspace=1cm, width=middle] \definelayout[1][% set this layout on the first page backspace=6cm] \definelayout[2][reset] % reset to the default layout starting from the second page \definelayout[5][backspace=6cm] % use this layout starting from page 5 \definelayout[9][reset] % reset to the default layout starting from page 9 \starttext\showframe\dorecurse{20}{\input dawkins \blank[big] \input knuth \page}\stoptext</texcode> == Layout components == A hidden nice feature is  <texcode>\showlayoutcomponents</texcode> By adding the above command at the beginning of your file you obtain a PDF file in which different components of the layout (such as layers) can be made visible or invisible in Acrobat Reader (or maybe a few other PDF viewers). == Hints == By using [[Layers]], you can also place elements at specific places, as done in the [[BusinessCard]] example. At [http://getfo.sourceforge.net/context_xml/index.html Paul Tremblay's] [[XML]] ConTeXt site, there's a lot about layout from a [[Formatting Objects|XML/FO]] perspective with some descriptive pictures.
{{Todo|Unfortunately it's not that easy to define a layout. We need more documentation about which parameters define which length, what influences what else etc.Getting started navbox}}
[[Category:ConTeXt-Issues]]

Navigation menu