Difference between revisions of "FO Page Layout"

From Wiki
Jump to navigation Jump to search
(Dispute ConTeXt's inability to work with even/odd layouts.)
(changed erronous info about not being able to change layouts for first, even, and odd pages; changed erronous info about cutspace and backspace; changed \setuplayout to \definelayout)
Line 1: Line 1:
Page Layout
 
 
 
=Overview=
 
=Overview=
  
Line 86: Line 84:
  
 
\part{}
 
\part{}
\definepapersize[secondPart][width=8.5in, height=10in]
+
\definepapersize[secondPart][width=8.5in, height=11in]
 
\setuppapersize[secondPart]
 
\setuppapersize[secondPart]
 
Text for second part.
 
Text for second part.
Line 107: Line 105:
  
 
% define layout for first part
 
% define layout for first part
\setuplayout[
+
\definelayout[
 
   topspace=.5in,  
 
   topspace=.5in,  
 +
  bottomspace=.5in,
 +
  cutspace=1in,
 
   backspace=1in,  
 
   backspace=1in,  
 
   header=2in,  
 
   header=2in,  
Line 125: Line 125:
 
The "topspace" value refers to the space at the very top of a
 
The "topspace" value refers to the space at the very top of a
 
page, and is roughly equivalent to the "margin-top" attribute in
 
page, and is roughly equivalent to the "margin-top" attribute in
FO. The backspace value indicates the space in the left of the
+
FO. The "bottompace" value refers to the space at the very bottom
page and is roughly equivalent to "margin-left" attribute in FO.
+
of a page, and is roughly equivalent to the "margin-bottom"
No text will occur in either one of these regions.
+
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 the
 +
left 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
+
If you pages are not doublesided (not part of a book), the
"margin-bottom". Rather, other values such as "height" and
+
"backspace" value will determine how much space occurs between
"leftmargin" determine how much space is left over for these
+
the left edge of the paper and any text. It always touches the
values. If you pages are not doublesided (not part of a book),
+
"leftmargin" region. If you have a doublesided layout, the
the "backspace" value will determine how much space occurs
+
"backspace" value will flip from right to left side of your
between the left edge of the paper and any text. It always
+
pages, but will always be in the gutter, or the spine of a book
touches the "leftmargin" region. If you have a doublesided
+
that is bound.
layout, the "backspace" value will flip from right to left side
 
of your pages, but will always be in the gutter, or the spine of
 
a book that is bound.
 
  
 
The values ConTeXt "header", "footer" "leftmargin" and
 
The values ConTeXt "header", "footer" "leftmargin" and
Line 158: Line 160:
 
the "width" and "height" values.
 
the "width" and "height" values.
  
=Changing Layouts for Odd and Even Pages=
+
'''I ahve a table to put in here, as soon as I figure out how to do
 +
  so with wiki'''
  
 
FO lets you create different pages sizes and layouts for the
 
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,
+
first page, and for odd and even pages. Here is how to do the
ConTeXt does not allow you this flexibility. The best you can do
+
same in ConTeXt
in ConTeXt is mirror pages--create pages in which the odd and even
+
 
pages swap their values. Put this command at the top of the
+
==First Page==
doucment:
+
 
 +
In order to define different pysical dimmensions for your first
 +
page, use "1" as your first option:
  
 
<texcode>
 
<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]
 
\setuppagenumbering[alternative=doublesided, state=stop]
Line 173: Line 201:
 
</texcode>
 
</texcode>
  
'''''Note: this section is inaccurate.''''' Try this minimal example to get started:
+
For more flexibility, you can add a position argument to your
 +
<tt>\definelayout</tt> command.
 +
 
 
<texcode>
 
<texcode>
 +
 +
 
\definelayout[odd]
 
\definelayout[odd]
            [backspace=1in,
+
            [backspace=1in,
              cutspace=1.25in,
+
            cutspace=1.25in,
              width=middle,
+
            width=middle,
              height=9in]
+
            height=9in]
 
\definelayout[even]
 
\definelayout[even]
            [backspace=1in,
+
            [backspace=1in,
              cutspace=1.25in,
+
            cutspace=1.25in,
              width=middle,
+
            width=middle,
              height=8in]
+
            height=8in]
 +
\setuplayout % needed to add this or the first page wouldn't format
 
\starttext
 
\starttext
 
\showframe
 
\showframe
 
\dorecurse{12}{\input dawkins \par}
 
\dorecurse{12}{\input dawkins \par}
 
\stoptext
 
\stoptext
 +
 +
 +
 
</texcode>
 
</texcode>
  
Line 324: Line 360:
 
document.
 
document.
  
[[pagelayout1.tex]]
+
[[page setup1]]
  
 
=Summary=
 
=Summary=
  
* We use the <tt>\part</tt> command to change page formatting.
+
* We use the <tt>\part</tt> command to change page formatting, or put another way, to start a new run of pages.
* 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>.
+
* 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>.
 
* 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.
+
* The <tt>\setuphead</tt> command allows us to control the headers and foooters for a new run of pages.
* 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.
 
* We use the <tt>\vbox</tt> and <tt>\hfill</tt> commands to format text within a header or footer.

Revision as of 07:28, 4 March 2005

Overview

In FO, one sets up paper size and dimensions at the start of a document and then later calls on these setups. The most straightforward way to accomplish the same thing in ConTeXt is to break the documents into parts, and define page dimensions and layout at each part.

First, let's look at page setup in FO for comparisons' sake:


<fo:simple-page-master  
  master-name="first"
  page-height="11in"   
  page-width="8.5in"
  margin-top="0.5in"   
  margin-bottom="0.5in"
  margin-left="1in"  
  margin-right="1in">

   <!--set up room for a  header-->
   <fo:region-body margin-top="1.0in"/>

</fo:simple-page-master>

Note how both page dimensions (the physical hieght of a page) and the layout (the margins) are contained in the simple-page-master element. In ConTeXt, these two qualities are separate.

Pysical Page Dimensions

Let's build different layouts in a ConTeXt document, starting from top to bottom.

First, let's start with the basic document:


\enableregime[utf]
\setuppagenumbering[state=stop]
\starttext

The \part tells ConTeXt to break a document into the largest division, forcing a page break.


\part{}

Now we'll define the page size for the first part of the document. (Note that part can refer to any generic division; use part for the main divisions, when you want to change page layout.)


\definepapersize[firstPart][width=8.5in, height=11in]
\setuppapersize[firstPart]


We'll add some dummy text :



Some text for our first part.

Let's repeat what we already did, altering our page height from 11 to 10 inches.



\part{}
\definepapersize[secondPart][width=8.5in, height=11in]
\setuppapersize[secondPart]
Text for second part.
\stoptext

Page Layout

We still haven't set up other page qualities like margins. Let's do this now, all at once:



\part{}

\definepapersize[firstdPart][width=8.5in, height=11in]
\setuppapersize[firstPart]

% define layout for first part
\definelayout[
  topspace=.5in, 
  bottomspace=.5in,
  cutspace=1in,
  backspace=1in, 
  header=2in, 
  footer=2in, 
  rightmargin=1in, 
  leftmargin=1in,
  width=5in, 
  height=10in, 
 ]  

Text for first part.


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 bottom of 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 the left of the page and is roughly equivalent to "margin-left" attribute in FO. No text will occur in either one of these regions.

If you pages are not doublesided (not part of a book), the "backspace" value will determine how much space occurs between the left edge of the paper and any text. It always touches the "leftmargin" region. If you have a doublesided layout, the "backspace" value will flip from right to left side of your pages, but will always be in the gutter, or the spine of a book that is bound.

The values ConTeXt "header", "footer" "leftmargin" and "rightmargin" are roughly equal to the FO <fo:region-body 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 conterparts, 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. If you the sum of your "backspace", margins, and width exceed the total page width, your layout will not work. In contrast, the "header" and "footer" do change the overall height of your body text. If you increased the header by one inch, your body text would be 1 inch smaller. You control the width and height of your body text by the "width" and "height" values.

I ahve a table to put in here, as soon as I figure out how to do

 so with wiki

FO lets you create different pages sizes and layouts for the first page, and for odd and even pages. Here is how to do the same in ConTeXt

First Page

In order to define different pysical dimmensions for your first page, use "1" as your first option:


\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
]



Odd and Even Pages

If you simply want to mirror odd and even pages, put this command at the top of your document:



\setuppagenumbering[alternative=doublesided, state=stop]

For more flexibility, you can add a position argument to your \definelayout command.



\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



Creating Headers and Footers

Simple Headers and Footers

In FO, you create headers and footers with the static-content element:



<fo:static-content
  flow-name="even-page">
  Title
</fo:static-content>

With ConTeXt, we place headers and footers in the body of the text wherever we want them with the commands \setupheadertexts and \setupfootertexts. These commands takes 4 arguments, the first for the left margin on even pages, the second for the right margin on odd pages, the third for the right margin on odd pages, and the fourth for the left margin on odd 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, allowing us to think of the header and footer as one block of text.


\setupheadertexts[left(even) header][] [][right(odd) header]
\setupfootertexts[left(even) footer][] [][right(odd) footer]

Since headers and footers will apper on whatever page you issue these commands, we must define header and footer text after we issue the \part command. If we don't, and ConTeXt needs to put blank pages at the end of a part, these blank pages will erronously contain the headings from the new part.

Controlling the Placement of Headers and Footers

The \setupheader and \setupfooter commands give us some control over header and footer placement. If we want a completely eliminate a header or footer for just one page, we use this command in conjunction with the state=high option, which not only eliminates the text of the header or footer, but the space it occupieds as well, pushing the body text into the header or footer region:



\setupheader[state=high] 
\setupfooter[state=high]

Other values for "state" are "stop", which stops the placement of headers and footers; "start", which starts them again if they have been stopped; "empty", which preserves the space for the header or footer but does not show the text; and none, which completely elminates both the space and the text for a header or foooter.

We'll not use the \setupheader command in this tutorial, instead relying on other methods.

Changing Headers and Footers for the Firstpage

We have already seen how we place a different header on odd and even pages. To start a different header or footer on the first page, we need the \setuphead command. The command 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 with a \definetext command in this way:


\definetext[partStart1][header][Part Header]
\setuphead[part][header=partStart1]
\part{}

For our sake, the \definetext command takes three options. The first is a name you choose to give it. The second is the postion. The third is the text itself.

Once we set up the defintion for the text, we recall it in the very next line in the header=partStart1 option.

Note how we pace the definition for the header before we issue the \part command. This contrast with all the other formatting commands we use for page layout, which come after the \part command.

Formatting Text in Headers and Footers

We'll need special commands to format our text in headers and footers. In order to make justify text left or right, we'll use the \hfill command. The \hfill command tells ConTeXt to fill in as much space horizontal space as possible.



% force the odd header to the right and the even header to the left
% (where it would appear, anyway).
\setupheadertexts[\hfill left(odd) header][] [][right(even) header
\hfill]

% an hfill command on either side of the word middle 
% forces the word to be centered
\setupheadertexts[left \hfill middle \hfill right][] [][right header]

Since ConTeXt won't allow us to create paragraphs in headers and footers as we would in normal text, we need the \vbox command if we want more than one line in a header or footer. The command \vbox stands for vertical box, the basic paragraph unit that ConTeXt uses behind the scenes. In order to break a line inside a \vbox, we use \vskip.

Example Documents

Here are two example documents, illustrating all the formatting. The first is a plain old ConTeXt document. The second is a TeXML document.

page setup1

Summary

  • We use the \part 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 \part.
  • We use \definelayout to set both the physical properties of a page as well as its layout.
  • We place the \setuphead command before the \part command. We place all other commands after \part.
  • The \setuphead command allows us to control the headers and foooters for a new run of pages.
  • We use the \vbox and \hfill commands to format text within a header or footer.