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