Changes

Jump to navigation Jump to search
2,978 bytes added ,  14:55, 22 September 2020
example pages have utterly disappeared. removed section
Page Layout
 
=Overview=
<pre>
 
<fo:simple-page-master
master-name="first"
</fo:simple-page-master>
 
</pre>
Note how both page dimensions (the physical hieght height of a page) and
the layout (the margins) are contained in the simple-page-master
element. In ConTeXt, these two qualities are separate.
=Pysical Physical Page Dimensions=
Let's build different layouts in a ConTeXt document, starting
<texcode>
 
\enableregime[utf]
\setuppagenumbering[state=stop, way=bytext]
\starttext
 
</texcode>
<texcode>
 
\part{}
 
</texcode>
<texcode>
 
\definepapersize[firstPart][width=8.5in, height=11in]
\setuppapersize[firstPart]  
</texcode>
<texcode>
 
 
Some text for our first part.
 
</texcode>
<texcode>
 
 
\part{}
\definepapersize[secondPart][width=8.5in, height=11in]
\setuppapersize[secondPart]
Text for second part.
\stoptext
 
</texcode>
<texcode>
 
 
\part{}
\definepapersize[firstdPart][width=8.5in, height=11in]
\setuppapersize[firstPart]
% define layout for first part
\setuplayoutdefinelayout[ topspace=.5in, bottomspace=.5in, cutspace=1in, backspace=1in, header=2in, footer=2in, rightmargin=1in, leftmargin=1in, width=5in, height=10in, ]
Text for first part.
 
 
</texcode>
The "topspace" value refers to the space at the very top of a
page, and is roughly equivalent to the "margin-top" attribute in
FO. The "bottompace" value refers to the space at the very bottomof a page, and is roughly equivalent to the "margin-bottom"attribute in FO. The "backspace " value indicates the space in the left of the page and is roughly equivalent to "margin-left"attribute in FO. The "cutspace" value indicates the space in theleft of the page and is roughly equivalent to "margin-left" attribute in FO.No text will occur in either one of these regions.
ConTeXt has no equivalent to the FO attributes "margin-right" and"margin-bottom". Rather, other values such as "height" and"leftmargin" determine how much space is left over for thesevalues. If you pages are not doublesided double sided (not part of a book),thethe "backspace" value will determine how much space occursbetweenbetween the left edge of the paper and any text. It alwaystouches the "leftmargin" region. If you have a doublesideddouble sided layout, the "backspace" value will flip from right to left sideof your pages, but will always be in the gutter, or the spine ofa book that is bound.
The values ConTeXt "header", "footer" "leftmargin" and
margin-top="2in"/>, <fo:region-body region-after="2in"/>,
<fo:region-body region-start="1in"/>, and <fo:region-body
region-end="1in"/> respectively. Like their FO conterpartscounterparts, the
ConTeXt values set up margins at the top, bottom, left, and right
of the page for marginal notes.
The values "leftmargin" and "rightmargin" have no affect on the
actual width of the body text. You could set "leftmargin" to 5in,
and your body text would not change its width. When you setwidth to 5 inches, the width of your body text will in fact be 5inches. (This contrasts with height, as I explain below.) If you the sum ofyour "backspace", margins, and width exceed the total pagewidth, your layout will not work.  In contrast, the "header" and"footer" do change the overall height of your body text. If youincreased the header by one inch, your body text would be 1 inchsmaller. The height actuallysmallerrefers to the total height of the toppace, header, body text,footer, and bottomspace. You control If you set the header to 2 inches, andset the width footer to 2 inches, and set the height of to 4 inches, thenthe actual body height would be: 4 - 2 - 2 = 0 (!) You would have no room for your body text byat all. If you meant toset your body height to 4 inches, you would set height to 8inches (2 + 2 + 4 = 8). <table style="border:1px solid #DDDDDD"> <caption> FO ConTeXt conversions for physical page layouts </caption> <tr style="background-color:#DDDDDD"><th>FO </th><th>ConTeXt </th></tr> <tr><td><pre><fo:simple-page-master margin-top="x"></pre> </td><td><texcode>\definelayout topspace=x</texcode> </td></tr> <tr style="background-color:#EEEEEE"><td><pre><fo:simple-page-master margin-bottom="x"></pre> </td><td><texcode>\definelayout bottomspace=x</texcode> </td></tr> <tr><td><pre><simple-page-master margin-left="x"></pre> </td><td><texcode>\definelayout backspace=x</texcode> </td></tr> <tr style="background-color:#EEEEEE"><td><pre><simple-page-master margin-right="x"></pre> </td><td><texcode>\definelayout cutspace=x</texcode> </td></tr> <tr><td><pre><fo:region-body margin-top="x"/></pre> </td><td><texcode>\definelayout headerdistance=x</texcode> </td></tr> <tr style="background-color:#EEEEEE"><td>the <pre><fo:region-before extent="widthx" and /></pre> </td><td><texcode>\definelayout header=x</texcode> </td></tr> <tr><td><pre><fo:region-after extent="heightx" values./></pre> </td><td><texcode>\definelayout footer=x</texcode> </td></tr>
<tr style="background-color:#EEEEEE"><td><pre><fo:region-start extent="x"/></pre> </td><td><texcode>\definelayout left-margin=x</texcode> </td></tr> <tr><td><pre><fo:region-after extent="x"/></pre> </td><td><texcode>\definelayout right-margin=x</texcode> </td></tr> </table> =Changing Layouts for First, Odd and Even Pages=
FO lets you create different pages sizes and layouts for the
first page, and for odd and even pages. So far as I can tell,ConTeXt does not allow you this flexibility. The best you can Here is how to dothesame in ConTeXt is mirror pages--create pages in which the odd and evenpages swap their values. Put this command at the top of thedoucment==First Page== In order to define different physical dimensions for your firstpage, use "1" as your first option:
<texcode>
\definelayout[1][
topspace=.5in, % the space at the very top of the page
backspace=2in, % the space in the gutter
header=2in, % the space for headers
footer=2in, % the space for footers
leftmargin=1in, % the space for margin notes
rightmargin=1.5in, % the space for right margin notes
width=3in, % the width of the body text
height=7in % the height of the body text
]
</texcode>
 
==Odd and Even Pages==
If you simply want to mirror odd and even pages, put this command
at the top of your document:
<texcode>
\setuppagenumbering[alternative=doublesided, state=stop]
</texcode>
For more flexibility, you can add a position argument to your
<tt>\definelayout</tt> command.
<texcode>
\definelayout[odd]
[backspace=1in,
cutspace=1.25in,
width=middle,
height=9in]
\definelayout[even]
[backspace=1in,
cutspace=1.25in,
width=middle,
height=8in]
\setuplayout % needed to add this or the first page wouldn't format
\starttext
\showframe
\dorecurse{12}{\input dawkins \par}
\stoptext
</texcode>
<pre>
 
 
<fo:static-content
flow-name="even-page">
Title
</fo:static-content>
 
</pre>
text wherever we want them with the commands
<tt>\setupheadertexts</tt> and <tt>\setupfootertexts</tt>. These
commands takes 4 arguments, the first for the left margin on evenodd
pages, the second for the right margin on odd pages, the third
for the right left margin on odd even pages, and the fourth for the leftrightmargin on odd even pages. For simplicity's sake, let's leave the
middle two options empty, so we get headers and footers on the
even and odd pages, naturally alligned with the left margin,
<texcode>
 
\setupheadertexts[left(even) header][] [][right(odd) header]
\setupfootertexts[left(even) footer][] [][right(odd) footer]
 
</texcode>
<texcode>
 
 
\setupheader[state=high]
\setupfooter[state=high]
 
</texcode>
have been stopped; "empty", which preserves the space for the
header or footer but does not show the text; and none, which
completely elminates eliminates both the space and the text for a header or
foooter.
determines the placement of text on the first page of a division
in a document, such as part. We will use this command in
conjuction conjunction with a <tt>\definetext</tt> command in this way:
<texcode>
 
\definetext[partStart1][header][Part Header]
\setuphead[part][header=partStart1]
\part{}
 
</texcode>
<texcode>
 
 
% force the odd header to the right and the even header to the left
% (where it would appear, anyway).
% forces the word to be centered
\setupheadertexts[left \hfill middle \hfill right][] [][right header]
 
</texcode>
break a line inside a <tt>\vbox</tt>, we use <tt>\vskip</tt>.
=Example DocumentsSummary* We use the <tt>\part</tt> command to change page formatting, or put another way, to start a new run of pages.* Unlike FO, which defines page formatting at the start of a document, ConTeXt formatting commands are placed in the vicinity of <tt>\part</tt>.* We use <tt>\definelayout</tt> to set both the physical properties of a page as well as its layout.* We place the <tt>\setuphead</tt> command before the <tt>\part</tt> command. We place all other commands after <tt>\part</tt>.* The <tt>\setuphead</tt> command allows us to control the headers and footers for a new run of pages.* We use the <tt>\vbox</tt> and <tt>\hfill</tt> commands to format text within a header or footer.
Here are two example documents, illustrating all the formatting.
The first is a plain old ConTeXt document. The second is a TeXML
document.
[[pagelayout1.tex]]=To Do=
=Summary=* Find out if there is a corresponding value of footerdistance in FO.
* We use the <tt>\part</tt> command to change page formatting.* Unlike in FO, which defines page formatting at the start of a document, in ConTeXt we place page formatting commands in the vicinity of <tt>\part</tt>.* We place the <tt>\setuphead</tt> command before the <tt>\part</tt> command. We place all other commands after <tt>\part</tt>.* The <tt>\setuphead</tt> command allows us to control the first page of a new part.* So far as I know, ConTeXt has no mechanisim to create different margins for the first and odd and even pages. The best we can do is mirror odd and even pages.* We use the <tt>\vbox</tt> and <tt>\hfill</tt> commands to format text within a header or footer.[[Category:XML]]

Navigation menu