| 1 |
.\" -*- mode: text; coding: utf-8; -*- |
| 2 |
.\" |
| 3 |
.\" Copyright (C) 2012-2020 Free Software Foundation, Inc. |
| 4 |
.\" |
| 5 |
.\" This file is part of mom, which is part of groff, a free software |
| 6 |
.\" project. |
| 7 |
.\" |
| 8 |
.\" You can redistribute it and/or modify it under the terms of the |
| 9 |
.\" GNU General Public License as published by the "Free Software |
| 10 |
\" Foundation", version\~2. |
| 11 |
.\" |
| 12 |
.\" The license text is available on the internet at |
| 13 |
.\" <http://www.gnu.org/licenses/gpl-2.0.html> |
| 14 |
.\" |
| 15 |
.PAPER A4 |
| 16 |
.\" Reference macros (metadata) |
| 17 |
.TITLE "Producing PDFs" "with groff and mom" |
| 18 |
.PDF_TITLE "\*[$TITLE] |
| 19 |
.COPYRIGHT "20\*[BU3]1\*[BU2]5, 20\*[BU3]1\*[BU2]7 Free Software Foundation |
| 20 |
.AUTHOR "Deri James" "\*[UP .5p]and" "Peter Schaffter" |
| 21 |
.\" Cover author style |
| 22 |
.COVER_AUTHOR_STYLE \ |
| 23 |
LEAD 15 \ |
| 24 |
SPACE -.5v |
| 25 |
.\" Docheader author style |
| 26 |
.AUTHOR_STYLE \ |
| 27 |
LEAD 14 \ |
| 28 |
SPACE -.75 |
| 29 |
.ATTRIBUTE_STRING "" \" Don't print 'by' |
| 30 |
.\" |
| 31 |
.PDF_BOOKMARKS_OPEN 2 |
| 32 |
.\" Formatting style, margins |
| 33 |
.PRINTSTYLE TYPESET |
| 34 |
.L_MARGIN 2.5c |
| 35 |
.R_MARGIN 2.5c |
| 36 |
.B_MARGIN 2.5c |
| 37 |
.\" General defaults |
| 38 |
.FAM H |
| 39 |
.FT R |
| 40 |
.PT_SIZE 10.5 |
| 41 |
.AUTOLEAD 3 |
| 42 |
.PARA_INDENT 0 \" No indent because we're spacing paragraphs. |
| 43 |
.COVERTEXT |
| 44 |
.SP .5v |
| 45 |
.QUAD CENTER |
| 46 |
.HY off |
| 47 |
.IB 8P |
| 48 |
.\" Copyright notice |
| 49 |
This file is part of groff, the GNU roff typesetting system. |
| 50 |
.SP .5v |
| 51 |
Groff is free software. You can redistribute it |
| 52 |
and\*[FU3]/or modify it under the terms of the GNU |
| 53 |
General Public License as published by the |
| 54 |
Free Software Foundation, either version 3 |
| 55 |
of the License, or (at your option) any later |
| 56 |
version. |
| 57 |
.SP .5v |
| 58 |
You should have received a copy of the GNU |
| 59 |
General Public License along with this program. |
| 60 |
If not, see: |
| 61 |
.SP .25v |
| 62 |
.PDF_LINK_COLOR 0.0 0.3 0.9 |
| 63 |
.PDF_WWW_LINK http://www.gnu.org/licenses/ |
| 64 |
.IQ CLEAR |
| 65 |
.HY |
| 66 |
.COVERTEXT end |
| 67 |
.\" Cover and page header |
| 68 |
.COVER TITLE AUTHOR COPYRIGHT COVERTEXT |
| 69 |
.HEADER_LEFT "James, Schaffter" |
| 70 |
.\" |
| 71 |
.COVER_LEAD +3.5 |
| 72 |
.DOCHEADER_LEAD +3.5 |
| 73 |
.\" Color for code snippets |
| 74 |
.NEWCOLOUR dark-grey RGB #343434 |
| 75 |
.\" Make QUOTE look like CODE |
| 76 |
.QUOTE_STYLE \ |
| 77 |
FAMILY C \ |
| 78 |
FONT B \ |
| 79 |
SIZE +1.5 \ |
| 80 |
COLOR dark-grey \ |
| 81 |
INDENT 9p |
| 82 |
.\" |
| 83 |
.CODE_STYLE \ |
| 84 |
FONT B \ |
| 85 |
SIZE 115 \ |
| 86 |
COLOR dark-grey |
| 87 |
.CONDENSE 87 \" Condense percentage used in COD |
| 88 |
.\" |
| 89 |
.HEADING_STYLE 1 \ |
| 90 |
NUMBER \ |
| 91 |
FONT B \ |
| 92 |
SIZE +1 \ |
| 93 |
BASELINE_ADJUST \n[.v]/5 |
| 94 |
.HEADING_STYLE 2 \ |
| 95 |
NUMBER \ |
| 96 |
FONT I \ |
| 97 |
SIZE +.25 \ |
| 98 |
BASELINE_ADJUST \n[.v]/5 |
| 99 |
.\" |
| 100 |
.FOOTNOTE_SIZE -1 |
| 101 |
.\" Character definitions for program names, opts, etc. |
| 102 |
.char \[ghostscript] \*[BD]ghostscript\*[PREV] |
| 103 |
.char \[groff] \*[BD]groff\*[PREV] |
| 104 |
.char \[gropdf] \*[BD]gropdf\*[PREV] |
| 105 |
.char \[grops] \*[BD]grops\*[PREV] |
| 106 |
.char \[man] \*[BD]man\*[PREV] |
| 107 |
.char \[-mom] \*[BD]\-mom\*[PREV] |
| 108 |
.char \[mom] \*[BD]mom\*[PREV] |
| 109 |
.char \[-mpdfmark] \*[BD]\-mpdfmark\*[PREV] |
| 110 |
.char \[ms] \*[BD]ms\*[PREV] |
| 111 |
.char \[pdfmom] \*[BD]pdfmom\*[PREV] |
| 112 |
.char \[pdfroff] \*[BD]pdfroff\*[PREV] |
| 113 |
.char \[-P-e] \*[BD]\-P\-e\*[PREV] |
| 114 |
.char \[-P-p<papersize>] \*[BD]\-P\-p<papersize>\*[PREV] |
| 115 |
.char \[ps2pdf] \*[BD]ps2pdf\*[PREV] |
| 116 |
.char \[psselect] \*[BD]psselect\*[PREV] |
| 117 |
.char \[-T] \*[BD]\-T\*[PREV] |
| 118 |
.char \[-Tpdf] \*[BD]\-Tpdf\*[PREV] |
| 119 |
.char \[-Tps] \*[BD]\-Tps\*[PREV] |
| 120 |
.\" Strings for inline code |
| 121 |
.ds cod \E*[CODE]\&\E*[COND] |
| 122 |
.ds codx \E*[CONDX]\E*[CODE off]\& |
| 123 |
.\" Paragraph spacing |
| 124 |
.PARA_SPACE .3v |
| 125 |
.\" Wrapper around QUOTE |
| 126 |
.de COD |
| 127 |
. QUOTE |
| 128 |
. nop \*[COND]\\$*\*[CONDX] |
| 129 |
. QUOTE OFF |
| 130 |
.. |
| 131 |
.\" Table of contents |
| 132 |
.TOC_PADDING 2 |
| 133 |
.SPACE_TOC_ITEMS |
| 134 |
.AUTO_RELOCATE_TOC |
| 135 |
.TOC_ENTRY_STYLE 2 FONT I |
| 136 |
.TOC_LEAD 14.5 ADJUST |
| 137 |
.TOC_PADDING 1 |
| 138 |
.\" |
| 139 |
.DOCHEADER_ADVANCE 5c \" Begin docheader this distance down from top of page |
| 140 |
.\" |
| 141 |
.NO_SHIM \" Use flex spacing |
| 142 |
.START |
| 143 |
. |
| 144 |
.SP .5c |
| 145 |
.HEADING 1 NAMED intro "Introduction" |
| 146 |
.PP |
| 147 |
.RW .12 |
| 148 |
PDF documents are intended to be "electronic paper,\*[BU6]" and, as |
| 149 |
such, take advantage of the digital medium in ways that PostScript |
| 150 |
documents do not. Chief amongst these are clickable links that |
| 151 |
point to named destinations, either within the documents themselves |
| 152 |
.PDF_LINK internal PREFIX ( SUFFIX ) "internal links" |
| 153 |
or to remote web pages |
| 154 |
.PDF_LINK external PREFIX ( SUFFIX ), "external links" |
| 155 |
and the generation of a clickable document outline that appears in |
| 156 |
the Contents panel of most PDF viewers. |
| 157 |
.PP |
| 158 |
.RW .01 |
| 159 |
Using \[groff] and \[mom] to produce PDF documents results in the |
| 160 |
automatic generation of clickable document outlines (discussed |
| 161 |
below, |
| 162 |
.PDF_LINK outline SUFFIX ), + |
| 163 |
and, if the \*[cod]TOC\*[codx] macro is included in the source file, |
| 164 |
entries in the printable table of contents can be clicked on as well |
| 165 |
when the document is viewed at the screen (see |
| 166 |
.PDF_LINK toc SUFFIX ). + |
| 167 |
.RW 0 |
| 168 |
.HEADING 1 NAMED generating "Using groff to generate PDF files" |
| 169 |
.PP |
| 170 |
Groff provides more than one way to generate PDF documents from |
| 171 |
files formatted with the \[mom] macros. One is to call \[groff] |
| 172 |
directly, either with |
| 173 |
.COD "groff [\-Tps] \-mom \-m pdfmark doc.mom | ps2pdf \- doc.pdf |
| 174 |
which pipes output from the \[grops] PostScript driver through |
| 175 |
\[ps2pdf], or |
| 176 |
.COD "groff \-Tpdf \-mom doc.mom > doc.pdf |
| 177 |
which uses the native PDF driver, \[gropdf]. Alternatively, one may |
| 178 |
call the wrapper |
| 179 |
.COD "pdfroff \-mom \-mpdfmark \-\-no-toc doc.mom > doc.pdf |
| 180 |
A fourth, preferred method is to use |
| 181 |
.PDF_LINK pdfmom SUFFIX , "\[pdfmom]" |
| 182 |
which is strongly recommended since it implements the full range |
| 183 |
of PDF features available in \[mom]. |
| 184 |
.COD "pdfmom doc.mom > doc.pdf |
| 185 |
One reason to prefer using the native PDF driver (via \[pdfmom] or |
| 186 |
\[-Tpdf]) is that papersizes set within mom source files (see |
| 187 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/typesetting.html#page-setup-intro SUFFIX ) \ |
| 188 |
"paper and page setup macros" |
| 189 |
do not require a corresponding \[-P-p<papersize>] flag on the |
| 190 |
command line. |
| 191 |
.PP |
| 192 |
There are other minor differences between the methods, discussed |
| 193 |
.PDF_LINK pdf-diff SUFFIX . "here" |
| 194 |
.RW 0 |
| 195 |
.HEADING 1 NAMED links "Creating PDF links with mom" |
| 196 |
.PP |
| 197 |
Often, but not always, links in the body of a PDF document point |
| 198 |
to headings elsewhere in the same document. Creating these links |
| 199 |
is a simple process. First, identify the places to link to |
| 200 |
("destinations"), then link to them from any place in the document. |
| 201 |
.HEADING 2 NAMED naming "Creating destination points at headings" |
| 202 |
.PP |
| 203 |
The first step in creating links to a heading is to give the |
| 204 |
heading a unique destination name. With mom, this is done by |
| 205 |
adding \*[cod]NAMED\|<id>\*[codx] to the HEADING macro, where |
| 206 |
\*[cod]<id>\*[codx] is a unique identifier for the heading. For |
| 207 |
example, |
| 208 |
.PDF_TARGET intro-ex |
| 209 |
.COD "\&.HEADING 1 NAMED intro \[dq]Introduction\[dq]" |
| 210 |
would, in addition to printing the head in the body of the document, |
| 211 |
identify the introduction by the unique id, "intro"\*[BU6]. This |
| 212 |
id, or name, can then be used to create links to the introduction |
| 213 |
from any part of the document. |
| 214 |
.PP |
| 215 |
Furthermore, \*[cod]NAMED\|<id>\*[codx] stores the text of the |
| 216 |
heading for use later on when linking to it (see |
| 217 |
.PDF_LINK internal SUFFIX ). + |
| 218 |
If headings are being numbered, the heading number is prepended. |
| 219 |
.HEADING 2 NAMED target "Creating destination points at arbitrary locations" |
| 220 |
.PP |
| 221 |
Any part of a document can be a link destination, not just headings. |
| 222 |
For example, say you create a table that needs to be referred to |
| 223 |
from other parts of the document. You'd identify the location of |
| 224 |
the table by placing |
| 225 |
.COD "\&.PDF_TARGET <id> \[dq]<text>\[dq]" |
| 226 |
just above the table in the source file. As with |
| 227 |
\*[cod]HEADING\*[codx], \*[cod]<id>\*[codx] is any unique name. |
| 228 |
\*[cod]<text>\*[codx] is optional. \*[cod]<id>\*[codx] can now be linked |
| 229 |
to from anywhere in the document. |
| 230 |
.SP 2.5p |
| 231 |
.HEADING 2 NAMED internal "Creating internal links" |
| 232 |
.PP |
| 233 |
Internal links are clickable text areas that allow you to jump to |
| 234 |
named destinations within a document. (See |
| 235 |
.PDF_LINK external "here" |
| 236 |
for a description of external links.) |
| 237 |
.PP |
| 238 |
Internal links are created with the macro \*[cod]PDF_LINK\*[codx], |
| 239 |
which takes the form |
| 240 |
.COD "\&.PDF_LINK <id> [PREFIX <text>] [SUFFIX <text>] \ |
| 241 |
\[dq]<hotlink text>\[dq]" |
| 242 |
where \*[cod]<id>\*[codx] is a named destination point elsewhere in |
| 243 |
the document (see |
| 244 |
.PDF_LINK naming + |
| 245 |
and |
| 246 |
.PDF_LINK target SUFFIX ). + |
| 247 |
.PP |
| 248 |
\*[cod]PREFIX\|<text>\*[codx] and \*[cod]SUFFIX\|<text>\*[codx], both or |
| 249 |
either of which are optional, are printed around the clickable area |
| 250 |
but do not form part of the link itself. |
| 251 |
.PP |
| 252 |
\*[cod]<hotlink text>\*[codx] is the text that should be clickable, |
| 253 |
identifiable in the PDF document by the colour assigned to links |
| 254 |
(see |
| 255 |
.PDF_LINK colour SUFFIX ). + |
| 256 |
.PDF_TARGET expando |
| 257 |
.PP |
| 258 |
If the hotlink text ends in \*[cod]\[dq]*\[dq]\*[codx]\*[BU9], |
| 259 |
the asterisk is replaced by the text of the destination |
| 260 |
point, assuming it's a heading. If the hotlink text ends in |
| 261 |
\*[cod]\[dq]+\[dq]\*[codx]\*[BU9], the replacement text is surrounded |
| 262 |
by quotes. |
| 263 |
.PP |
| 264 |
Using our |
| 265 |
.PDF_LINK intro-ex SUFFIX , "HEADING example" |
| 266 |
.RW .1 |
| 267 |
above, the following invocation of \*[cod]PDF_LINK\*[codx] would |
| 268 |
produce a click\%able link to the introduction: |
| 269 |
.COD "\&.PDF_LINK intro PREFIX ( SUFFIX ). \[dq]see: +\[dq]" |
| 270 |
.RW 0 |
| 271 |
In the text, the link would look like this: |
| 272 |
.PDF_LINK intro PREFIX ( SUFFIX ). "see: +" |
| 273 |
.HEADING 2 NAMED external "Creating external links" |
| 274 |
.PP |
| 275 |
External links are clickable text areas whose destination is a |
| 276 |
URL. Clicking on them causes a browser window to pop up with the |
| 277 |
destination address. |
| 278 |
.PP |
| 279 |
The format of the macro to create external links is similar to the |
| 280 |
one for creating internal links: |
| 281 |
.COD "\&.PDF_WWW_LINK <url> [PREFIX <text>] [SUFFIX <text>] [\[dq]<hotlink text>\[dq]]" |
| 282 |
\*[cod]<url>\*[codx] is any valid URL, usually a web address; |
| 283 |
\*[cod]PREFIX\|<text>\*[codx] and \*[cod]SUFFIX\|<text>\*[codx] have |
| 284 |
exactly the same meaning, as does \*[cod]<hotlink text>\*[codx], |
| 285 |
which furthermore accepts the same expandos, \*[cod]\[dq]+\[dq]\*[codx] and |
| 286 |
\*[cod]\[dq]*\[dq]\*[codx]. |
| 287 |
.PP |
| 288 |
.RW .1 |
| 289 |
If no hotlink text is given, then \*[cod]<url>\*[codx] is |
| 290 |
used as the text. If hotlink text is given and ends in |
| 291 |
\*[cod]\[dq]*\[dq]\*[codx]\*[BU9], the asterisk is replaced by the |
| 292 |
URL. If it ends in \*[cod]\[dq]+\[dq]\*[codx]\*[BU9], the URL is |
| 293 |
surrounded by quotes. As an example, |
| 294 |
.RW 0 |
| 295 |
.COD "\&.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/toc.html |
| 296 |
would open mom's online documentation at |
| 297 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/toc.html SUFFIX "." |
| 298 |
The same, with \*[cod]\[dq]here\[dq]\*[codx] supplied as |
| 299 |
hotlink text, lets you click |
| 300 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/toc.html "here" |
| 301 |
instead. |
| 302 |
.HEADING 2 NAMED colour "Assigning a colour to links" |
| 303 |
.PP |
| 304 |
The colour of links is set with |
| 305 |
.COD "\&.PDF_LINK_COLOR <xcolor> | <newcolor> | <r g b> | <#rrggbb> |
| 306 |
where \*[cod]<xcolor>\*[codx] or \*[cod]<newcolor>\*[codx] are the names |
| 307 |
of colours already initialized with |
| 308 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/color.html#xcolor "XCOLOR" |
| 309 |
or |
| 310 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/color.html#newcolor SUFFIX . "NEWCOLOR" |
| 311 |
If you prefer to define a new colour (using the RGB colour scheme), |
| 312 |
enter it either as 3 numbers between |
| 313 |
0.0 \*[UP 1p]\[->]\*[DOWN 1p] 1\*[BU4].0 |
| 314 |
or as a 6 character hex string. Thus |
| 315 |
.SP .5v |
| 316 |
\*[FWD 6p]\*[cod].PDF_LINK_COLOR #ff0000\*[codx] |
| 317 |
\ \*[SIZE -.5]and\*[SIZE]\ \" |
| 318 |
\*[cod].PDF_LINK_COLOR 1.0 0 0\*[codx] |
| 319 |
.SP .5v |
| 320 |
both lead to mom using |
| 321 |
.PDF_LINK_COLOR 1 0 0 |
| 322 |
.PDF_LINK colour red |
| 323 |
.PDF_LINK_COLOR |
| 324 |
links. |
| 325 |
.PP |
| 326 |
The default colour can be restored by calling |
| 327 |
\*[cod]PDF_LINK_COLOR\*[codx] with no parameter. |
| 328 |
.FLOAT |
| 329 |
.JUSTIFY |
| 330 |
.BOX-NOTE 3P |
| 331 |
\*[BD]Note:\*[PREV] |
| 332 |
The decimal scheme for creating colours must be used if a file is to |
| 333 |
be processed with |
| 334 |
\[oq]\[groff]\~\[-Tps]\~\[-mpdfmark]\[cq], |
| 335 |
\[oq]\[pdfroff]\[cq], or |
| 336 |
\[oq]\[pdfmom]\~\[-Tps]\[cq]. |
| 337 |
.IBQ |
| 338 |
.FLOAT off |
| 339 |
.SP .5v |
| 340 |
.HEADING 1 NAMED outline "The PDF Outline" |
| 341 |
.PP |
| 342 |
Most PDF viewers provide a panel that displays a document's outline, |
| 343 |
similar to a table of contents. Clicking on an entry navigates |
| 344 |
directly to the appropriate place in the document. |
| 345 |
.PP |
| 346 |
Mom generates PDF outlines the same way she populates |
| 347 |
her own table of contents: by intercepting calls to the |
| 348 |
\*[cod]HEADING\*[codx] macro, as well as to the various title |
| 349 |
and chapter macros used in namimg documents, and allocating each a |
| 350 |
hierarchic level. |
| 351 |
.PP |
| 352 |
Covers, titles/chapters, and the table of contents are all |
| 353 |
assigned to level 1\*[BU5]. Subsequent headings are assigned to |
| 354 |
n\*[UP 1p]+\*[DOWN 1p]\*[BU4]1, where n is the level given to |
| 355 |
\*[cod]HEADING\*[codx]. |
| 356 |
.PP |
| 357 |
.RW .22 |
| 358 |
The PDF outline can sensibly recover from skipped or omitted heading |
| 359 |
levels; the printed table of contents cannot. Users are therefore |
| 360 |
advised to use headings in logical order, not for typographic |
| 361 |
effects. |
| 362 |
.RW 0 |
| 363 |
.HEADING 2 NAMED open-close "Opening and closing levels |
| 364 |
.PP |
| 365 |
A level is said to be open if one or more levels beneath it is |
| 366 |
visible in the PDF outline. Closed \%levels have at least one level |
| 367 |
beneath them that is not visible unless the closed link is clicked. |
| 368 |
It is common for only the first two levels to be open so the outline |
| 369 |
doesn't look cluttered. |
| 370 |
.PP |
| 371 |
To establish which levels should be open by default when a document |
| 372 |
loads, use |
| 373 |
.COD "\&.PDF_BOOKMARKS_OPEN n |
| 374 |
where \*[cod]n\*[codx] is a number specifying at which level all |
| 375 |
subsequent ones should be closed. |
| 376 |
.PP |
| 377 |
If, at any point in the document, you specify |
| 378 |
.COD "\&.PDF_BOOKMARKS_OPEN NO \e\[dq] or any other text argument |
| 379 |
then all subsequent bookmarks will be closed until |
| 380 |
\*[cod]PDF_BOOKMARKS_OPEN\*[codx] opens them again. |
| 381 |
.HEADING 2 NAMED disabling "Suspending/disabling collection of outline entries |
| 382 |
.PP |
| 383 |
Suspending the collection of entries for the PDF outline is |
| 384 |
accomplished with |
| 385 |
.COD "\&.PDF_BOOKMARKS OFF |
| 386 |
Mom's default is to collect entries, so if the command is placed at |
| 387 |
the start of a document, it \%disables entry collection completely. |
| 388 |
Elsewhere, it suspends collection until you re-enable it with |
| 389 |
.COD "\&.PDF_BOOKMARKS \e\[dq] i.e. with no parameter |
| 390 |
.SP -1 |
| 391 |
.HEADING 2 NAMED pdf:title "The PDF window title" |
| 392 |
.PP |
| 393 |
While not strictly part of the PDF outline, the title of a document |
| 394 |
can be displayed as the document viewer's window title. The macro |
| 395 |
to accomplish this is |
| 396 |
.COD "\&.PDF_TITLE\ \[dq]<window title>\[dq] |
| 397 |
It can take any text, so the viewer window title need not be the |
| 398 |
same as the document's title. |
| 399 |
.FLOAT |
| 400 |
.JUSTIFY |
| 401 |
.BOX-NOTE 4P+8p |
| 402 |
\*[BD]Note:\*[PREV] The macro, \*[cod]DOC_TITLE\*[codx], always |
| 403 |
invokes \*[cod]PDF_TITLE\*[codx]. If this is not what you want, you |
| 404 |
can remove the window title by issuing |
| 405 |
.COD ".PDF_TITLE \[dq]\[dq] \e\[dq] ie. with a blank argument |
| 406 |
.IBQ |
| 407 |
.FLOAT off |
| 408 |
\#.SP .5v |
| 409 |
.HEADING 1 NAMED toc "Tables of Contents" |
| 410 |
.RLD .5v |
| 411 |
.HEADING 2 NAMED toc:gen "Generating a Table of Contents |
| 412 |
.PP |
| 413 |
.RW .1 |
| 414 |
To generate a printable Table of Contents for any document, simply |
| 415 |
insert the macro, \*[cod]TOC\*[codx], as the last line of the source |
| 416 |
file. (Formatting of the printable Table of Contents is discussed in |
| 417 |
detail in the |
| 418 |
.PDF_WWW_LINK \ |
| 419 |
https://www.schaffter.ca/mom/momdoc/tables-of-contents.html#top \ |
| 420 |
SUFFIX ). "mom documentation" |
| 421 |
When the file is processed and loaded in a viewer, entries in the |
| 422 |
Table of Contents will be clickable links. |
| 423 |
.RW 0 |
| 424 |
.PP |
| 425 |
Whichever link colour is active at the end of the document, prior to |
| 426 |
\*[cod]TOC\*[codx], will be used for the \%Table of Contents |
| 427 |
links. |
| 428 |
.HEADING 2 NAMED toc:pos "Positioning the Table of Contents" |
| 429 |
.PP |
| 430 |
If \[groff]'s PostScript device (\[-Tps]) is used to process a mom |
| 431 |
file, the Table of Contents is printed at the end of the document. |
| 432 |
When this is not desirable, the PostScript output from \[groff] |
| 433 |
must be processed with \[psselect] in order to place the TOC in the |
| 434 |
preferred location. |
| 435 |
.PP |
| 436 |
When using mom and \[groff]'s native pdf device (via \[pdfmom] or |
| 437 |
\[groff] \[-Tpdf]), positioning of the Table of Contents can be done |
| 438 |
within the source file. |
| 439 |
.PP |
| 440 |
The command to control the placement of the TOC is |
| 441 |
.COD "\&.AUTO_RELOCATE_TOC [<position>] |
| 442 |
where the optional \*[cod]<position>\*[codx] can be one of these |
| 443 |
keywords: |
| 444 |
.LEFT |
| 445 |
.IL 2P |
| 446 |
.SP .25v |
| 447 |
\*[SIZE -.7]TOP\*[FU2]\*[UP .5p]\c |
| 448 |
.FOOTNOTE |
| 449 |
\*[BD]Note:\*[PREV] Documents without a COVER or DOC_COVER require |
| 450 |
the \*[cod]TOP\*[codx] argument. |
| 451 |
.FOOTNOTE off |
| 452 |
\*[IT]\*[SIZE +.2]\ |
| 453 |
(ie. at the very start of the document)\*[SIZE -.2]\*[PREV] |
| 454 |
BEFORE_DOCCOVER |
| 455 |
AFTER_DOCCOVER |
| 456 |
BEFORE_COVER |
| 457 |
AFTER_COVER\*[SIZE +.7] |
| 458 |
.SP .25v |
| 459 |
.ILQ |
| 460 |
.JUSTIFY |
| 461 |
It is normally not necessary to supply a keyword, since |
| 462 |
\*[cod]AUTO_RELOCATE_TOC\*[codx] places the TOC after the DOC_COVER, |
| 463 |
if there is one, or the first COVER when no DOC_COVER is present. |
| 464 |
In rare instances where it is desirable to place the TOC somewhere |
| 465 |
else in the document, there are two low-level commands, |
| 466 |
\*[cod].TOC_BEFORE_HERE\*[codx] |
| 467 |
\ \*[SIZE -.5]and\*[SIZE]\ \" |
| 468 |
\*[cod].TOC_AFTER_HERE\*[codx] |
| 469 |
which place the TOC either before or after the current page. |
| 470 |
.PP |
| 471 |
These last two commands have a small catch: although the TOC will |
| 472 |
appear where specified, the \%"Contents" entry in the PDF outline, |
| 473 |
which observes a hierarchy of levels, will assign the TOC to |
| 474 |
level\~\*[BU4]1\*[BU4], possibly disrupting the visual ordering of |
| 475 |
levels in the outline. |
| 476 |
.HEADING 1 NAMED simplify "pdfmom: Simplifying PDF output" |
| 477 |
.PP |
| 478 |
As explained in the section |
| 479 |
.PDF_LINK generating SUFFIX , * |
| 480 |
.RW .15 |
| 481 |
there are two established methods |
| 482 |
.RW 0 |
| 483 |
for creating PDF files with \[groff]: the original method, ie. |
| 484 |
passing the \[-Tps] and \[-mpdfmark] options to \[groff] (or using |
| 485 |
\[pdfroff], which does this for you); or the newer \[-Tpdf], which |
| 486 |
produces PDF files natively. |
| 487 |
.HEADING 2 NAMED fwd:ref "The problem of forward references" |
| 488 |
.PP |
| 489 |
.EW .2 |
| 490 |
Both methods encounter difficulties when dealing with forward |
| 491 |
references; that is, when a link \*[IT]\%earlier\/\*[PREV] in a |
| 492 |
document refers to a destination \*[IT]later\/\*[PREV] in the |
| 493 |
document and the link text terminates |
| 494 |
.EW 0 |
| 495 |
with one of the expandos, |
| 496 |
\*[cod]\[dq]*\[dq]\*[codx] or \*[cod]\[dq]+\[dq]\*[codx] |
| 497 |
(explained |
| 498 |
.PDF_LINK expando SUFFIX ). "here" |
| 499 |
Mom doesn't know what text to put in the expando because it has not |
| 500 |
yet been defined. This means that \[groff] must be run multiple |
| 501 |
times to find the unknown text. |
| 502 |
.PP |
| 503 |
.EW .2 |
| 504 |
The program \[pdfroff] exists to handle these multiple runs, but it |
| 505 |
imposes some limitations on the PDF features available with \[mom]. |
| 506 |
.EW 0 |
| 507 |
.HEADING 2 NAMED pdfmom "pdfmom" |
| 508 |
.PP |
| 509 |
\[pdfmom] performs the same function as \[pdfroff], and is the |
| 510 |
preferred, trouble-free way to generate PDF documents from a mom |
| 511 |
source file. Like \[pdfroff], it is a frontend to \[groff] and |
| 512 |
accepts all the same options (see \[man]\~\[groff]). |
| 513 |
.PP |
| 514 |
.EW .2 |
| 515 |
Called as-is, \[pdfmom] accepts all the same options as \[groff], |
| 516 |
and requires no additional flags. PDF generation is performed by |
| 517 |
\[gropdf], \[groff]'s native PDF driver: |
| 518 |
.EW 0 |
| 519 |
.COD "pdfmom doc.mom [groff opts] > doc.pdf |
| 520 |
If a \[-Tps] option is supplied, \[pdfmom] hands control over to |
| 521 |
\[pdfroff], and both \[groff] and \[pdfroff] options may given. |
| 522 |
The resulting PDF is produced from PostScript output fed into |
| 523 |
\[ghostscript]. |
| 524 |
.COD "pdfmom \-Tps [pdfroff opts [groff opts]] doc.mom > doc.pdf |
| 525 |
For either invocation, it is not necessary to add \[-mom] or |
| 526 |
\[-mpdfmark], as these are implied. |
| 527 |
.PP |
| 528 |
.RW .04 |
| 529 |
If Encapsulated PostScript or plain PostScript images have been |
| 530 |
embedded in a document with |
| 531 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/images.html#pspic SUFFIX , \ |
| 532 |
"PSPIC" |
| 533 |
the \[-Tps] option must be used. In most other cases, \[pdfmom] |
| 534 |
with no \[-T] flag is preferable. |
| 535 |
.RW 0 |
| 536 |
.HEADING 2 NAMED papersize "Setting papersize within a source file" |
| 537 |
.PP |
| 538 |
A significant convenience afforded by using \[pdfmom] (or \[groff] |
| 539 |
with the \[-Tpdf] flag) is that papersizes or page dimensions set |
| 540 |
within mom source files (see |
| 541 |
.PDF_WWW_LINK https://www.schaffter.ca/mom/momdoc/typesetting.html#page-setup-intro \ |
| 542 |
SUFFIX ) "paper and page setup macros" |
| 543 |
do not require a corresponding \[-P-p<papersize>] option on the |
| 544 |
command line. It is even possible to create documents with |
| 545 |
unequal-sized pages. |
| 546 |
.HEADING 2 NAMED pdf-diff \ |
| 547 |
"Differences between pdfmom and pdfroff" |
| 548 |
.PP |
| 549 |
Several features described in this manual are not available when |
| 550 |
the \[-Tps] option is given to \[pdfmom], nor when using \[pdfroff] |
| 551 |
or \[groff]\~\[-Tps]\~\[-mpdfmark]: |
| 552 |
.SP .25v |
| 553 |
.QUAD LEFT |
| 554 |
.HYPHENATION off |
| 555 |
.IB 16p |
| 556 |
.LIST |
| 557 |
.ITEM |
| 558 |
.PDF_LINK toc:pos "Relocation of the Table of Contents" |
| 559 |
is not supported. The TOC appears at the end of the document; |
| 560 |
\[psselect] must be used to re-order pages. |
| 561 |
.ITEM |
| 562 |
.RW .08 |
| 563 |
.WS -2 |
| 564 |
If a link crosses a page boundary, it will stop being a clickable |
| 565 |
hotspot on subsequent pages. |
| 566 |
.RW 0 |
| 567 |
.ITEM |
| 568 |
When establishing whether PDF outline levels are |
| 569 |
.PDF_LINK open-close SUFFIX , "open or closed" |
| 570 |
only the numerical parameter to \*[cod]PDF_BOOKMARKS_OPEN\*[codx] has |
| 571 |
any effect. |
| 572 |
.ITEM |
| 573 |
.PDF_LINK colour "PDF_LINK_COLOR" |
| 574 |
only accepts colour definitions in decimal notation. |
| 575 |
.LIST OFF |
| 576 |
.IQ |
| 577 |
.HEADING 1 \ |
| 578 |
"Comparison of \-Tps\*[FU4]/\*[FU2]\-mpdfmark with \-Tpdf\*[FU4]/\*[FU2]\-mom |
| 579 |
.SP .25v |
| 580 |
.IB |
| 581 |
\[-Tps]\*[FU4]/\*[FU2]\[-mpdfmark] |
| 582 |
.LIST |
| 583 |
.SHIFT_LIST 1P+6p |
| 584 |
.ITEM |
| 585 |
does not support all the features described here |
| 586 |
.ITEM |
| 587 |
accepts images and graphics embedded with PSPIC |
| 588 |
.LIST OFF |
| 589 |
.IQ |
| 590 |
.ALD .4v |
| 591 |
.IB |
| 592 |
\[-Tpdf]\*[FU4]/\*[FU2]\[-mom] |
| 593 |
.LIST |
| 594 |
.SHIFT_LIST 1P+6p |
| 595 |
.ITEM |
| 596 |
facilitates embedding fonts directly in the PDF file (if the |
| 597 |
\[-P-e] flag is given on the command line) |
| 598 |
.ITEM |
| 599 |
sets papersize from within the source file, circumventing the need |
| 600 |
for the papersize flag (\[-P-p<papersize>]) on the command line |
| 601 |
.ITEM |
| 602 |
is not compatible with |
| 603 |
.PDF_WWW_LINK \ |
| 604 |
https://www.schaffter.ca/mom/momdoc/docprocessing.html#printstyle \ |
| 605 |
"PRINTSTYLE TYPEWRITE" |
| 606 |
underlining (e.g., of italics) |
| 607 |
.ITEM |
| 608 |
generally produces larger files; these can be reduced by piping |
| 609 |
the output through \[ps2pdf] |
| 610 |
.SP -1.25v |
| 611 |
.BOX OUTLINED black SHADED grey90 WEIGHT 1p INSET 6p |
| 612 |
.JUSTIFY |
| 613 |
\*[BD]Note:\*[PREV] Owing to a known bug, PDF files piped through |
| 614 |
\[ps2pdf] lose some of their metadata, notably the window title set |
| 615 |
with \*[cod]PDF_TITLE\*[codx]. |
| 616 |
.BOX STOP |
| 617 |
.SP -.25v |
| 618 |
.LIST OFF |
| 619 |
.TOC |
| 620 |
.\" Local Variables: |
| 621 |
.\" mode: nroff |
| 622 |
.\" End: |
| 623 |
.\" vim: filetype=groff: |