1 #+TITLE: Groff and PDF export
4 #+OPTIONS: H:2 toc:t num:nil
8 # This file is released by its authors and contributors under the GNU
9 # Free Documentation license v1.3 or later, code examples are released
10 # under the GNU General Public License v3 or later.
12 Org mode provides the ability to export files marked with the Groff
13 Memorandum Macros (-mm) set. With additional processing it can turn
14 these files into PDF files that can be used for general
15 distribution. This feature is being provided as an alternative to the LaTeX
16 export being that not all Unix installations have TeX available while
17 Groff is commonly installed because it is needed for the generation of
20 The Groff export follows the sequence of macro calls needed for the
21 Memorandum Type covers.
23 Some example org files and corresponding exported pdf files from the
24 author of the library can be found on [[https://www.box.com/s/578d9a22c890ddcea8bd][this page]].
27 Include =(require 'ox-groff)= in your =.emacs= file. This feature
28 only works with the new =ox= facility.
30 * Groff MM macro summary
31 For the purpose of context, the following list describes some of the
32 macros used during export. These are built from data stored by your org
33 document and follows the order needed for the generation of cover
37 - AF :: Firm. It is populated with the content of the custom
38 variable org-groff-organization. It has a default value of
40 - TL :: Title. It uses the content of #+TITLE: during
41 export. Subtitles are supported with the use of a custom
43 - AU :: Author Macro. It uses the content of #+AUTHOR: during
45 - AT :: Author Title. It uses a custom option to populate the title,
46 otherwise it is not used.
47 - ND :: Date. It will use the content of #+DATE: during export. If
48 the #+DATE: is not written in your org file, it will default
49 to the date at the moment of export.
50 - MT :: Memorandum Type. It defines the structure of the document.
51 Groff supports the use of the different Memorandum Types as well
52 as Cover Pages (COVER/COVEND pairs).
54 * Groff export commands
55 - M-x org-groff-export-to-groff :: Converts buffer to Groff under
56 the assumptions that it was Org mode syntax. For an Org file like
57 =myfile.org= the Groff file will be =myfile.groff=. The file will
58 be overwritten without warning.
59 - M-x org-groff-export-to-pdf :: Converts buffer to a PDF file under
60 the assumptions that it was Org mode syntax. It uses Groff as its
63 * Header and sectioning structure
64 By default, the Groff export uses the =internal= (.MT 0) Memorandum Type
65 to generate documents.
67 You can change this globally by setting a different value for
68 =org-groff-default-class= or locally by adding an option
69 like =#+GROFF_CLASS: myclass= in your file. The class must be listed in
70 =org-groff-classes=. This variables defines the attributes for a
71 class, unlike L_aTex, the structure in Groff is defined in the content
72 of the document. What this variable defines is the style of the cover
73 page, the type of headers and if the export will generate a Table of
74 Content or Letter Signature.
76 The following classes are defined by default:
78 | <l10> | <c15> | <l40> | <l7> | <l> |
79 | class | Memorandum Type | Description | type | closing |
80 |------------+-----------------+------------------------------------------+---------+---------|
81 | internal | MT 0 | Creates a document with a cover page having the Subject, Date, Author and Organization. | memo | toc |
82 | file | MT 1 | Creates a document with a cover page having the Subject, Date, Author, Organization and MEMORANDUM FOR FILE header. | memo | toc |
83 | programmer | MT 2 | Creates a document with a cover page having the Subject, Date, Author, Organization and PROGRAMMER's NOTES header. | memo | toc |
84 | engineer | MT 3 | Creates a dcoument with a cover page having the Subject, Date, Author, Organization and ENGINEER's NOTES header | memo | toc |
85 | external | MT 4 | Creates a document with a cover page having the Subject, Date, Organization. Unlike the previous types, these will centered at the top | memo | toc |
86 | letter | MT 5 | Creates a document with a cover page having the Subject, Author and Date. It was traditionally used for letters in the original Bell Labs troff macros. However, Groff uses a different mechanism. This is kept for compatibility purposes | memo | sign |
87 | ms | COVER ms | Creates a document with a cover page similar to the one used by the ms macros. | cover | toc |
88 | se_ms | COVER se_ms | Creates a document with a cover page similar to the one used by the se macros. | cover | toc |
89 | dummy | "" | Creates a document without a cover, but defines all the cover attributes. This is used to generate documents with an Abstract section | memo | toc |
90 | block | "BL" | Creates a blocked letter using the Groff letter macros | letter | sign |
91 | semiblock | "SB" | Creates a semiblocked letter using the Groff letter macros | letter | sign |
92 | fullblock | "FB" | Creates a full block letter using the Groff letter macros | letter | sign |
93 | simplified | "SP" | Creates a simplified letter using the Groff letter macros | letter | sign |
94 | none | "" | Creates a document without any header. Used for customized documents or letters using the Groff's macros. | custom | nothing |
96 This variable can be used to defined your own document types in which
97 different type of documents be loaded using the .COVER or .so commands.
99 To define a new class add a new entry to the =org-groff-class=
100 list. The element of the list are:
102 - class name :: Name of the class
103 - document type invocation :: It defines how the document will be
104 invoked. If the document is a memorandum type, the whole .MT
105 command written. If the document is a COVER, only the
106 cover name is needed. If a custom file is being used, then an Groff
107 include statement (.so) with the path of the custom file is used.
108 - document options :: This is a property list containing the document
110 - :type :: Document type. Defines if the header information is created
111 or not. Options are "memo" for full header, "cover" for
112 full header plus COVER/COVENT statement, "custom" for no
114 - :heading :: Defines the command to invoke each of the section
115 heading. Options are 'default for the MM defaults and a
116 pointer to a function that will return a format string
117 containing the heading command. The format string takes
118 the =level= and the result of the =numberp= predicate that
119 indicates if the heading is a numbered one or not.
120 - :last-section :: Defines what is the last item to print. Options
121 are "toc" for table of content and "sign" for
123 - :paragraph :: Defines the command to invoke each of the paragraph
124 commands. Options are 'default or a pointer to a
125 function that will return a format string containing
126 the paragraph formatting commands before writing the
131 #+begin_src emacs-lisp
132 ;; org-groff--colored-heading is a function that will return
133 ;; the invocation of the .HL macro. The .HL macro is a custom groff
136 (defun org-groff--colored-heading (level numberedp)
137 (concat ".HL " (number-to-string level) " \"%s\"\n%s"))
139 ;; adds the class definition.
141 (add-to-list 'org-groff-classes
143 ".so myclassfile.groff"
144 (:heading org-groff--colored-heading :type
145 "memo" :last-section "toc")))
148 The =#+GROFF_CLASS_OPTIONS= option is used to add additional information
149 that changes the document structure or adds additional information that
150 gets exported. The following options are supported:
152 - :firm :: overrides the Organization name stored in the
153 =org-groff-organization=. /(string)/
154 - :author-title :: Adds the title for the author. If not available, the
155 .AT macro will not be used. /(string)/
156 - :hyphernate :: Enables or disables hyphernation support. /("yes"/"no")/
157 - :justify-right :: Enables or disables right justification /("yes"/"no")/
158 - :closing :: Changes the final closing from "Sincerely
159 yours,". The string is used as part of a call to .FC.
161 - :subtitle1 :: Defines a subtitle that maps to the "Charge Case"
163 - :subtitle2 :: Defines a subtitle that maps to the "File Case"
164 line. These two options might not be relevant for
165 many users, but setting values to these variables can be
166 helpful when custom covers are used. These two
167 options will be used when the .TL macro is invoked
168 during export. /(string)/
169 - :salutation :: Defines a custom salutation. Defaults to "Tho whom it
170 may concern" /(string)/
171 - :confidential :: Toggles the confidential batter. /(boolean)/
172 - :subject :: Adds a subject line /(string)/
173 - :references :: Addss an "In Reference Line". The value of =#+TITLE= is
174 used to populate the reference. /(boolean)/
175 - :attention :: Adds an "ATTENTION:" line. /(string)/
177 [1] All memorandum and letter types are defined by default. This command is useful
178 for new types of covers or when a custom file is being invoked.
181 The Groff exporter now features a set of tags that handles special
182 contents required for the inclusion of abstracts sections, and parts of
183 a business letter. The following special tags are in use by the
184 =ox-groff.el= exporter.
185 - FROM :: Defines the originator of a letter.
186 - TO :: Defines the recipient of a letter.
187 - ABSTRACT :: Defines the abstract part of a memo.
188 - NS :: Defines a notational sign at the letter. Notational signs items
189 like "Copy to" or "Carbon Copy" that are placed at the end of
190 the letter to indicate its disposition.
191 - BODY :: Defines the body part of a letter.
193 Special tags have several rules to follow. These are:
194 1. it must be the first tag of a list of tags, or a single tag,
195 2. it should be placed on first level headlines only,
196 3. items will be placed in their location and not written as part of
198 Use of tags is described in detail in the following sections.
200 ** Tags used for Letter types
201 Letter types use the FROM, TO, BODY and NS tags for placing content in
202 a document class of letter. Letter types are the ones defined as:
203 block, semiblock, simplified and fullblock.
205 Illustrated below is how a typical letter looks like:
213 Urbanizacion Palma Lejos
214 Calle 22, Bloque A, Numero 10
222 - FROM :: A header with a /:FROM:/ tag contains the address of the
223 originator. It needs to be
224 written in free form but it should follow the
225 addressing standards of the originator.
226 - TO :: A header with a /:TO:/ tag contains the address of the
227 recipient. It needs to be written in free form but it should
228 - BODY :: The /:BODY:/ tag indicates the start of the letter. This is needed to
229 start the content of the letter without writing the header on
231 - NS :: /:NS: will write the title of the header as the type of
232 disposition at the end of the letter, after the signature.
233 In the exaple, it will write "Copy to" Jill Brown at
234 the end of the letter.
236 ** Tags used for Memorandum Types letters
237 Letters that are of type "memo" also use the FROM, TO, BODY and NS tags
238 for placing content in a document class of letter.
239 Memo letter types are the ones defined as: "letter" or a custom cover.
241 Illustrated below is how a typical letter looks like:
252 Urbanizacion Palma Lejos
253 Calle 22, Bloque A, Numero 10
261 - FROM :: A header with a /:FROM:/ tag contains the address of the
262 originator. It needs to be
263 written in the same order as the AU macro call. This order is
264 1. Initials: Author initials
265 2. Author location: Building Name
266 3. Author department code
269 6. Additional items, like email or street address.
270 - TO :: A header with a /:TO:/ tag contains the address of the
271 recipient. It needs to be written in free form but it should
272 - BODY :: The /:BODY:/ tag indicates the start of the letter. This is needed to
273 start the content of the letter without writing the header on
275 - NS :: The /:NS:/ tag will write the title of the header as the type of
276 disposition at the end of the letter, after the signature.
277 In the exaple, it will write "Copy to" Jill Brown at
278 the end of the letter.
280 The placement of items depends directly on the way the cover has been
281 written. Although MT 5 is the "letter" memorandum type, Groff does not
282 follow the same convention as Bell Labs' troff. Therefore, the use
283 of these document classes is usable only to custom type covers.
285 ** Tags used for Memorandum Types documents.
286 Documents that are of type "memo" use the FROM and ABSTRACT
287 for placing content in a document class of memo
288 Letter types are the ones defined as: internal, external, file,
289 engineering, programmer or a custom cover.
291 Illustrated below is how a typical memo looks like:
305 - FROM :: A header with a /:FROM:/ tag contains the address of the
306 originator. It needs to be
307 written in the same order as the AU macro call. This order is
309 2. Author location code or Building Name
310 3. Author department number
313 6. Additional items, like email or street address.
314 - ABSTRACT :: A header with an /:ABSTRACT:/ tag contains the abstract
315 The abstract will be placed in the Abstract Location,
316 usually at the cover sheet, before the start of the document.
318 The placement of items depends directly on the way the cover has been
319 written and these follows the Bell Labs standards. This may or may not be
320 applicable for your case. As an alternative you should use the external
321 or letter class, which does not fully use the author information in the
322 cover or create your own custom cover.
324 However, the following alternate ordering used in headers with the FROM tag may
325 be more suitable to use than the one prescribed in the manual page. This
326 is because it does not follow the Bell Labs nomenclature.
328 This alternate ordering is:
330 2. Building Name or Location
333 5. Main telephone switch number
335 7. City, State, Province, Postal code
338 This ordering places the author information in the following order:
343 Switch Phone Number xExtension
345 City, State, Province, Postal Code
349 Out of all these values, the only one required is the initials. The
350 others do not need to be written and they will not be written in the document.
352 * Tables in Groff export
353 Groff uses the =tbl= preprocessor for table exports but the Groff export
354 process also supports the specification of labels, captions and table
355 options with the use of the =#+ATTR_GROFF:= line. The following options
356 are available to modify table behavior.
358 - :divider :: Places vertical bars between the different
360 - :placement :: Defines where the table will be placed in the
361 line. There are two possible values: center or
363 - :boxtype :: Defines the box type. /(symbol)/ The following values are supported:
364 - box :: Creates a border only. Default
365 - doublebox :: Creates a border with two lines.
366 - allbox :: Creates a table in which all cells are divided.
367 - none :: No borders.
368 - :title-line :: Forces the first row to be centered bold. /(boolean)/
369 - :diable-caption :: Captions are placed by default. This will disable
370 its creation. /(boolean)/
371 - :expand :: Expands the table across the width of the page.
372 - :long-cells :: Encloses all cells in T{ }T to allow the use of multi
373 line cells. /(boolean)/
374 The Groff export will honor columns definitions placed on top of a given
375 table in Org mode and propagates those definitions as =tbl= commands.
377 * Images in Groff export
378 Groff provides very limited support for image export and this limitation
379 is reflected in the export. The Groff export uses the =pic= preprocessor
380 and the -Tps device for image support. The only types that are supported
382 - Encapsulated Postscript (eps)
386 Other types need to be converted into either of these for its use in
389 Images that are linked to without description part in the line like
390 =[[file:img.eps]]= or =[[img.pic]]= will be inserted into the PDF output file
391 resulting from Groff processing. Org will use a .PSPIC (for eps and ps)
392 or PS/PE (for pic) macro to insert the image during export. If you have specified a
393 caption or label, it will be included in the export through a call to
394 the .FG macro. You can use an =#+ATTR_GROFF:= line to specify other
395 options, but these only affect postscript types ones (eps and ps). This
396 is because pic images contain its definition in the in the pic file.
397 The following options are available:
399 - :position :: Positions the image in the line. There are three options:
400 left, right and center /(symbol)/
401 - :width :: Defines the width of the image in Groff units. For
402 example :width 1.0i or :width 2.0c /(symbol)/
403 - :heigth :: Defines the hight of the image in Groff units. For
404 example :heigth 1.0i or :height 2.0c. /(symbol)/
406 [2] Although the MPIMG macro is available in the -mwww set, it
407 conflicts with the definition of list items (LI) in the -mm one. At
408 the end, these macros convert images to EPS.
410 * Footnotes and References
411 The Groff export uses the same footnote mechanism to identify footnotes
412 and bibliographic references. Adding a =\[1\]= or a =\[fn:123\]= marker with its
413 appropriate reference will create a footnote at the end of the page.
414 However adding a reference with a /"rl"/ tag, creates a Reference to the
419 This is a refered text\[fn:rl1\].
420 \[fn:rl1\] Author, Title (c) 2010.
423 Will place "Author, Title (c) 2010" in the reference list in the Table
426 Footnotes markers with the same tag will refer to the same reference in
430 Special character substitution can be enabled if there is a list
431 specified in the =org-groff-special-char= variable. This variable
432 consists of a list of cons pairs in which the first value is the item to
433 substitute and the second value is the value to be substituted with. By
434 default it will substitute (c) for copyright notice, (tm) for trademark
435 and (rg) for registered mark.
437 Character substitution can be disabled by setting this variable to *nil*.
439 * Source highlight in Groff export
440 There are no packages or processors for syntax highlight in
441 Groff. However this feature is available for Groff export with the use
442 of GNU's source highlight
443 ([[http://www.gnu.org/software/src-highlite/]]). The steps needed to use
444 this feature are as follows:
446 1. Install source highlight according to the instruction in the
447 distribution. Source highlight requires the Boost [[http://www.boost.org][www.boost.org]]
448 libraries installed and available as well. See their respective
449 documentation for details.
450 2. Make sure that the source highlight binary is available in your
452 3. Download the groff language files from
453 [[http://www.github.com/papoanaya/emacs_utils/source-highlight]]. Place
454 them in the source-highlight configuration directory, usually under
455 =share/source-highlight=. Note that the outlang.map will replace the
456 one in the configuration directory. If you have custom outlang.map
457 entries, they have to be merged with the ones from the Groff
459 4. Set the custom variable =org-groff-source-highlight= to
460 *t* in your .emacs file (i. e. =(setq org-groff-source-highlight t)=)
462 When the #+begin_src line is used with a supported language, the Groff
463 export process will submit the block to source-highlight for
468 #+begin_src emacs-lisp
469 (message "Hello World")
473 The resultant text will have Groff formatted text that corresponds to
474 the highlighted code. This code will be surrounded with a Display Static pair
475 (DS/DE) and finishes with a call to the EX macro. EX will add an
476 /Exhibit/ caption at the bottom of the highlighted source.
478 The following languages are supported by default:
480 | begin_src tag | source highlight language |
481 |----------------------+----------------------|
482 | emacs-lisp | lisp |
490 | fortran | fortran |
501 | javascript | javascript |
503 | shell-script | sh |
518 | postscript | postscript |
520 | properties | properties |
521 | makefile | makefile |
524 | vbscript | vbscript |
527 New languages can be added to source highlight and made available for
528 export by adding entries to the list stored in the
529 =org-groff-source-highlight-langs= variable. The format for each entry
530 consists on a symbol and a string. The symbol corresponds to the
531 begin_src tag and the string to the corresponding language entry
532 available in source highlight. An example of an entry is:
533 #+begin_src emacs-lisp
537 If a language is not defined, then the Groff export process will default
538 to write the code in Constant Width font.
541 Groff commands can be exported literally by surrounding the text on a
542 pair of #+BEGIN_GROFF/#+END_GROFF lines. These are a couple of
543 commands that can be useful during export to control the output.
551 Page break. Skips to a new page.
565 EQN escape. This is used to add equations in your exported document. The
566 Groff export uses the =eqn= processor to add them in your output. EQN
567 statements must be placed between .EQ and .EN.
578 Used with the dummy document class, it can be used to add an abstract block to
579 any of the memorandum type. The internal type is presented for
580 reference. Absract text must be placed betwen .AS and .AE.
583 The following limitations are known at the time of release. They will be
584 looked at and addressed in subsequent releases if they are technically
587 - Images :: Image support is limited to PIC, PS and EPS.
588 - Links :: There is no support for document linking or grefer. Most
589 links will be just written. The only exception are for
590 supported image and files with a .groff extension. The
591 former will be embedded in the exported file, the later
592 will be included through the use of a .so command.
593 - Abstracts :: Abstract support is only available through the use of
595 - Equations :: Equations support is only available through the use of
597 - Alternate Macro Set :: There are plans to create export for MOM
598 macros. No plans for the MS set unless there is enough
599 interest. The reason is that MOM seems to be the up and coming
600 substitute for MM and its similarities with LaT_eX makes it a
601 very attractive alternative to MM. It also allows the use of the
602 macros available in the WWW set.
603 - Gnuplot :: Gnuplot plots can be included if the following conditions
605 1. Output type must be set to =gpic= (GnuPIC). Using Lat_eX EPS
606 will result in an incomplete graph.
607 2. For images generated directly from an Org mode table will have
608 to be included afterwards after its generation. For example:
610 #+PLOT: title "X" ... set:"term gpic" "set:output 'table.pic'"
615 3. While using Org Babel, gpic output specification needs to be
616 stated. Otherwise, the image will not be included on export.
618 #+begin_src gnuplot :file salida.pic
623 - PlantUML :: Plantuml is supported but the output type must be
624 EPS. This is done by using /.eps/ as the file suffix.
626 #+begin_src plantuml :file x.eps
630 - Other Babel Graphics :: Other babel graphics should be supported if
631 either PS, EPS or GnuPIC are used as their output format.