Changes

Jump to navigation Jump to search
545 bytes added ,  11:51, 14 September 2017
Describe how to create pages that fit their content
{{Todo todo | Merge with [[PaperSizesPaper sizes]] and [[Layout]] }}
Paper setup is one of the most basic requirements for creating your own style. In this article, the basics of paper setup are explained; the more advanced setups are described in the [http://context.aanhet.net/svn/contextman/context-reference/en/co-pagedesign.pdf Page Design] chapter of the new ConTeXt manual.
= Basic setup =
== Setting paper size ({{cmd|setuppapersize}}) ==
Plain TeX and LaTeX were primarily developed in the US. So, they default to letter paper, which is the standard paper size in the US. ConTeXt was developed in the Netherlands. So, it defaults to A4 paper, which is the standard paper size in Europe (and almost everywhere else in the world).
* a few more paper sizes, which I will not mention here. See <tt>page-lay.mki(i|v)</tt> for details.
== Defining new paper sizes ({{cmd|definepapersize}})==
The predefined paper sizes in ConTeXt cannot fit all needs. To define a new paper size, use
<texcode>\definepapersize[exotic]
[width=50mm, height=100mm]</texcode>
which defines a paper that is 50mm wide and 100mm high; the name of this paper is ''exotic'' (we could have used any other word). All predefined paper sizes are defined using <{{cmd>|definepapersize</cmd>}}. For example, <tt>A4</tt> paper is defined as:
<texcode>\definepapersize [A4] [width=210mm,height=297mm]</texcode>
Normally, the paper size is set up once&mdash;in the environment file&mdash;and doesn't need to be changed later. But, occasionally, changing paper size mid-document is needed; for example, to insert a table or a figure in landscape mode. There are two ways to change the paper size mid-document. To illustrate those, let us first define two paper sizes for convenience:
<texcode>\setuppapersizedefinepapersize[main] [A4]\setuppapersizedefinepapersize[extra][A4,landscape]</texcode>One way to change document size is to permanently change the paper size using <{{cmd>|setuppapersize</cmd> }} and then revert back using <{{cmd>|setuppapersize</cmd>}}.
<texcode>% Set the default paper size
\stoptext</texcode>
The <{{cmd>|page</cmd> }} before <{{cmd>|setuppapersize</cmd> }} is necessary as <{{cmd>|setuppapersize</cmd> }} changes the size of the current page.
Often times, a different paper size is needed only for one page. Rather than manually switching the paper size back and forth using <{{cmd>|setuppapersize</cmd>}}, a convenient alternative is to use <{{cmd>|adaptpapersize</cmd>}}, which automatically reverts back to the existing paper size after ''one'' page. This is illustrated by the following example.
<texcode>\setuppapersize[main]
\starttext
Page 1. Potrait Portrait \pagePage 2. Potrait Portrait \page
\adaptpapersize[extra]
Page 3. Landscape \page
Page 4. Potrait Portrait \page
\stoptext</texcode>
As with <{{cmd>|setuppapersize</cmd>}}, always use an explicit <{{cmd>|page</cmd> }} before <{{cmd>|adaptpapersize</cmd>}}.
= Setting print size =
Occasionally you may want to print on a larger paper than the actual page size. This could be because you want to print to the edge of the page&mdash;so you print on a large paper and crop later&mdash;or because the page size that you are using is not standard. For example, suppose you want to print an <tt>A5</tt> page on a <tt>A4</tt> paper (and crop later). For that, you need to specify that the paper size is <tt>A5</tt> but the ''print paper'' size is <tt>A4</tt>. This information is specified using the two argument version of the <{{cmd>|setuppapersize</cmd>}}:
<texcode>\setuppapersize[A5][A4]</texcode>
== Defining page and print size combinations ==
It is convenient to define paper-size/print-paper-size combination for later reuse. These are also defined using <{{cmd>|definepapersize</cmd>}}. For example, suppose you want to define two paper-size/print-paper-size combinations: <tt>A4</tt> paper on <tt>A4</tt> print paper for normal work flow, and <tt>A4</tt> paper on <tt>A3</tt> print paper for the final proofs. For that, use the following:
<texcode>\definepapersize[regular][A4][A4]
\doifmode{proof}{\setuppapersize[proof]}</texcode>
Then, when you compile the document in the normal manner, you will get <tt>A4</tt> paper on <tt>A4</tt> print paper; if you compile the document with <tt>--mode=proof</tt>, then you will get a <tt>A4</tt> paper on <tt>A3</tt> print paper.
 
= Fitting pages to their content =
 
ConTeXt has three commands that create a page that is exactly large enough to fit its contents.
 
* {{cmd|startTEXpage}} — start a page that fits its contents exactly. Or has some extra space around the edges, if you specify offset.
* {{cmd|startpagefigure}} — start a page just large enough to fit a figure, possibly with some text underneath
* {{cmd|startMPpage}} — start a page just large enough to fit its MetaPost contents
= Notes =
<references />
 
{{Getting started navbox}}
 
[[Category:ConTeXt-Issues]]

Navigation menu