Difference between revisions of "PaperSetup"

From Wiki
Jump to navigation Jump to search
m (Editorial changes by Karl and Barbara)
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Todo | Merge with [[PaperSizes]] 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.
 
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 =
 
= Basic setup =
  
== Setting paper size ==
+
== 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).
 
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).
  
Changing paper size is easy. To get letter paper, use<ref>The syntax used here only works with ConTeXt versions newer than February 2011. In earlier versions, you had to use
+
Changing paper size is easy, for letter paper:<ref>The syntax used here only works with ConTeXt versions newer than February 2011. Before that, you had to use
  
 
<texcode>\setuppapersize[letter][letter]</texcode>
 
<texcode>\setuppapersize[letter][letter]</texcode>
 
to get letter sized paper. You may wonder why we need to repeat the paper size twice. In most cases, these are the same. You only need to use different arguments if you want to print on a bigger paper and trim it later (see the section on print size for details).
 
to get letter sized paper. You may wonder why we need to repeat the paper size twice. In most cases, these are the same. You only need to use different arguments if you want to print on a bigger paper and trim it later (see the section on print size for details).
</ref>:
+
</ref>
  
 
<texcode>\setuppapersize[letter]</texcode>
 
<texcode>\setuppapersize[letter]</texcode>
Line 19: Line 17:
  
 
<texcode>\setuppapersize[A4]</texcode>
 
<texcode>\setuppapersize[A4]</texcode>
== Pre-defined paper sizes ==
 
  
Both <tt>A4</tt> and <tt>letter</tt> are predefined paper sizes. ConTeXt predefines many other commonly used paper sizes. These include:
+
== Predefined Paper Sizes ==
 +
 
 +
Beyond <tt>A4</tt> and <tt>letter</tt>, ConTeXt predefines many other commonly used paper sizes (see [[Paper sizes|Paper sizes page]] for actuals dimensions in mm). These include:
 +
 
 +
; ISO (EN/DIN) sizes:
 +
:* series A and B, from ISO-216 standard (e.g. "A4")
 +
:* envelope: serie C 0–10, plus DL
 +
:* series RA, SRA 0–4, from ISO-217 standard;
 +
:* ISO-based "2 A0" (double A0), "4 A0", "C6/C5", A3plus
 +
; US sizes
 +
:* letter, ledger, tabloid, legal, folio, executive, A, B, C
 +
:* envelope: "envelope 9" (10, 11, 12, 14), monarch, check, DL, E4
 +
; Swedish sizes
 +
:* sizes <tt>G5</tt> and <tt>E5</tt> from SIS-014711 standard. These are used for Swedish theses;
 +
; Screen sizes
 +
:* 4:3 ratio: S3–6 (width 300–600 pt)
 +
:* 1:1 ratio: S33, S44, S55, S66 (300 &times; 300 pt etc.)
 +
:* 8:5 ratio: SM (720 &times; 450 pt), they have the same height as S6
 +
:* 16:9 ratio: SW (800 &times; 450 pt), they have the same height as S6
 +
; CD (120 &times; 120 mm) for CD Covers
  
* <tt>letter</tt>, <tt>ledger</tt>, <tt>tabloid</tt>, <tt>legal</tt>, <tt>folio</tt>, and <tt>executive</tt> sizes from the North American paper standard;
+
Plus keywords oversized (plus 1.5 cm), doublesized, doubleoversized, undersized (minus 1.5 cm). For definitions, see {{src|page-lay.mkii}} and {{src|page-lay.mkiv}}.
* sizes <tt>A0</tt> &ndash; <tt>A10</tt>, <tt>B0</tt> &ndash; <tt>B10</tt>, and <tt>C0</tt> &ndash; <tt>C10</tt> from the A, B, and C series of the ISO-216 standard;
 
* sizes <tt>RA0</tt> &ndash; <tt>RA4</tt> and <tt>SRA0</tt> &ndash; <tt>SRA4</tt> from the RA and SRA series of ISO-217 paper standard;
 
* sizes <tt>C6/C5</tt>, <tt>DL</tt>, and <tt>E4</tt> from ISO-269 standard envelope sizes;
 
* <tt>envelope 9</tt> &ndash; <tt>envelope 14</tt> sizes from the American postal standard;
 
* sizes <tt>G5</tt> and <tt>E5</tt> from the Swedish SIS-014711 standard. These are used for Swedish theses;
 
* size <tt>CD</tt> for CD covers;
 
* size <tt>S3</tt> &ndash; <tt>S6</tt>, <tt>S8</tt>, <tt>SM</tt>, and <tt>SW</tt> for screen sizes. These sizes are useful for presentations. <tt>S3</tt> &ndash; <tt>S6</tt> and <tt>S8</tt> have an aspect ratio of 4:3. <tt>S3</tt> is 300pt wide, <tt>S4</tt> is 400pt wide, and so on. <tt>S6</tt> is almost as wide as a <tt>A4</tt> paper. <tt>SM</tt> and <tt>SW</tt> are for medium and wide screens; they have the same height as <tt>S6</tt>;
 
* 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 ==
+
== Defining new paper sizes ({{cmd|definepapersize}})==
  
 
The predefined paper sizes in ConTeXt cannot fit all needs. To define a new paper size, use
 
The predefined paper sizes in ConTeXt cannot fit all needs. To define a new paper size, use
Line 39: Line 47:
 
<texcode>\definepapersize[exotic]
 
<texcode>\definepapersize[exotic]
 
                 [width=50mm, height=100mm]</texcode>
 
                 [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 <tt>\definepapersize</tt>. For example, <tt>A4</tt> paper is defined as:
+
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}}. For example, <tt>A4</tt> paper is defined as:
  
 
<texcode>\definepapersize [A4]  [width=210mm,height=297mm]</texcode>
 
<texcode>\definepapersize [A4]  [width=210mm,height=297mm]</texcode>
Line 54: Line 62:
 
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:
 
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>\setuppapersize[main] [A4]
+
<texcode>\definepapersize[main] [A4]
\setuppapersize[extra][A4,landscape]</texcode>
+
\definepapersize[extra][A4,landscape]</texcode>
One way to change document size is to permanently change the paper size using <tt>\setuppapersize</tt> and then revert back using <tt>\setuppapersize</tt>.
+
One way to change document size is to permanently change the paper size using {{cmd|setuppapersize}} and then revert back using {{cmd|setuppapersize}}.
  
 
<texcode>% Set the default paper size
 
<texcode>% Set the default paper size
Line 80: Line 88:
  
 
\stoptext</texcode>
 
\stoptext</texcode>
The <tt>\page</tt> before <tt>\setuppapersize</tt> is necessary as <tt>\setuppapersize</tt> changes the size of the current page.
+
The {{cmd|page}} before {{cmd|setuppapersize}} is necessary as {{cmd|setuppapersize}} 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 <tt>\setuppapersize</tt>, a convenient alternative is to use <tt>\adaptpapersize</tt>, which automatically reverts back to the existing paper size after ''one'' page. This is illustrated by the following example.
+
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}}, a convenient alternative is to use {{cmd|adaptpapersize}}, which automatically reverts back to the existing paper size after ''one'' page. This is illustrated by the following example.
  
 
<texcode>\setuppapersize[main]
 
<texcode>\setuppapersize[main]
 
\starttext
 
\starttext
Page 1. Potrait \page
+
Page 1. Portrait \page
Page 2. Potrait \page
+
Page 2. Portrait \page
 
\adaptpapersize[extra]
 
\adaptpapersize[extra]
 
Page 3. Landscape \page
 
Page 3. Landscape \page
Page 4. Potrait \page
+
Page 4. Portrait \page
 
\stoptext</texcode>
 
\stoptext</texcode>
As with <tt>\setuppapersize</tt>, always use an explicit <tt>\page</tt> before <tt>\adaptpapersize</tt>.
+
As with {{cmd|setuppapersize}}, always use an explicit {{cmd|page}} before {{cmd|adaptpapersize}}.
  
 
= Setting print size =
 
= 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 <tt>\setuppapersize</tt>:
+
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 an <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}}:
  
 
<texcode>\setuppapersize[A5][A4]</texcode>
 
<texcode>\setuppapersize[A5][A4]</texcode>
Line 124: Line 132:
 
== Defining page and print size combinations ==
 
== 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 <tt>\definepapersize</tt>. 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:
+
It is convenient to define paper-size/print-paper-size combination for later reuse. These are also defined using {{cmd|definepapersize}}. 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]
 
<texcode>\definepapersize[regular][A4][A4]
Line 133: Line 141:
 
\doifmode{proof}{\setuppapersize[proof]}</texcode>
 
\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.
 
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 =
 
= Notes =
  
 
<references />
 
<references />
 +
 +
[[Category:Layout]]

Revision as of 12:35, 8 June 2020

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 Page Design chapter of the new ConTeXt manual.

Basic setup

Setting paper size (\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).

Changing paper size is easy, for letter paper:[1]

\setuppapersize[letter]

Similarly, to get A4 paper, use:

\setuppapersize[A4]

Predefined Paper Sizes

Beyond A4 and letter, ConTeXt predefines many other commonly used paper sizes (see Paper sizes page for actuals dimensions in mm). These include:

ISO (EN/DIN) sizes
  • series A and B, from ISO-216 standard (e.g. "A4")
  • envelope: serie C 0–10, plus DL
  • series RA, SRA 0–4, from ISO-217 standard;
  • ISO-based "2 A0" (double A0), "4 A0", "C6/C5", A3plus
US sizes
  • letter, ledger, tabloid, legal, folio, executive, A, B, C
  • envelope: "envelope 9" (10, 11, 12, 14), monarch, check, DL, E4
Swedish sizes
  • sizes G5 and E5 from SIS-014711 standard. These are used for Swedish theses;
Screen sizes
  • 4:3 ratio: S3–6 (width 300–600 pt)
  • 1:1 ratio: S33, S44, S55, S66 (300 × 300 pt etc.)
  • 8:5 ratio: SM (720 × 450 pt), they have the same height as S6
  • 16:9 ratio: SW (800 × 450 pt), they have the same height as S6
CD (120 × 120 mm) for CD Covers

Plus keywords oversized (plus 1.5 cm), doublesized, doubleoversized, undersized (minus 1.5 cm). For definitions, see page-lay.mkii and page-lay.mkiv.

Defining new paper sizes (\definepapersize)

The predefined paper sizes in ConTeXt cannot fit all needs. To define a new paper size, use

\definepapersize[exotic]
                [width=50mm, height=100mm]

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 \definepapersize. For example, A4 paper is defined as:

\definepapersize [A4]  [width=210mm,height=297mm]

Use this new paper size like any of the predefined paper sizes. For example, to set the paper size to 50mm x 100mm paper, use

\setuppapersize[exotic]

Orientation

Most of the popular paper sizes default to a portrait orientation. To get landscape orientation, use

\setuppapersize[letter,landscape]

Changing paper setup mid-document

Normally, the paper size is set up once—in the environment file—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:

\definepapersize[main] [A4]
\definepapersize[extra][A4,landscape]

One way to change document size is to permanently change the paper size using \setuppapersize and then revert back using \setuppapersize.

% Set the default paper size
\setuppapersize[main]

\starttext

% ...
% text with main paper size
% ...

\page \setuppapersize[extra]

% ...
% pages in landscape mode
% ...

\page \setuppapersize[main]

% ...
% back to main paper size
% ...

\stoptext

The \page before \setuppapersize is necessary as \setuppapersize 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 <\setuppapersize, a convenient alternative is to use \adaptpapersize, which automatically reverts back to the existing paper size after one page. This is illustrated by the following example.

\setuppapersize[main]
\starttext
Page 1. Portrait \page
Page 2. Portrait \page
\adaptpapersize[extra]
Page 3. Landscape \page
Page 4. Portrait \page
\stoptext

As with \setuppapersize, always use an explicit \page before \adaptpapersize.

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—so you print on a large paper and crop later—or because the page size that you are using is not standard. For example, suppose you want to print an A5 page on an A4 paper (and crop later). For that, you need to specify that the paper size is A5 but the print paper size is A4. This information is specified using the two argument version of the \setuppapersize:

\setuppapersize[A5][A4]

Changing page location

By default, this places the A5 page on the top left corner of the A4 paper. To place the A5 page in the middle of the A4 paper use:

\setuppapersize[A5][A4]
\setuplayout[location={middle,middle}]

Other possible values for location are: {top,left}, {top,middle}, {top,right}, {middle,right}, {middle,left}, {bottom,left}, {bottom,middle}, and {bottom,right}. Since {middle, middle} is the most commonly used value, it has a shortcut—location=middle.

If you use {*,left} or {*,right} and print double-sided, then also add duplex as an option; for example location={duplex,top,left}. This ensures that the page paper is moved appropriately on even pages.

Crop marks

To get crop marks (also called cut marks) use

\setuplayout[marking=on]

By default, the page numbers are also included with the crop marks. To get additional information like job name, current date and time along with the crop marks, use

\setuplayout[marking=text]

If you want just the crop marks, and no other text, use

\setuplayout[marking=empty]


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 \definepapersize. For example, suppose you want to define two paper-size/print-paper-size combinations: A4 paper on A4 print paper for normal work flow, and A4 paper on A3 print paper for the final proofs. For that, use the following:

\definepapersize[regular][A4][A4]
\definepapersize[proof]  [A4][A3]

You can then combine these paper sizes with Modes:

\setuppapersize[regular]
\doifmode{proof}{\setuppapersize[proof]}

Then, when you compile the document in the normal manner, you will get A4 paper on A4 print paper; if you compile the document with --mode=proof, then you will get a A4 paper on A3 print paper.

Fitting pages to their content

ConTeXt has three commands that create a page that is exactly large enough to fit its contents.

  • \startTEXpage — start a page that fits its contents exactly. Or has some extra space around the edges, if you specify offset.
  • \startpagefigure — start a page just large enough to fit a figure, possibly with some text underneath
  • \startMPpage — start a page just large enough to fit its MetaPost contents

Notes

  1. The syntax used here only works with ConTeXt versions newer than February 2011. Before that, you had to use
    \setuppapersize[letter][letter]

    to get letter sized paper. You may wonder why we need to repeat the paper size twice. In most cases, these are the same. You only need to use different arguments if you want to print on a bigger paper and trim it later (see the section on print size for details).