Exporting
At some point you might want to print your notes, publish them on the web, or share them with people not using Org. Org can convert and export documents to a variety of other formats while retaining as much structure (see Document Structure) and markup (see Markup for Rich Contents) as possible.
The libraries responsible for translating Org files to other formats are called backends. Org ships with support for the following backends:
- ascii (ASCII format)
- beamer (LaTeX Beamer format)
- html (HTML format)
- icalendar (iCalendar format)
- latex (LaTeX format)
- md (Markdown format)
- odt (OpenDocument Text format)
- org (Org format)
- texinfo (Texinfo format)
- man (Man page format)
Users can install libraries for additional formats from the Emacs
packaging system. For easy discovery, these packages have a common
naming scheme: ox-NAME, where NAME is a format. For
example, ox-koma-letter for koma-letter backend. More libraries
can be found in the org-contrib repository (see Installation).
Org only loads backends for the following formats by default: ASCII,
HTML, iCalendar, LaTeX, and ODT. Additional backends can be loaded
in either of two ways: by configuring the org-export-backends
variable, or by requiring libraries in the Emacs init file. For
example, to load the Markdown backend, add this to your Emacs config:
(require 'ox-md)The Export Dispatcher
The export dispatcher is the main interface for Org's exports. A hierarchical menu presents the currently configured export formats. Options are shown as easy toggle switches on the same screen.
Org also has a minimal prompt interface for the export dispatcher.
When the variable org-export-dispatch-use-expert-ui is set to
a non-nil value, Org prompts in the minibuffer. To switch back to
the hierarchical menu, press ?.
-
C-c C-e(org-export-dispatch)
Invokes the export dispatcher interface. The options show default
settings. The C-u prefix argument preserves options from
the previous export, including any subtree selections.
Org exports the entire buffer by default. If the Org buffer has an active region, then Org exports just that region.
Within the dispatcher interface, the following key combinations can further alter what is exported, and how.
-
C-a
Toggle asynchronous export. Asynchronous export uses an external Emacs process with a specially configured initialization file to complete the exporting process in the background, without tying-up Emacs. This is particularly useful when exporting long documents.
Output from an asynchronous export is saved on the export stack.
To view this stack, call the export dispatcher with a double
C-u prefix argument. If already in the export dispatcher
menu, & displays the stack.
You can make asynchronous export the default by setting
org-export-in-background.
You can set the initialization file used by the background process
by setting org-export-async-init-file.
-
C-b
Toggle body-only export. Useful for excluding headers and footers
in the export. Affects only those backend formats that have
sections like <head>...</head> in HTML.
To make body-only export the default, customize the variable
org-export-body-only.
-
C-f
Toggle force-publishing export. Publish functions normally only publish changed files (see Triggering Publication). Forced publishing causes files to be published even if their timestamps do not indicate the file has been changed.
To make forced publishing the default, customize the variable
org-export-force-publishing. (This is similar to
org-publish-use-timestamps-flag, but only affects the export
dispatcher.)
-
C-s
Toggle subtree export. When turned on, Org exports only the subtree starting from point position at the time the export dispatcher was invoked. Org uses the top heading of this subtree as the document's title. If point is not on a heading, Org uses the nearest enclosing header. If point is in the document preamble, Org signals an error and aborts export.
To make subtree export the default, customize the variable
org-export-initial-scope.
-
C-v
Toggle visible-only export. This is useful for exporting only certain parts of an Org document by adjusting the visibility of particular headings. See also Sparse Trees.
To make visible-only export the default, customize the variable
org-export-visible-only.
Export Settings
Export options can be set: globally with variables; for an individual
file by making variables buffer-local with in-buffer settings (see
Summary of In-Buffer Settings); by setting individual keywords or
specifying them in compact form with the OPTIONS keyword; or for
a tree by setting properties (see Properties and Columns). Options
set at a specific level override options set at a more general level.
In-buffer settings may appear anywhere in the file, either directly or
indirectly through a file included using #+SETUPFILE: filename or
URL syntax. Option keyword sets tailored to a particular backend
can be inserted from the export dispatcher (see The Export Dispatcher) using the Insert template command by pressing
#. To insert keywords individually, a good way to make
sure the keyword is correct is to type #+ and then to use
M-TAB 6 for completion.
The export keywords available for every backend, and their equivalent global variables, include:
-
AUTHOR
The document author (user-full-name).
-
CREATOR
Entity responsible for output generation
(org-export-creator-string).
-
DATE
A date or a timestamp(note: The variable
org-export-date-timestamp-format defines how this timestamp is
exported.).
-
EMAIL
The email address (user-mail-address).
-
LANGUAGE
Language to use for translating certain strings
(org-export-default-language). With #+LANGUAGE: fr, for
example, Org translates Table of contents to the French =Table des
matières= 42.
-
SELECT_TAGS
List of tags that will, if present, be selected for export. The
default value is org-export-select-tags ("export"). When a tree
is tagged with export, Org selects that tree and its subtrees for
export, ignoring all the other sections that do not possess the
export tag.
When selectively exporting files with export tags set, Org does
not export any text that appears before the first headline.
Note that a file without the export tags will export all its
sections.
To select non-default tags for export, customize
org-export-select-tags (globally) or add #+SELECT_TAGS: tag1
tag2 to the document.
-
EXCLUDE_TAGS
List of tags that will be excluded from export. The default value is
org-export-exclude-tags ("noexport"). When a tree is tagged
with noexport, Org excludes that tree and its subtrees from
export.
Entries tagged with noexport are unconditionally excluded from the
export, even if they have an export tag. Even if a subtree is not
exported, Org executes any code blocks contained there.
To select non-default tags for the exclusion, customize
org-export-exclude-tags (globally) or add #+EXCLUDE_TAGS: tag1
tag2 to the document.
-
TITLE
Org displays this title. For long titles, use multiple #+TITLE
lines.
-
EXPORT_FILE_NAME
The name of the output file to be generated. Otherwise, Org generates the file name based on the buffer name and the extension based on the backend format.
The OPTIONS keyword is a compact form. To configure multiple
options, use several OPTIONS lines. OPTIONS recognizes the
following arguments.
-
'
Toggle smart quotes (org-export-with-smart-quotes). Depending on
the language used, when activated, Org treats pairs of double quotes
as primary quotes, pairs of single quotes as secondary quotes, and
single quote marks as apostrophes.
-
*
Toggle emphasized text (org-export-with-emphasize).
-
-
Toggle conversion of special strings
(org-export-with-special-strings).
-
:
Toggle fixed-width sections (org-export-with-fixed-width).
-
<
Toggle inclusion of time/date active/inactive stamps
(org-export-with-timestamps).
-
\n
Toggles whether to preserve line breaks
(org-export-preserve-breaks).
-
^
Toggle TeX-like syntax for sub- and superscripts. If you write
^:{}, a_{b} is interpreted, but the simple a_b is left as it
is (org-export-with-sub-superscripts).
-
arch
Configure how archived trees are exported. When set to headline,
the export process skips the contents and processes only the
headlines (org-export-with-archived-trees).
-
author
Toggle inclusion of author name into exported file
(org-export-with-author).
-
expand-links
Toggle expansion of environment variables in file paths
(org-export-expand-links).
-
broken-links
Toggles if Org should continue exporting upon finding a broken
internal link. When set to mark, Org clearly marks the problem
link in the output (org-export-with-broken-links).
-
c
Toggle inclusion of CLOCK keywords (org-export-with-clocks).
-
creator
Toggle inclusion of creator information in the exported file
(org-export-with-creator).
-
d
Toggles inclusion of drawers, or list of drawers to include, or list
of drawers to exclude (org-export-with-drawers).
-
date
Toggle inclusion of a date into exported file
(org-export-with-date).
-
e
Toggle inclusion of entities (org-export-with-entities).
-
email
Toggle inclusion of the author's e-mail into exported file
(org-export-with-email).
-
f
Toggle the inclusion of footnotes (org-export-with-footnotes).
-
H
Set the last headline level for export as a headline
(org-export-headline-levels). For descendants of that level,
headlines are treated differently. In most backends, they become
list items.
-
inline
Toggle inclusion of inlinetasks (org-export-with-inlinetasks).
-
num
Toggle section-numbers (org-export-with-section-numbers). When
set to number N, Org numbers only those headlines at level N or
above. Set UNNUMBERED property to non-nil to disable numbering
of heading and subheadings entirely. Moreover, when the value is
notoc the headline, and all its children, do not appear in the
table of contents either (see Table of Contents).
-
p
Toggle export of planning information (org-export-with-planning).
"Planning information" comes from lines located right after the
headline and contain any combination of these cookies: SCHEDULED,
DEADLINE, or CLOSED.
-
pri
Toggle inclusion of priority cookies
(org-export-with-priority).
-
prop
Toggle inclusion of property drawers, or list the properties to
include (org-export-with-properties).
-
stat
Toggle inclusion of statistics cookies
(org-export-with-statistics-cookies).
-
tags
Toggle inclusion of tags, may also be not-in-toc
(org-export-with-tags).
-
tasks
Toggle inclusion of tasks (TODO items); or nil to remove all
tasks; or todo to remove done tasks; or list the keywords to keep
(org-export-with-tasks).
-
tex
nil does not export; t exports; verbatim keeps everything in
verbatim (org-export-with-latex).
-
timestamp
Toggle inclusion of the creation time in the exported file
(org-export-timestamp-file).
-
title
Toggle inclusion of title (org-export-with-title).
-
toc
Toggle inclusion of the table of contents, or set the level limit
(org-export-with-toc).
-
todo
Toggle inclusion of TODO keywords into exported text
(org-export-with-todo-keywords).
-
|
Toggle inclusion of tables (org-export-with-tables).
When exporting subtrees, special node properties can override the
above keywords. These properties have an EXPORT_ prefix. For
example, DATE becomes, EXPORT_DATE when used for a specific
subtree. Except for SETUPFILE, all other keywords listed above
have an EXPORT_ equivalent.
If org-export-allow-bind-keywords is non-nil, Emacs variables can
become buffer-local during export by using the BIND keyword. Its
syntax is #+BIND: variable value. This is particularly useful for
in-buffer settings that cannot be changed using keywords.
Table of Contents
The table of contents includes all headlines in the document. Its
depth is therefore the same as the headline levels in the file. If
you need to use a different depth, or turn it off entirely, set the
org-export-with-toc variable accordingly. You can achieve the same
on a per-file basis, using the following toc item in OPTIONS
keyword:
#+OPTIONS: toc:2 (only include two levels in TOC) #+OPTIONS: toc:nil (no default TOC at all)
Org includes both numbered and unnumbered headlines in the table of
contents43. If you need to exclude an unnumbered headline,
along with all its children, set the UNNUMBERED property to notoc
value.
* Subtree not numbered, not in table of contents either :PROPERTIES: :UNNUMBERED: notoc :END:
Org normally inserts the table of contents in front of the exported
document. To move the table of contents to a different location,
first turn off the default with org-export-with-toc variable or with
#+OPTIONS: toc:nil. Then insert #+TOC: headlines N at the desired
location(s).
#+OPTIONS: toc:nil ... #+TOC: headlines 2
To adjust the table of contents depth for a specific section of the
Org document, append an additional local parameter. This parameter
becomes a relative depth for the current level. The following example
inserts a local table of contents, with direct children only.
* Section #+TOC: headlines 1 local
Note that for this feature to work properly in LaTeX export, the Org
file requires the inclusion of the titletoc package. Because of
compatibility issues, titletoc has to be loaded before hyperref.
Customize the org-latex-default-packages-alist variable.
The following example inserts a table of contents that links to the children of the specified target.
* Target :PROPERTIES: :CUSTOM_ID: TargetSection :END: ** Heading A ** Heading B * Another section #+TOC: headlines 1 :target #TargetSection
The :target attribute is supported in HTML, Markdown, ODT, and ASCII export.
Use the TOC keyword to generate list of tables—respectively, all
listings—with captions.
#+TOC: listings #+TOC: tables
Normally Org uses the headline for its entry in the table of contents.
But with ALT_TITLE property, a different entry can be specified for
the table of contents.
Include Files
During export, you can include the content of another file. For
example, to include your .emacs file, you could use:
#+INCLUDE: "~/.emacs" src emacs-lisp
There are three positional arguments after the include keyword, they are:
- The file name, this is the sole mandatory argument. Org neither checks for correctness nor validates the content in any way.
- The block name to wrap the file content in. When this is
example,export, orsrcthe content is escaped byorg-escape-code-in-string. Arbitrary block names may be given, however block names starting with:must be quoted, i.e.":name". - The source code language to use for formatting the contents. This is relevant
to both
exportandsrcblock types.
If an included file is not specified as having any markup language,
Org assumes it to be in Org format and proceeds as usual with a few
exceptions. Org makes the footnote labels (see Creating Footnotes)
in the included file local to that file. The contents of the included
file belong to the same structure—headline, item—containing the
INCLUDE keyword. In particular, headlines within the file become
children of the current section. That behavior can be changed by
providing an additional keyword parameter, :minlevel. It shifts the
headlines in the included file to become the lowest level. For
example, this syntax makes the included file a sibling of the current
top-level headline:
#+INCLUDE: "~/my-book/chapter2.org" :minlevel 1
Inclusion of only portions of files are specified using ranges
parameter with :lines keyword. The line at the upper end of the
range will not be included. The start and/or the end of the range may
be omitted to use the obvious defaults.
#+INCLUDE: "~/.emacs" :lines "5-10" |
Include lines 5 to 10, 10 excluded |
#+INCLUDE: "~/.emacs" :lines "-10" |
Include lines 1 to 10, 10 excluded |
#+INCLUDE: "~/.emacs" :lines "10-" |
Include lines from 10 to EOF |
Inclusions may specify a file-link to extract an object matched by
org-link-search 44 (see Search Options in File Links). The
ranges for :lines keyword are relative to the requested element.
Therefore,
#+INCLUDE: "./paper.org::*conclusion" :lines "1-20"
includes the first 20 lines of the headline named conclusion.
To extract only the contents of the matched object, set
:only-contents property to non-nil. This omits any planning lines
or property drawers. For example, to include the body of the heading
with the custom ID theory, you can use
#+INCLUDE: "./paper.org::#theory" :only-contents t
The following command allows navigating to the included document:
-
C-c '(org-edit-special)
Visit the included file at point.
Macro Replacement
Macros replace text snippets during export(note: The macro replacement
can be disabled by setting org-export-replace-macros to nil (default
is t).). Macros are defined globally in org-export-global-macros,
or document-wise with the following syntax:
#+MACRO: name replacement text; $1, $2 are arguments
which can be referenced using arg1, arg2 45. For
example
#+MACRO: poem Rose is $1, violet's $2. Life's ordered: Org assists you. red,blue
becomes
Rose is red, violet's blue. Life's ordered: Org assists you.
As a special case, Org parses any replacement text starting with
(eval as an Emacs Lisp expression and evaluates it accordingly.
Within such templates, arguments become strings. Thus, the following
macro
#+MACRO: gnustamp (eval (concat "GNU/" (capitalize $1)))
turns linux into GNU/Linux during export.
Org recognizes macro references in following Org markup areas:
paragraphs, headlines, verse blocks, tables cells and lists. Org also
recognizes macro references in keywords, such as CAPTION, TITLE,
AUTHOR, DATE, and for some backend specific export options.
Org comes with following pre-defined macros:
-
=NAME=;=; =; ==
The keyword macro collects all values from NAME
keywords throughout the buffer, separated with white space.
title, author and email macros are shortcuts for,
respectively, =TITLE=, =AUTHOR= and
=EMAIL=.
-
=; =FORMAT
This macro refers to the DATE keyword. FORMAT is an
optional argument to the date macro that is used only if DATE is
a single timestamp. FORMAT should be a format string
understood by format-time-string.
-
FORMAT;FORMAT, VC
These macros refer to the document's date and time of export and
date and time of modification. FORMAT is a string
understood by format-time-string. If the second argument to the
modification-time macro is non-nil, Org uses vc.el to retrieve
the document's modification time from the version control system.
Otherwise, Org reads the file attributes.
- ==
This macro refers to the filename of the exported file.
-
PROPERTY-NAME;PROPERTY-NAME, SEARCH OPTION
This macro returns the value of property PROPERTY-NAME in the current entry. If SEARCH-OPTION (see Search Options in File Links) refers to a remote entry, use it instead.
-
=; =NAME;NAME, ACTION
This macro implements custom counters by returning the number of
times the macro has been expanded so far while exporting the buffer.
You can create more than one counter using different NAME
values. If ACTION is -, previous value of the counter
is held, i.e., the specified counter is not incremented. If the
value is a number, the specified counter is set to that value. If
it is any other non-empty string, the specified counter is reset
to 1. You may leave NAME empty to reset the default
counter.
Moreover, inline source blocks (see Structure of Code Blocks) use the
special results macro to mark their output. As such, you are
advised against re-defining it, unless you know what you are doing.
The surrounding brackets can be made invisible by setting
org-hide-macro-markers to a non-nil value.
Org expands macros at the very beginning of the export process.
Comment Lines
Lines starting with zero or more whitespace characters followed by one
# and a whitespace are treated as comments and, as such, are not
exported.
Likewise, comment blocks #+BEGIN_COMMENT … #+END_COMMENT are not
exported. (note: Just like in Literal Examples, you need to escape
leading * with , to avoid interpreting them as headings.)
Finally, a COMMENT keyword at the beginning of an entry, but after
any other keyword or priority cookie, comments out the entire subtree.
In this case, the subtree is not exported and no code block within it
is executed or tangled(note: For less restrictive export limitations,
consider using a select tag (see Export Settings) instead.). The
command below helps to change the comment status of a headline.
-
C-c ;(org-toggle-comment)
Toggle the COMMENT keyword at the beginning of an entry.
ASCII/Latin-1/UTF-8 export
ASCII export produces an output file containing only plain ASCII characters. This is the simplest and most direct text output. It does not contain any Org markup. Latin-1 and UTF-8 export use additional characters and symbols available in these encoding standards. All three of these export formats offer the most basic of text output for maximum portability.
On export, Org fills and justifies text according to the text width
set in org-ascii-text-width.
Org exports links using a footnote-like style where the descriptive
part is in the text and the link is in a note before the next heading.
See the variable org-ascii-links-to-notes for details.
ASCII export commands
-
C-c C-e t a(org-ascii-export-to-ascii),C-c C-e t l,C-c C-e t u
Export as an ASCII file with a .txt extension. For myfile.org,
Org exports to myfile.txt, overwriting without warning. For
myfile.txt, Org exports to myfile.txt.txt in order to prevent
data loss.
-
C-c C-e t A(org-ascii-export-to-ascii),C-c C-e t L,C-c C-e t U
Export to a temporary buffer. Does not create a file.
ASCII specific export settings
The ASCII export backend has one extra keyword for customizing ASCII output. Setting this keyword works similar to the general options (see Export Settings).
-
SUBTITLE
The document subtitle. For long subtitles, use multiple
#+SUBTITLE lines in the Org file. Org prints them on one
continuous line, wrapping into multiple lines if necessary.
Header and sectioning structure
Org converts the first three outline levels into headlines for ASCII export. The remaining levels are turned into lists. To change this cut-off point where levels become lists, see Export Settings.
Quoting ASCII text
To insert text within the Org file by the ASCII backend, use one the following constructs, inline, keyword, or export block:
Inline text @@ascii:and additional text@@ within a paragraph. #+ASCII: Some text #+BEGIN_EXPORT ascii Org exports text in this block only when using ASCII backend. #+END_EXPORT
ASCII specific attributes
ASCII backend recognizes only one attribute, :width, which
specifies the width of a horizontal rule in number of characters. The
keyword and syntax for specifying widths is:
#+ATTR_ASCII: :width 10 -----
ASCII special blocks
Besides #+BEGIN_CENTER blocks (see Paragraphs), ASCII backend has
these two left and right justification blocks:
#+BEGIN_JUSTIFYLEFT It's just a jump to the left... #+END_JUSTIFYLEFT #+BEGIN_JUSTIFYRIGHT ...and then a step to the right. #+END_JUSTIFYRIGHT
Beamer Export
Org uses Beamer export to convert an Org file tree structure into high-quality interactive slides for presentations. Beamer is a LaTeX document class for creating presentations in PDF, HTML, and other popular display formats.
We strongly recommend familiarizing yourself with Beamer terminology before reading the rest of this chapter. See <https://en.wikipedia.org/wiki/Beamer_(LaTeX)> and references therein.
Beamer export commands
-
C-c C-e l b(org-beamer-export-to-latex)
Export as LaTeX file with a .tex extension. For myfile.org, Org
exports to myfile.tex, overwriting without warning.
-
C-c C-e l B(org-beamer-export-as-latex)
Export to a temporary buffer. Does not create a file.
-
C-c C-e l P(org-beamer-export-to-pdf)
Export as LaTeX file and then convert it to PDF format.
-
C-c C-e l O
Export as LaTeX file, convert it to PDF format, and then open the PDF file.
Beamer specific export settings
Beamer export backend has several additional keywords for customizing Beamer output. These keywords work similar to the general options settings (see Export Settings).
-
BEAMER_THEME
The Beamer layout theme (org-beamer-theme). Use square brackets
for options. For example:
#+BEAMER_THEME: Rochester [height=20pt]
-
BEAMER_FONT_THEME
The Beamer font theme.
-
BEAMER_INNER_THEME
The Beamer inner theme.
-
BEAMER_OUTER_THEME
The Beamer outer theme.
-
BEAMER_HEADER
Arbitrary lines inserted in the preamble, just before the hyperref
settings.
-
DESCRIPTION
The document description. For long descriptions, use multiple
DESCRIPTION keywords. By default, hyperref inserts
DESCRIPTION as metadata. Use org-latex-hyperref-template to
configure document metadata. Use org-latex-title-command to
configure typesetting of description as part of front matter.
-
KEYWORDS
The keywords for defining the contents of the document. Use
multiple KEYWORDS lines if necessary. By default, hyperref
inserts KEYWORDS as metadata. Use org-latex-hyperref-template
to configure document metadata. Use org-latex-title-command to
configure typesetting of keywords as part of front matter.
-
SUBTITLE
Document's subtitle. For typesetting, use
org-beamer-subtitle-format string. Use
org-latex-hyperref-template to configure document metadata. Use
org-latex-title-command to configure typesetting of subtitle as
part of front matter.
Frames and Blocks in Beamer
Org transforms heading levels into Beamer's sectioning elements, frames and blocks. Any Org tree with a not-too-deep-level nesting should in principle be exportable as a Beamer presentation.
Org headlines become Beamer frames when the heading level in Org is
equal to org-beamer-frame-level or H value in a OPTIONS line
(see Export Settings).
Org overrides headlines to frames conversion for the current tree of
an Org file if it encounters the BEAMER_ENV property set to
frame or fullframe. Org ignores whatever
org-beamer-frame-level happens to be for that headline level in
the Org tree. In Beamer terminology, a full frame is a frame
without its title.
- Org exports a Beamer frame's objects as block environments. Org can
enforce wrapping in special block types when
BEAMER_ENVproperty
is set46. For valid values see
org-beamer-environments-default. To add more values, see
org-beamer-environments-extra.
If BEAMER_ENV is set to appendix, Org exports the entry as an
appendix. When set to note, Org exports the entry as a note
within the frame or between frames, depending on the entry's heading
level. When set to noteNH, Org exports the entry as a note
without its title. When set to againframe, Org exports the entry
with \againframe command, which makes setting the BEAMER_REF
property mandatory because \againframe needs frame to resume.
When ignoreheading is set, Org export ignores the entry's headline
but not its content. This is useful for inserting content between
frames. It is also useful for properly closing a column
environment.
If BEAMER_SUBTITLE is set, Org exports its value as the subtitle
for the headline's frame. This property has no effect on headlines
which are not exported as frames.
When BEAMER_ACT is set for a headline, Org export translates that
headline as an overlay or action specification. When enclosed in
square brackets, Org export makes the overlay specification
a default. Use BEAMER_OPT to set any options applicable to the
current Beamer frame or block. The Beamer export backend wraps
with appropriate angular or square brackets. It also adds the
fragile option for any code that may require a verbatim block.
To create a column on the Beamer slide, use the BEAMER_COL
property for its headline in the Org file. Set the value of
BEAMER_COL to a decimal number representing the fraction of the
total text width. Beamer export uses this value to set the column's
width and fills the column with the contents of the Org entry. If
the Org entry has no specific environment defined, Beamer export
ignores the heading. If the Org entry has a defined environment,
Beamer export uses the heading as title. Behind the scenes, Beamer
export automatically handles LaTeX column separations for contiguous
headlines. To manually adjust them for any unique configurations
needs, use the BEAMER_ENV property.
Beamer specific syntax
Since Org's Beamer export backend is an extension of the LaTeX
backend, it recognizes other LaTeX specific syntax—for example,
#+LATEX: or #+ATTR_LATEX:. See LaTeX Export, for details.
Beamer export wraps the table of contents generated with toc:t
OPTION keyword in a frame environment. Beamer export does not
wrap the table of contents generated with TOC keyword (see Table of Contents). Use square brackets for specifying options.
#+TOC: headlines [currentsection]
Insert Beamer-specific code using the following constructs:
#+BEAMER: \pause #+BEGIN_EXPORT beamer Only Beamer export backend exports this. #+END_EXPORT Text @@beamer:some code@@ within a paragraph.
Inline constructs, such as the last one above, are useful for adding
overlay specifications to objects with bold, item, link,
radio-target and target types. Enclose the value in angular
brackets and place the specification at the beginning of the object as
shown in this example:
A *@@beamer:<2->@@useful* feature
Beamer export recognizes the ATTR_BEAMER keyword with the following
attributes from Beamer configurations: :environment for changing
local Beamer environment, :overlay for specifying Beamer overlays in
angular or square brackets, and :options for inserting optional
arguments.
#+ATTR_BEAMER: :environment nonindentlist - item 1, not indented - item 2, not indented - item 3, not indented
#+ATTR_BEAMER: :overlay <+-> - item 1 - item 2
#+ATTR_BEAMER: :options [Lagrange] Let $G$ be a finite group, and let $H$ be a subgroup of $G$. Then the order of $H$ divides the order of $G$.
Editing support
Org Beamer mode is a special minor mode for faster editing of Beamer documents.
#+STARTUP: beamer
-
C-c C-b(org-beamer-select-environment)
Org Beamer mode provides this key for quicker selections in Beamer
normal environments, and for selecting the BEAMER_COL property.
A Beamer example
Here is an example of an Org document ready for Beamer export.
#+TITLE: Example Presentation
#+AUTHOR: Carsten Dominik
#+OPTIONS: H:2 toc:t num:t
#+LATEX_CLASS: beamer
#+STARTUP: beamer
#+LATEX_CLASS_OPTIONS: [presentation]
#+BEAMER_THEME: Madrid
#+COLUMNS: %45ITEM %10BEAMER_ENV(Env) %10BEAMER_ACT(Act) %4BEAMER_COL(Col)
* This is the first structural section
** Frame 1
*** Thanks to Eric Fraga :B_block:
:PROPERTIES:
:BEAMER_COL: 0.48
:BEAMER_ENV: block
:END:
for the first viable Beamer setup in Org
*** Thanks to everyone else :B_block:
:PROPERTIES:
:BEAMER_COL: 0.48
:BEAMER_ACT: <2->
:BEAMER_ENV: block
:END:
for contributing to the discussion
**** This will be formatted as a beamer note :B_note:
:PROPERTIES:
:BEAMER_env: note
:END:
** Frame 2 (where we will not use columns)
*** Request
Please test this stuff!
HTML Export
Org mode contains an HTML exporter with extensive HTML formatting compatible with XHTML 1.0 strict standard.
HTML export commands
-
C-c C-e h h(org-html-export-to-html)
Export as HTML file with a .html extension. For myfile.org, Org
exports to myfile.html, overwriting without warning. C-c C-e h o exports to HTML and opens it in a web browser.
-
C-c C-e h H(org-html-export-as-html)
Exports to a temporary buffer. Does not create a file.
HTML specific export settings
HTML export has a number of keywords, similar to the general options settings described in Export Settings.
-
DESCRIPTION
This is the document's description, which the HTML exporter inserts
it as an HTML meta tag in the HTML file. For long descriptions, use
multiple DESCRIPTION lines. The exporter takes care of wrapping
the lines properly.
The exporter includes a number of other meta tags, which can be customized
by modifying org-html-meta-tags.
-
HTML_DOCTYPE
Specify the document type, for example: HTML5 (org-html-doctype).
-
HTML_CONTAINER
Specify the HTML container, such as div, for wrapping sections and
elements (org-html-container-element).
-
HTML_LINK_HOME
The URL for home link (org-html-link-home).
-
HTML_LINK_UP
The URL for the up link of exported HTML pages (org-html-link-up).
-
HTML_MATHJAX
Options for MathJax (org-html-mathjax-options). MathJax is used
to typeset LaTeX math in HTML documents. See Math formatting in HTML export, for an example.
-
HTML_HEAD
Arbitrary lines for appending to the HTML document's head
(org-html-head).
-
HTML_HEAD_EXTRA
More arbitrary lines for appending to the HTML document's head
(org-html-head-extra).
-
KEYWORDS
Keywords to describe the document's content. HTML exporter inserts
these keywords as HTML meta tags. For long keywords, use multiple
KEYWORDS lines.
-
LATEX_HEADER
Arbitrary lines for appending to the preamble; HTML exporter appends when transcoding LaTeX fragments to images (see Math formatting in HTML export).
-
SUBTITLE
The document's subtitle. HTML exporter formats subtitle if document
type is HTML5 and the CSS has a subtitle class.
Some of these keywords are explained in more detail in the following sections of the manual.
HTML doctypes
Org can export to various (X)HTML flavors.
Set the org-html-doctype variable for different (X)HTML variants.
Depending on the variant, the HTML exporter adjusts the syntax of HTML
conversion accordingly. Org includes the following ready-made
variants:
"html4-strict""html4-transitional""html4-frameset""xhtml-strict""xhtml-transitional""xhtml-frameset""xhtml-11""html5""xhtml5"
See the variable org-html-doctype-alist for details. The default is
"xhtml-strict".
Org's HTML exporter does not by default enable new block elements
introduced with the HTML5 standard. To enable them, set
org-html-html5-fancy to non-nil. Or use an OPTIONS line in the
file to set html5-fancy.
HTML5 documents can have arbitrary #+BEGIN … #+END blocks.
For example:
#+BEGIN_aside Lorem ipsum #+END_aside
exports to:
<aside>
<p>Lorem ipsum</p>
</aside>while this:
#+ATTR_HTML: :controls controls :width 350 #+BEGIN_video #+HTML: <source src="movie.mp4" type="video/mp4"> #+HTML: <source src="movie.ogg" type="video/ogg"> Your browser does not support the video tag. #+END_video
exports to:
<video controls="controls" width="350">
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
<p>Your browser does not support the video tag.</p>
</video>When special blocks do not have a corresponding HTML5 element, the
HTML exporter reverts to standard translation (see
org-html-html5-elements). For example, #+BEGIN_lederhosen exports
to <div class="lederhosen">.
Special blocks cannot have headlines. For the HTML exporter to wrap
the headline and its contents in <section> or <article> tags, set
the HTML_CONTAINER property for the headline.
HTML preamble and postamble
The HTML exporter has delineations for preamble and postamble. The
default value for org-html-preamble is t, which makes the HTML
exporter insert the preamble. See the variable
org-html-preamble-format for the format string.
Set org-html-preamble to a string to override the default format
string. If set to a function, the HTML exporter expects the function
to return a string upon execution. The HTML exporter inserts this
string in the preamble. The HTML exporter does not insert a preamble
if org-html-preamble is set nil.
The above also applies to org-html-postamble and
org-html-postamble-format. In addition, org-html-postamble can be
set to auto (its default value), which makes the HTML exporter build
a postamble from looking up author's name, email address, creator's
name, and date.
Exporting to minimal HTML
If you want to output a minimal HTML file, with no CSS, no JavaScript, no preamble or postamble, here are the variable you would need to set:
(setq org-html-head ""
org-html-head-extra ""
org-html-head-include-default-style nil
org-html-head-include-scripts nil
org-html-preamble nil
org-html-postamble nil
org-html-use-infojs nil)Headlines in HTML export
Headlines are exported to <h1>, <h2>, etc. Each headline gets the
id attribute from CUSTOM_ID property, or a unique generated value,
see Internal Links.
Headlines can contain a link to themselves. To enable it, you can:
- Set the variable
org-html-self-link-headlinesto a non-nilvalue -
In an Org file, use
html-self-link-headlinesoption#+OPTIONS: html-self-link-headlines:t
When enabled, the text of the headlines is wrapped in <a> tags.
These tags have a href attribute making the headlines link to
themselves.
Links in HTML export
The HTML export backend transforms Org's internal links (see Internal Links) to equivalent HTML links in the output. The backend similarly handles Org's automatic links created by radio targets (see Radio Targets) similarly. For Org links to external files, the backend transforms the links to relative paths.
For Org links to other .org files, the backend automatically
changes the file extension to .html and makes file paths relative.
If the .org files have an equivalent .html version at the same
location, then the converted links should work without any further
manual intervention. However, to disable this automatic path
translation, set org-html-link-org-files-as-html to nil. When
disabled, the HTML export backend substitutes the ID-based links in
the HTML output. For more about linking files when publishing to
a directory, see Publishing links.
Org files can also have special directives to the HTML export
backend. For example, by using #+ATTR_HTML lines to specify new
format attributes to <a> or <img> tags. This example shows
changing the link's title and style:
#+ATTR_HTML: :title The Org mode website :style color:red; [[https://orgmode.org]]
Tables in HTML export
The HTML export backend uses org-html-table-default-attributes when
exporting Org tables to HTML. By default, the exporter does not draw
frames and cell borders. To change for this for a table, use the
following lines before the table in the Org file:
#+CAPTION: This is a table with lines around and between cells #+ATTR_HTML: :border 2 :rules all :frame border
Note that table attributes are deprecated in HTML5 in favor of CSS.
When the doctype is set to HTML5 (see HTML doctypes), Org ignores
org-html-table-default-attributes. #+ATTR_HTML: is still
respected, but not recommended.
The HTML export backend preserves column groupings in Org tables (see Column Groups) when exporting to HTML.
Additional options for customizing tables for HTML export.
-
org-html-table-align-individual-fields
Non-nil attaches style attributes for alignment to each table
field.
-
org-html-table-caption-above
Non-nil places caption string at the beginning of the table.
-
org-html-table-data-tags
Opening and ending tags for table data fields.
-
org-html-table-default-attributes
Default attributes and values for table tags.
-
org-html-table-header-tags
Opening and ending tags for table's header fields.
-
org-html-table-row-tags
Opening and ending tags for table rows.
-
org-html-table-use-header-tags-for-first-column
Non-nil formats column one in tables with header tags.
Images in HTML export
The HTML export backend has features to convert Org image links to HTML inline images and HTML clickable image links.
When the link in the Org file has no description, the HTML export
backend by default in-lines that image. For example:
[[file:myimg.jpg]] is in-lined, while [[file:myimg.jpg][the image]] links to the text,
the image. For more details, see the variable
org-html-inline-images.
On the other hand, if the description part of the Org link is itself
another link, such as file: or https: URL pointing to an image
(the exact rule is defined in org-html-inline-image-rules), the HTML
export backend in-lines this image and links to the main image. This
Org syntax enables the backend to link low-resolution thumbnail to the
high-resolution version of the image, as shown in this example:
[[file:highres.jpg][file:thumb.jpg]]
To change attributes of in-lined images, use #+ATTR_HTML lines in
the Org file. This example shows realignment to right, and adds alt
and title attributes in support of text viewers and modern web
accessibility standards.
#+CAPTION: A black cat stalking a spider #+ATTR_HTML: :alt cat/spider image :title Action! :align right [[#_002e_002fimg_002fa_002ejpg][./img/a.jpg]]
The HTML export backend copies the http links from the Org file
as-is.
Math formatting in HTML export
LaTeX math snippets (see LaTeX fragments) can be displayed in two different ways on HTML pages. The default is to use the MathJax, which should work out of the box
with Org(note: By default, Org loads MathJax from
jsDelivr, as recommended in
Getting Started
with MathJax Components.)47. Some MathJax options can be
configured via org-html-mathjax-options, or in the buffer. For
example, with the following settings,
#+HTML_MATHJAX: align: left indent: 5em tagside: left
equation labels are displayed on the left margin and equations are five ems from the left margin.
To use a local copy of MathJax, use path option:
#+HTML_MATHJAX: path:the/path/to/mathjax.js
See the docstring of org-html-mathjax-options for all supported
variables. The MathJax template can be configured via
org-html-mathjax-template.
If you prefer, you can also request that LaTeX fragments are processed into small images that will be inserted into the browser page. Before the availability of MathJax, this was the default method for Org files. This method requires that the dvipng program, dvisvgm or ImageMagick suite is available on your system. You can still get this processing with
#+OPTIONS: tex:dvipng
#+OPTIONS: tex:dvisvgm
or
#+OPTIONS: tex:imagemagick
Text areas in HTML export
Before Org mode's Babel, one popular approach to publishing code in
HTML was by using :textarea. The advantage of this approach was
that copying and pasting was built into browsers with simple
JavaScript commands. Even editing before pasting was made simple.
The HTML export backend can create such text areas. It requires an
#+ATTR_HTML line as shown in the example below with the :textarea
option. This must be followed by either an example or a source code
block. Other Org block types do not honor the :textarea option.
By default, the HTML export backend creates a text area 80 characters
wide and height just enough to fit the content. Override these
defaults with :width and :height options on the #+ATTR_HTML
line.
#+ATTR_HTML: :textarea t :width 40
#+BEGIN_EXAMPLE
(defun org-xor (a b)
"Exclusive or."
(if a (not b) b))
#+END_EXAMPLE
CSS support
You can modify the CSS style definitions for the exported file. The
HTML exporter assigns the following special CSS classes(note: If the
classes on TODO keywords and tags lead to conflicts, use the variables
org-html-todo-kwd-class-prefix and org-html-tag-class-prefix to
make them unique.) to appropriate parts of the document—your style
specifications may change these, in addition to any of the standard
classes like for headlines, tables, etc.
p.author |
author information, including email |
p.date |
publishing date |
p.creator |
creator info, about org mode version |
.title |
document title |
.subtitle |
document subtitle |
.todo |
TODO keywords, all not-done states |
.done |
the DONE keywords, all states that count as done |
.WAITING |
each TODO keyword also uses a class named after itself |
.timestamp |
timestamp |
.timestamp-kwd |
keyword associated with a timestamp, like SCHEDULED |
.timestamp-wrapper |
span around keyword plus timestamp |
.tag |
tag in a headline |
._HOME |
each tag uses itself as a class, "@" replaced by "_" |
.target |
target for links |
.linenr |
the line number in a code example |
.code-highlighted |
for highlighting referenced code lines |
div.outline-N |
div for outline level N (headline plus text) |
div.outline-text-N |
extra div for text at outline level N |
.section-number-N |
section number in headlines, different for each level |
.figure-number |
label like "Figure 1:" |
.table-number |
label like "Table 1:" |
.listing-number |
label like "Listing 1:" |
div.figure |
how to format an in-lined image |
pre.src |
formatted source code |
pre.example |
normal example |
p.verse |
verse paragraph |
div.footnotes |
footnote section headline |
p.footnote |
footnote definition paragraph, containing a footnote |
.footref |
a footnote reference number (always a <sup>) |
.footnum |
footnote number in footnote definition (always <sup>) |
.org-svg |
default class for a linked .svg image |
The HTML export backend includes a compact default style in each exported HTML file. To override the default style with another style, use these keywords in the Org file. They will replace the global defaults the HTML exporter uses.
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" /> #+HTML_HEAD_EXTRA: <link rel="alternate stylesheet" type="text/css" href="style2.css" />
To just turn off the default style, customize
org-html-head-include-default-style variable, or use this option
line in the Org file.
#+OPTIONS: html-style:nil
For longer style definitions, either use several HTML_HEAD and
HTML_HEAD_EXTRA keywords, or use <style> ... </style> blocks
around them. Both of these approaches can avoid referring to an
external file.
In order to add styles to a subtree, use the HTML_CONTAINER_CLASS
property to assign a class to the tree. In order to specify CSS
styles for a particular headline, you can use the ID specified in
a CUSTOM_ID property. You can also assign a specific class to
a headline with the HTML_HEADLINE_CLASS property.
Never change the org-html-style-default constant. Instead, use other
simpler ways of customizing as described above.
JavaScript supported display of web pages
Sebastian Rose has written a JavaScript program especially designed to
allow two different ways of viewing HTML files created with Org. One
is an Info-like mode where each section is displayed separately and
navigation can be done with the n and p keys, and some other
keys as well, press ? for an overview of the available keys. The
second one has a folding view, much like Org provides inside Emacs.
The script is available at https://orgmode.org/org-info.js and the
documentation at https://orgmode.org/worg/code/org-info-js/. The
script is hosted on https://orgmode.org, but for reliability, prefer
installing it on your own web server.
To use this program, just add this line to the Org file:
#+INFOJS_OPT: view:info toc:nil
The HTML header now has the code needed to automatically invoke the script. For setting options, use the syntax from the above line for options described below:
-
path: -
The path to the script. The default is to grab the script from
https://orgmode.org/org-info.js, but you might want to have a local
copy and use a path like
../scripts/org-info.js. -
view: -
Initial view when the website is first shown. Possible values are:
infoInfo-like interface with one section per page overviewFolding interface, initially showing only top-level contentFolding interface, starting with all headlines visible showallFolding interface, all headlines and text visible -
sdepth: -
Maximum headline level still considered as an independent section
for info and folding modes. The default is taken from
org-export-headline-levels, i.e., theHswitch inOPTIONS. If this is smaller than inorg-export-headline-levels, each info/folding section can still contain child headlines. -
toc: -
Should the table of contents initially be visible? Even when
nil, you can always get to the "toc" withi. -
tdepth: -
The depth of the table of contents. The defaults are taken from the
variables
org-export-headline-levelsandorg-export-with-toc. -
ftoc: - Does the CSS of the page specify a fixed position for the "toc"? If yes, the TOC is displayed as a section.
-
ltoc: -
Should there be short contents (children) in each section? Make
this
aboveif the section should be above initial text. -
mouse: -
Headings are highlighted when the mouse is over them. Should be
underline(default) or a background color like#cccccc. -
buttons: -
Should view-toggle buttons be everywhere? When
nil(the default), only one such button is present.
You can choose default values for these options by customizing the
variable org-infojs-options. If you always want to apply the script
to your pages, configure the variable org-export-html-use-infojs.
LaTeX Export
The LaTeX export backend can handle complex documents, incorporate standard or custom LaTeX document classes, generate documents using alternate LaTeX engines, and produce fully linked PDF files with indexes, bibliographies, and tables of contents, destined for interactive online viewing or high-quality print publication.
While the details are covered in-depth in this section, here are some
quick references to variables for the impatient: for engines, see
org-latex-compiler; for build sequences, see
org-latex-pdf-process; for packages, see
org-latex-default-packages-alist and org-latex-packages-alist.
An important note about the LaTeX export backend: it is sensitive to blank lines in the Org document. That's because LaTeX itself depends on blank lines to tell apart syntactical elements, such as paragraphs.
The following sections expect users to be familiar with common LaTeX
terminology. You may refer to https://tug.org/begin.html to get
familiar with LaTeX basics. Users with LaTeX installed may also run
texdoc latex from terminal to open LaTeX introduction (note: The
command will open a PDF file, which is also available for download
from https://mirrors.ctan.org/info/latex-doc-ptr/latex-doc-ptr.pdf)
LaTeX/PDF export commands
-
C-c C-e l l(org-latex-export-to-latex)
Export to a LaTeX file with a .tex extension. For myfile.org,
Org exports to myfile.tex, overwriting without warning.
-
C-c C-e l L(org-latex-export-as-latex)
Export to a temporary buffer. Do not create a file.
-
C-c C-e l p(org-latex-export-to-pdf)
Export as LaTeX file and convert it to PDF file.
-
C-c C-e l o
Export as LaTeX file and convert it to PDF, then open the PDF using the default viewer.
-
M-x org-export-region-as-latex - Convert the region to LaTeX under the assumption that it was in Org mode syntax before. This is a global command that can be invoked in any buffer.
The LaTeX export backend can use any of these LaTeX engines:
pdflatex, xelatex, and lualatex. These engines compile LaTeX
files with different compilers, packages, and output options. The
LaTeX export backend finds the compiler version to use from
org-latex-compiler variable or the #+LATEX_COMPILER keyword in the
Org file. See the docstring for the
org-latex-default-packages-alist for loading packages with certain
compilers. Also see org-latex-bib-compiler to set the
bibliography compiler48.
LaTeX specific export settings
The LaTeX export backend has several additional keywords for customizing LaTeX output. Setting these keywords works similar to the general options (see Export Settings).
-
DESCRIPTION
The document's description. The description along with author name,
keywords, and related file metadata are inserted in the output file
by the hyperref package. See org-latex-hyperref-template for
customizing metadata items. See org-latex-title-command for
typesetting description into the document's front matter. Use
multiple DESCRIPTION keywords for long descriptions.
-
LANGUAGE
Language code of the primary document language. When LANGUAGE
keyword is not specified use the value of
org-export-default-language (by default - en, American English)
The list of language codes supported by Org is stored in the
variable org-latex-language-alist.
In order to be effective, the babel or polyglossia
packages—according to the LaTeX compiler used—must be loaded
with the appropriate language as argument. This can be accomplished
by modifying the org-latex-packages-alist variable, e.g., with the
following snippet (note that polyglossia does not work with
pdfLaTeX):
(add-to-list 'org-latex-packages-alist
'("AUTO" "babel" t ("pdflatex" "xelatex" "lualatex")))
(add-to-list 'org-latex-packages-alist
'("AUTO" "polyglossia" t ("xelatex" "lualatex")))-
LATEX_CLASS
This is LaTeX document class, such as article, report, book,
and so on, which contain predefined preamble and headline level
mapping that the LaTeX export backend needs. The backend reads
the default class name from the org-latex-default-class variable.
Org has article as the default class. A valid default class must
be an element of org-latex-classes.
-
LATEX_CLASS_OPTIONS
Options the LaTeX export backend uses when calling the LaTeX document class.
-
LATEX_COMPILER
The compiler, such as pdflatex, xelatex, lualatex, for
producing the PDF. See org-latex-compiler.
-
LATEX_HEADER,LATEX_HEADER_EXTRA
Arbitrary lines to add to the document's preamble, before the
hyperref settings. See org-latex-classes for adjusting the
structure and order of the LaTeX headers.
-
LATEX_CLASS_PRE
Arbitrary lines to prepend before the LaTeX preamble.
-
KEYWORDS
The keywords for the document. The description along with author
name, keywords, and related file metadata are inserted in the output
file by the hyperref package. See org-latex-hyperref-template for
customizing metadata items. See org-latex-title-command for
typesetting description into the document's front matter. Use
multiple KEYWORDS lines if necessary.
-
SUBTITLE
The document's subtitle. It is typeset as per
org-latex-subtitle-format. If org-latex-subtitle-separate is
non-nil, it is typed outside the \title macro. See
org-latex-hyperref-template for customizing metadata items. See
org-latex-title-command for typesetting description into the
document's front matter.
The following sections have further details.
LaTeX header and sectioning structure
The LaTeX export backend converts the first three of Org's outline levels into LaTeX headlines. The remaining Org levels are exported as lists. To change this globally for the cut-off point between levels and lists, (see Export Settings).
By default, the LaTeX export backend uses the article class.
To change the default class globally, edit org-latex-default-class.
To change the default class locally in an Org file, add option lines
#+LATEX_CLASS: myclass. To change the default class for just a part
of the Org file, set a subtree property, EXPORT_LATEX_CLASS. The
class name entered here must be valid member of org-latex-classes.
This variable defines a header template for each class into which the
exporter splices the values of org-latex-default-packages-alist and
org-latex-packages-alist. Use the same three variables to define
custom sectioning or custom classes.
The LaTeX export backend sends the LATEX_CLASS_OPTIONS keyword and
EXPORT_LATEX_CLASS_OPTIONS property as options to the LaTeX
\documentclass macro. The options and the syntax for specifying
them, including enclosing them in square brackets, follow LaTeX
conventions.
#+LATEX_CLASS_OPTIONS: [a4paper,11pt,twoside,twocolumn]
The LaTeX export backend appends values from LATEX_HEADER and
LATEX_HEADER_EXTRA keywords to the LaTeX header. The docstring for
org-latex-classes explains in more detail. Also note that LaTeX
export backend does not append LATEX_HEADER_EXTRA to the header
when previewing LaTeX snippets (see Previewing LaTeX fragments).
A sample Org file with the above headers:
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [a4paper]
#+LATEX_HEADER: \usepackage{xyz}
* Headline 1
some text
* Headline 2
some more text
The LaTeX export backend prepends values from LATEX_CLASS_PRE
keywords before the LaTeX preamble. Use this option when you want to
set the values passed to packages included in the document class. For
example, to use extended names for the xcolor package, use
#+LATEX_CLASS_PRE: \PassOptionsToPackage{dvipsnames}{xcolor}
LaTeX packages babel or polyglossia can also be loaded in a
document. The "AUTO" string will be replaced in both cases by the
appropriate value for the LANGUAGE keyword, if present in the
document, or by the value of org-export-default-language. Let's see
some examples in one or another case.
Babel accepts the classic syntax and (in addition) the new syntax
with the \babelprovide command to load the languages using the new
INI files procedure. Keep in mind that there are a number of
languages that are only served in babel using INI files, so they
cannot be declared using the classic syntax, but only using the
\babelprovide command (see
https://mirrors.ctan.org/macros/latex/required/babel/base/babel.pdf).
Valid usage examples could be:
#+LATEX_HEADER: \usepackage[french,italian,AUTO]{babel}
where "AUTO" is the main language. But it can also be loaded using
the \babelprovide command:
#+LATEX_HEADER: \usepackage[french,italian]{babel}
#+LATEX_HEADER: \babelprovide[import, main]{AUTO}
Polyglossia, for this procedure to be effective, must be loaded
using the same babel classic syntax (but note that this is not
the actual polyglossia syntax). For example, suppose a document
declares Polytonic Greek as the primary language, and French as the
secondary language. In this case, it would be expressed as:
#+LANGUAGE: el-polyton
#+LATEX_HEADER: \usepackage[french,AUTO]{polyglossia}
This would produce in LaTeX (with the actual polyglossia syntax):
\usepackage{polyglossia}
\setmainlanguage[variant=polytonic]{greek}
\setotherlanguage{french}
The LaTeX backend normally exports using the Roman font family
specified in the document class or by the user in the
LATEX_HEADER. Setting the option org-latex-use-sans to t will
force the LaTeX compiler to use the Sans font as default. You can also
include it in the document options with:
#+OPTIONS: latex-use-sans:t
Quoting LaTeX code
When the available LaTeX export customizations are not sufficient to fine-tune the desired output, it is possible to insert any arbitrary LaTeX code (see Embedded LaTeX). There are three ways to embed such code in the Org file, and they all use different quoting syntax.
Inserting in-line quoted with @ symbols:
Code embedded in-line @@latex:any arbitrary LaTeX code@@ in a paragraph.
Inserting as one or more keyword lines in the Org file:
#+LATEX: any arbitrary LaTeX code
Inserting as an export block in the Org file, where the backend exports any code between begin and end markers:
#+BEGIN_EXPORT latex any arbitrary LaTeX code #+END_EXPORT
Tables in LaTeX export
The LaTeX export backend can pass several LaTeX attributes for table contents and layout. Besides specifying a label (see Internal Links) and a caption (see Captions), the other valid LaTeX attributes include:
-
:mode
The LaTeX export backend wraps the table differently depending on
the mode for accurate rendering of math symbols. Mode is either
table, math, inline-math, verbatim or tabbing.
For math or inline-math mode, LaTeX export backend wraps the
table in a math environment, but every cell in it is exported as-is.
For tabbing the LaTeX tabbing environment is used and the correct
tabbing delimiters \> are used.
The LaTeX export backend determines the default mode from
org-latex-default-table-mode. The LaTeX export backend merges
contiguous tables in the same mode into a single environment.
-
:environment
Set the default LaTeX table environment for the LaTeX export
backend to use when exporting Org tables. Common LaTeX table
environments are provided by these packages: tabularx, longtable,
array, tabu, and bmatrix. For packages, such as tabularx and tabu,
or any newer replacements, include them in the
org-latex-packages-alist variable so the LaTeX export backend can
insert the appropriate load package headers in the converted LaTeX
file. Look in the docstring for the org-latex-packages-alist
variable for configuring these packages for LaTeX snippet previews,
if any.
-
:caption -
Use
CAPTIONkeyword to set a simple caption for a table (see Captions). For custom captions, use:captionattribute, which accepts raw LaTeX code.:captionvalue overridesCAPTIONvalue. -
:float,:placement -
The table environments by default are not floats in LaTeX. To make
them floating objects use
:floatwith one of the following options:t(for a defaulttableenvironment),sideways(for asidewaystableenvironment),multicolumn(to span the table across multiple columns of a page in atable*environment) andnil. In addition to these three values,:floatcan pass through any arbitrary value, for example a user-defined float type with thefloatLaTeX package. LaTeX floats can also have additional layout:placementattributes. These are the usual[h t b p ! H]permissions specified in square brackets. Note that for:float sidewaystables, the LaTeX export backend ignores:placementattributes. -
:align,:font,:width - The LaTeX export backend uses these attributes for regular tables to set their alignments, fonts, and widths.
-
:options -
The
:optionsattribute allows adding an optional argument with a list of various table options (between brackets in LaTeX export), since certain tabular environments, such as longtblr of the tabularray LaTeX package, provides this structure. For example::options remark{Note}={note},remark{Source}={source}. -
:spread -
When
:spreadis non-nil, the LaTeX export backend spreads or shrinks the table by the:widthfor tabu and longtabu environments.:spreadhas no effect if:widthis not set. -
:booktabs,:center,:rmlines
All three commands are toggles. :booktabs brings in modern
typesetting enhancements to regular tables. The booktabs package
has to be loaded through org-latex-packages-alist. :center is
for centering the table. :rmlines removes all but the very first
horizontal line made of ASCII characters from "table.el" tables
only.
-
:math-prefix,:math-suffix,:math-arguments -
The LaTeX export backend inserts
:math-prefixstring value in a math environment before the table. The LaTeX export backend inserts:math-suffixstring value in a math environment after the table. The LaTeX export backend inserts:math-argumentsstring value between the macro name and the table's contents.:math-argumentscomes in use for matrix macros that require more than one argument, such asqbordermatrix.
LaTeX table attributes help to format tables for a wide range of situations, such as matrix product or spanning multiple pages:
#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
| ... | ... |
| ... | ... |
#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
| a | b |
| c | d |
#+ATTR_LATEX: :mode math :environment bmatrix
| 1 | 2 |
| 3 | 4 |
Set the caption with the LaTeX command
\bicaption{HeadingA}{HeadingB}:
#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
| ... | ... |
| ... | ... |
Images in LaTeX export
The LaTeX export backend processes image links in Org files that do
not have descriptions, such as these links [[file:img.jpg]] or
[[#_002e_002fimg_002ejpg][./img.jpg]], as direct image insertions in the final PDF output. In
the PDF, they are no longer links, but actual images embedded on the
page. The LaTeX export backend uses \includegraphics macro to
insert the image. But for TikZ (https://sourceforge.net/projects/pgf/)
images, the backend uses an \input macro wrapped within
a tikzpicture environment.
For specifying image :width, :height, :scale and other :options,
use this syntax:
#+ATTR_LATEX: :width 5cm :options angle=90 [[#_002e_002fimg_002fsed_002dhr4049_002epdf][./img/sed-hr4049.pdf]]
A :scale attribute overrides both :width and :height attributes.
For custom commands for captions, use the :caption attribute. It
overrides the default #+CAPTION value:
#+ATTR_LATEX: :caption \bicaption{HeadingA}{HeadingB}
[[#_002e_002fimg_002fsed_002dhr4049_002epdf][./img/sed-hr4049.pdf]]
When captions follow the method as described in Captions, the LaTeX
export backend wraps the picture in a floating figure environment.
To float an image without specifying a caption, set the :float
attribute to one of the following:
-
t -
For a default
figureenvironment. -
multicolumn -
To span the image across multiple columns of a page; the backend
wraps the image in a
figure*environment. -
wrap - For text to flow around the image on the right; the figure occupies the left half of the page.
-
sideways -
For a new page with the image sideways, rotated ninety degrees, in
a
sidewaysfigureenvironment; overrides:placementsetting. -
nil -
To avoid a
:floateven if using a caption. - Any arbitrary value
-
For example, a user-defined float type with the
floatLaTeX package.
Use the placement attribute to modify a floating environment's
placement.
#+ATTR_LATEX: :float wrap :width 0.38\textwidth :placement {r}{0.4\textwidth}
[[#_002e_002fimg_002fhst_002epng][./img/hst.png]]
The LaTeX export backend centers all images by default. Setting
:center to nil disables centering. To disable centering globally,
set org-latex-images-centered to nil.
Set the :comment-include attribute to non-nil value for the LaTeX
export backend to comment out the \includegraphics macro.
Plain lists in LaTeX export
The LaTeX export backend accepts the environment and options
attributes for plain lists. Both attributes work together for
customizing lists, as shown in the examples:
#+LATEX_HEADER: \usepackage[inline]{enumitem}
Some ways to say "Hello":
#+ATTR_LATEX: :environment itemize*
#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={, and}]
- Hola
- Bonjour
- Guten Tag.
Since LaTeX supports only four levels of nesting for lists, use an
external package, such as enumitem in LaTeX, for levels deeper than
four:
#+LATEX_HEADER: \usepackage{enumitem}
#+LATEX_HEADER: \renewlist{itemize}{itemize}{9}
#+LATEX_HEADER: \setlist[itemize]{label=$\circ$}
- One
- Two
- Three
- Four
- Five
Source blocks in LaTeX export
LaTeX export backend provides multiple ways to render src blocks in
LaTeX, according to the value of org-latex-src-block-backend. The
default value verbatim renders the src code verbatim, without any
extra styling. Alternative values allow more colorful styling, but
require additional LaTeX (listings, minted), system (minted), or
Emacs (engraved) packages. See the org-latex-src-block-backend
docstring for more details.
The LaTeX export backend can make source code blocks into floating
objects through the attributes :float and :options. For :float:
-
t - Makes a source block float; by default floats any source block with a caption.
-
multicolumn - Spans the source block across multiple columns of a page.
-
nil -
Avoids a
:floateven if using a caption; useful for source code blocks that may not fit on a page.
#+ATTR_LATEX: :float nil #+BEGIN_SRC emacs-lisp Lisp code that may not fit in a single page. #+END_SRC
The LaTeX export backend passes string values in :options to LaTeX
packages for customization of that specific source block. In the
example below, the :options are set for Engraved or Minted. Minted
is a source code highlighting LaTeX package with many configurable
options(note: Minted uses an external Python package for code
highlighting, which requires the flag -shell-escape to be added to
org-latex-pdf-process.). Both Minted and Engraved are built on
fvextra, and so support many of
the same options.
#+ATTR_LATEX: :options mathescape
#+BEGIN_SRC emacs-lisp
(defun Fib (n) ; $n_i = n_{i-2} + n_{i-1}$
(if (< n 2) n (+ (Fib (- n 1)) (Fib (- n 2)))))
#+END_SRC
To apply similar configuration options for all source blocks in a
file, use the org-latex-listings-options,
org-latex-engraved-options, and org-latex-minted-options
variables.
Example blocks in LaTeX export
The LaTeX export backend wraps the contents of example blocks in
a verbatim environment. To change this behavior to use another
environment globally, specify an appropriate export filter (see
Advanced Export Configuration). To change this behavior to use
another environment for each block, use the :environment parameter
to specify a custom environment.
#+ATTR_LATEX: :environment myverbatim #+BEGIN_EXAMPLE This sentence is false. #+END_EXAMPLE
Special blocks in LaTeX export
For other special blocks in the Org file, the LaTeX export backend
makes a special environment of the same name. The backend also takes
:options, if any, and appends as-is to that environment's opening
string. For example:
#+BEGIN_abstract We demonstrate how to solve the Syracuse problem. #+END_abstract #+ATTR_LATEX: :options [Proof of important theorem] #+BEGIN_proof ... Therefore, any even number greater than 2 is the sum of two primes. #+END_proof
exports to
\begin{abstract}
We demonstrate how to solve the Syracuse problem.
\end{abstract}
\begin{proof}[Proof of important theorem]
...
Therefore, any even number greater than 2 is the sum of two primes.
\end{proof}
If you need to insert a specific caption command, use :caption
attribute. It overrides standard CAPTION value, if any. For
example:
#+ATTR_LATEX: :caption \MyCaption{HeadingA}
#+BEGIN_proof
...
#+END_proof
Horizontal rules in LaTeX export
The LaTeX export backend converts horizontal rules by the specified
:width and :thickness attributes. For example:
#+ATTR_LATEX: :width .6\textwidth :thickness 0.8pt -----
Verse blocks in LaTeX export
The LaTeX export backend accepts five attributes for verse blocks:
:lines, :center, :versewidth, :latexcode and :literal. The
three first require the external LaTeX package verse.sty, which is
an extension of the standard LaTeX environment.
-
:lines - To add marginal verse numbering. Its value is an integer, the sequence in which the verses should be numbered.
-
:center - With value
tall the verses on the page are optically centered (a typographic convention for poetry), taking as a reference the longest verse, which must be indicated by the attribute:versewidth. -
:versewidth - Its value is a literal text string with the longest verse.
-
:latexcode - It accepts any arbitrary LaTeX code that can be
included within a LaTeX
verseenvironment. -
:literal - With value t, all blank lines are preserved and
exported as
\vspace*{\baselineskip}, including the blank lines before or after contents. Note that without the:literalattribute, one or more blank lines between stanzas are exported as a single blank line, and any blank lines before or after the content are removed, which is more consistent with the syntax of the LaTeX `verse' environment, and the one provided by theversepackage. If theversepackage is loaded, the vertical spacing between all stanzas can be controlled by the global length\stanzaskip(see https://www.ctan.org/pkg/verse).
A complete example with Shakespeare's first sonnet:
#+ATTR_LATEX: :center t :latexcode \color{red} :lines 5
#+ATTR_LATEX: :versewidth Feed’st thy light’s flame with self-substantial fuel,
#+BEGIN_VERSE
From fairest creatures we desire increase,
That thereby beauty’s rose might never die,
But as the riper should by time decease
His tender heir might bear his memory
But thou, contracted to thine own bright eyes,
Feed’st thy light’s flame with self-substantial fuel,
Making a famine where abundance lies,
Thyself thy foe, to thy sweet self too cruel.
Thou that art now the world’s fresh ornament,
And only herald to the gaudy spring,
Within thine own bud buriest thy content,
And, tender churl, mak’st waste in niggardly.
Pity the world, or else this glutton be,
To eat the world’s due, by the grave and thee.
#+END_VERSEQuote blocks in LaTeX export
The LaTeX export backend accepts two attributes for quote blocks:
:environment, for an arbitrary quoting environment (the default
value is that of org-latex-default-quote-environment: "quote") and
:options. For example, to choose the environment quotation,
included as an alternative to quote in standard LaTeX classes:
#+ATTR_LATEX: :environment quotation #+BEGIN_QUOTE some text... #+END_QUOTE
To choose the foreigndisplayquote environment, included in the LaTeX
package csquotes, with the german option, use this syntax:
#+LATEX_HEADER:\usepackage[autostyle=true]{csquotes}
#+ATTR_LATEX: :environment foreigndisplayquote :options {german}
#+BEGIN_QUOTE
some text in German...
#+END_QUOTE
which is exported to LaTeX as
\begin{foreigndisplayquote}{german}
some text in German...
\end{foreigndisplayquote}
Controlling the way the table of contents is generated
When exporting your document to LaTeX, only numbered sections will be
included. This is closer to LaTeX and different to how other exporters
work (see Table of Contents). If you need an unnumbered section
to appear in the table of contents, use the property UNNUMBERED and
set it to toc:
:PROPERTIES: :UNNUMBERED: toc :END:
If you want the LaTeX exporter to behave like other exporters,
customise the variable org-latex-toc-include-unnumbered and
set it to t:
(setq org-latex-toc-include-unnumbered t)
or add this setting in the local variables.
In this case, unnumbered sections will be included in the table of
contents, unless you set the UNNUMBERED property to notoc:
:PROPERTIES: :UNNUMBERED: notoc :END:
Markdown Export
The Markdown export backend, "md", converts an Org file to Markdown format, as defined at https://daringfireball.net/projects/markdown/. This is the original Markdown specification, developed by John Gruber and Aaron Swartz.
Since "md" backend is built on top of the HTML backend (see HTML Export), it converts every Org construct not defined in Markdown syntax, such as tables, to HTML.
Do note that the original Markdown syntax has differences with other commonly used Markdown flavors. See https://en.wikipedia.org/wiki/Markdown for more details.
Markdown export commands
-
C-c C-e m m(org-md-export-to-markdown)
Export to a text file with Markdown syntax. For myfile.org, Org
exports to myfile.md, overwritten without warning.
-
C-c C-e m M(org-md-export-as-markdown)
Export to a temporary buffer. Does not create a file.
-
C-c C-e m o
Export as a text file with Markdown syntax, then open it.
Header and sectioning structure
Based on org-md-headline-style, Markdown export can generate
headlines of both atx and setext types. setext limits headline
levels to two whereas atx limits headline levels to six. mixed
exports headline levels one and two in setext-style, and headline
levels three through six as atx-style headlines. Beyond these
limits, the export backend converts headlines to lists. To set a
limit to a level before the absolute limit (see Export Settings).
OpenDocument Text Export
The ODT export backend handles creating of OpenDocument Text (ODT) format. Documents created by this exporter use the OpenDocument-v1.2 specification(note: See Open Document Format for Office Applications (OpenDocument) Version 1.2.) and are compatible with LibreOffice 3.4.
Pre-requisites for ODT export
The ODT export backend relies on the zip program to create the final
compressed ODT output. Check if zip is locally available and
executable. Without it, export cannot finish.
ODT export commands
-
C-c C-e o o(org-odt-export-to-odt)
Export as OpenDocument Text file.
If org-odt-preferred-output-format is specified, the ODT export
backend automatically converts the exported file to that format.
For myfile.org, Org exports to myfile.odt, overwriting without
warning. The ODT export backend exports a region only if a region
was active.
If the selected region is a single tree, the ODT export backend
makes the tree head the document title. Incidentally, C-c @ selects the current subtree. If the tree head entry has, or
inherits, an EXPORT_FILE_NAME property, the ODT export backend
uses that for file name.
-
C-c C-e o O
Export as an OpenDocument Text file and open the resulting file.
If org-export-odt-preferred-output-format is specified, open the
converted file instead. See Automatically exporting to other formats.
ODT specific export settings
The ODT export backend has several additional keywords for customizing ODT output. Setting these keywords works similar to the general options (see Export Settings).
-
DESCRIPTION
This is the document's description, which the ODT export backend
inserts as document metadata. For long descriptions, use multiple
lines, prefixed with DESCRIPTION.
-
KEYWORDS
The keywords for the document. The ODT export backend inserts the
description along with author name, keywords, and related file
metadata as metadata in the output file. Use multiple KEYWORDS if
necessary.
-
ODT_STYLES_FILE
The ODT export backend uses the org-odt-styles-file by default.
See Applying custom styles for details.
-
SUBTITLE
The document subtitle.
Extending ODT export
The ODT export backend can produce documents in other formats besides
ODT using a specialized ODT converter process. Its common interface
works with popular converters to produce formats such as doc, or
convert a document from one format, say csv, to another format, say
xls.
Customize org-odt-convert-process variable to point to unoconv,
which is the ODT's preferred converter. Working installations of
LibreOffice would already have unoconv installed. Alternatively,
other converters may be substituted here. See Configuring a document converter.
Automatically exporting to other formats
If ODT format is just an intermediate step to get to other formats,
such as doc, docx, rtf, or pdf, etc., then extend the ODT
export backend to directly produce that format. Specify the final
format in the org-odt-preferred-output-format variable. This is one
way to extend (see ODT export commands).
Converting between document formats
The Org export backend is made to be interoperable with a wide range of text document format converters. Newer generation converters, such as LibreOffice and Pandoc, can handle hundreds of formats at once. Org provides a consistent interaction with whatever converter is installed. Here are some generic commands:
-
M-x org-odt-convert
Convert an existing document from one format to another. With a prefix argument, opens the newly produced file.
Applying custom styles
The ODT export backend comes with many OpenDocument styles (see Working with OpenDocument style files). To expand or further customize these built-in style sheets, either edit the style sheets directly or generate them using an application such as LibreOffice. The example here shows creating a style using LibreOffice.
Applying custom styles: the easy way
-
Create a sample
example.orgfile with settings as shown below, and export it to ODT format.#+OPTIONS: H:10 num:t
- Open the above
example.odtusing LibreOffice. Use the Stylist to locate the target styles, which typically have the "Org" prefix. Open one, modify, and save as either OpenDocument Text (ODT) or OpenDocument Template (OTT) file.
Customize the variable org-odt-styles-file and point it to the
newly created file. For additional configuration options, see
Overriding factory styles.
To apply an ODT style to a particular file, use the
ODT_STYLES_FILE keyword as shown in the example below:
#+ODT_STYLES_FILE: "/path/to/example.ott"
or
#+ODT_STYLES_FILE: ("/path/to/file.ott" ("styles.xml" "image/hdr.png"))
Using third-party styles and templates
The ODT export backend relies on many templates and style names. Using third-party styles and templates can lead to mismatches. Templates derived from built-in ODT templates and styles seem to have fewer problems.
Links in ODT export
ODT exporter creates native cross-references for internal links. It creates Internet-style links for all other links.
A link with no description and pointing to a regular, un-itemized, outline heading is replaced with a cross-reference and section number of the heading.
A \ref{label}-style reference to an image, table etc., is replaced
with a cross-reference and sequence number of the labeled entity. See
Labels and captions in ODT export.
Tables in ODT export
The ODT export backend handles native Org mode tables (see Tables)
and simple table.el tables. Complex table.el tables having column
or row spans are not supported. Such tables are stripped from the
exported document.
By default, the ODT export backend exports a table with top and bottom frames and with ruled lines separating row and column groups (see Column Groups). All tables are typeset to occupy the same width. The ODT export backend honors any table alignments and relative widths for columns (see Column Width and Alignment).
Note that the ODT export backend interprets column widths as weighted ratios, the default weight being 1.
Specifying :rel-width property on an ATTR_ODT line controls the
width of the table. For example:
#+ATTR_ODT: :rel-width 50 | Area/Month | Jan | Feb | Mar | Sum | |---------------+-------+-------+-------+-------| | / | < | | | < | | <l13> | <r5> | <r5> | <r5> | <r6> | | North America | 1 | 21 | 926 | 948 | | Middle East | 6 | 75 | 844 | 925 | | Asia Pacific | 9 | 27 | 790 | 826 | |---------------+-------+-------+-------+-------| | Sum | 16 | 123 | 2560 | 2699 |
On export, the above table takes 50% of text width area. The exporter sizes the columns in the ratio: 13:5:5:5:6. The first column is left-aligned and rest of the columns, right-aligned. Vertical rules separate the header and the last column. Horizontal rules separate the header and the last row.
For even more customization, create custom table styles and associate
them with a table using the ATTR_ODT keyword. See Customizing tables in ODT export.
Images in ODT export
Embedding images
The ODT export backend processes image links in Org files that do not
have descriptions, such as these links [[file:img.jpg]] or [[#_002e_002fimg_002ejpg][./img.jpg]],
as direct image insertions in the final output. Either of these
examples works:
[[file:img.png]]
[[#_002e_002fimg_002epng][./img.png]]
Embedding clickable images
For clickable images, provide a link whose description is another link
to an image file. For example, to embed an image
org-mode-unicorn.png which when clicked jumps to https://orgmode.org
website, do the following
[[https://orgmode.org][./org-mode-unicorn.png]]
Sizing and scaling of embedded images
Control the size and scale of the embedded images with the ATTR_ODT
attribute.
The ODT export backend starts with establishing the size of the image
in the final document. The dimensions of this size are measured in
centimeters. The backend then queries the image file for its
dimensions measured in pixels. For this measurement, the backend
relies on ImageMagick's identify program or Emacs create-image and
image-size API. ImageMagick is the preferred choice for large file
sizes or frequent batch operations. The backend then converts the
pixel dimensions using org-odt-pixels-per-inch into the familiar 72
dpi or 96 dpi. The default value for this is in
display-pixels-per-inch, which can be tweaked for better results
based on the capabilities of the output device. Here are some common
image scaling operations:
- Explicitly size the image
-
To embed
img.pngas a 10 cm x 10 cm image, do the following:#+ATTR_ODT: :width 10 :height 10 [[#_002e_002fimg_002epng][./img.png]]
- Scale the image
-
To embed
img.pngat half its size, do the following:#+ATTR_ODT: :scale 0.5 [[#_002e_002fimg_002epng][./img.png]]
- Scale the image to a specific width
-
To embed
img.pngwith a width of 10 cm while retaining the original height:width ratio, do the following:#+ATTR_ODT: :width 10 [[#_002e_002fimg_002epng][./img.png]]
- Scale the image to a specific height
-
To embed
img.pngwith a height of 10 cm while retaining the original height:width ratio, do the following:#+ATTR_ODT: :height 10 [[#_002e_002fimg_002epng][./img.png]]
Anchoring of images
The ODT export backend can anchor images to as-char, paragraph,
or page. Set the preferred anchor using the :anchor property of
the ATTR_ODT line.
To create an image that is anchored to a page:
#+ATTR_ODT: :anchor page [[#_002e_002fimg_002epng][./img.png]]
Math formatting in ODT export
The ODT exporter has special support for handling math.
LaTeX math snippets
LaTeX math snippets (see LaTeX fragments) can be embedded in the ODT document in one of the following ways:
- MathML
Add this line to the Org file. This option is activated on a per-file basis.
#+OPTIONS: tex:t
With this option, LaTeX fragments are first converted into MathML fragments using an external LaTeX-to-MathML converter program. The resulting MathML fragments are then embedded as an OpenDocument Formula in the exported document.
You can specify the LaTeX-to-MathML converter by customizing the
variables org-latex-to-mathml-convert-command and
org-latex-to-mathml-jar-file.
If you prefer to use MathToWeb(note: See MathToWeb.) as your converter, you can configure the above variables as shown below.
(setq org-latex-to-mathml-convert-command
"java -jar %j -unicode -force -df %o %I"
org-latex-to-mathml-jar-file
"/path/to/mathtoweb.jar")or, to use LaTeXML(note: See https://dlmf.nist.gov/LaTeXML/.) instead,
(setq org-latex-to-mathml-convert-command
"latexmlmath %i --presentationmathml=%o")To quickly verify the reliability of the LaTeX-to-MathML converter, use the following commands:
-
M-x org-export-as-odf -
Convert a LaTeX math snippet to an OpenDocument formula (
.odf) file. -
M-x org-export-as-odf-and-open -
Convert a LaTeX math snippet to an OpenDocument formula (
.odf) file and open the formula file with the system-registered application.
- PNG images
Add this line to the Org file. This option is activated on a per-file basis.
#+OPTIONS: tex:dvipng
#+OPTIONS: tex:dvisvgm
or
#+OPTIONS: tex:imagemagick
Under this option, LaTeX fragments are processed into PNG or SVG images and the resulting images are embedded in the exported document. This method requires dvipng program, dvisvgm or ImageMagick programs.
MathML and OpenDocument formula files
When embedding LaTeX math snippets in ODT documents is not reliable,
there is one more option to try. Embed an equation by linking to its
MathML (.mml) source or its OpenDocument formula (.odf) file as
shown below:
[[#_002e_002fequation_002emml][./equation.mml]]
or
[[#_002e_002fequation_002eodf][./equation.odf]]
Labels and captions in ODT export
ODT format handles labeling and captioning of objects based on their types. Inline images, tables, LaTeX fragments, and Math formulas are numbered and captioned separately. Each object also gets a unique sequence number based on its order of first appearance in the Org file. Each category has its own sequence. A caption is just a label applied to these objects.
#+CAPTION: Bell curve #+NAME: fig:SED-HR4049 [[#_002e_002fimg_002fa_002epng][./img/a.png]]
When rendered, it may show as follows in the exported document:
Figure 2: Bell curve
To modify the category component of the caption, customize the option
org-odt-category-map-alist. For example, to tag embedded images
with the string "Illustration" instead of the default string "Figure",
use the following setting:
(setq org-odt-category-map-alist
'(("__Figure__" "Illustration" "value" "Figure" org-odt--enumerable-image-p)))With the above modification, the previous example changes to:
Illustration 2: Bell curve
Literal examples in ODT export
The ODT export backend supports literal examples (see Literal Examples) with full fontification. Internally, the ODT export
backend relies on htmlfontify.el to generate the style definitions
needed for fancy listings. The auto-generated styles get OrgSrc
prefix and inherit colors from the faces used by Emacs Font Lock
library for that source language.
For custom fontification styles, customize the
org-odt-create-custom-styles-for-srcblocks option.
To turn off fontification of literal examples, customize the
org-odt-fontify-srcblocks option.
Advanced topics in ODT export
The ODT export backend has extensive features useful for power users and frequent uses of ODT formats.
Configuring a document converter
The ODT export backend works with popular converters with little or no extra configuration. See Extending ODT export. The following is for unsupported converters or tweaking existing defaults.
- Register the converter
Add the name of the converter to the org-odt-convert-processes
variable. Note that it also requires how the converter is invoked
on the command line. See the variable's docstring for details.
- Configure its capabilities
Specify which formats the converter can handle by customizing the
variable org-odt-convert-capabilities. Use the entry for the
default values in this variable for configuring the new converter.
Also see its docstring for details.
- Choose the converter
Select the newly added converter as the preferred one by customizing
the option org-odt-convert-process.
Working with OpenDocument style files
This section explores the internals of the ODT exporter; the means by which it produces styled documents; the use of automatic and custom OpenDocument styles.
The ODT exporter relies on two files for generating its output. These
files are bundled with the distribution under the directory pointed to
by the variable org-odt-styles-dir. The two files are:
-
OrgOdtStyles.xml -
This file contributes to the
styles.xmlfile of the final ODT document. This file gets modified for the following purposes:- To control outline numbering based on user settings;
- To add styles generated by
htmlfontify.elfor fontification of code blocks.
-
OrgOdtContentTemplate.xml -
This file contributes to the
content.xmlfile of the final ODT document. The contents of the Org outline are inserted between the<office:text>…</office:text>elements of this file.Apart from serving as a template file for the final
content.xml, the file serves the following purposes:- It contains automatic styles for formatting of tables which are referenced by the exporter;
- It contains
<text:sequence-decl>…</text:sequence-decl>elements that control numbering of tables, images, equations, and similar entities.
The following two variables control the location from where the ODT exporter picks up the custom styles and content template files. Customize these variables to override the factory styles used by the exporter.
-
org-odt-styles-file -
The ODT export backend uses the file pointed to by this variable, such as
styles.xml, for the final output. It can take one of the following values:-
FILE.xml -
Use this file instead of the default
styles.xml -
FILE.odtorFILE.ott -
Use the
styles.xmlcontained in the specified OpenDocument Text or Template file -
FILE.odtorFILE.ottand a subset of included files -
Use the
styles.xmlcontained in the specified OpenDocument Text or Template file. Additionally, extract the specified member files and embed those within the final ODT document. Use this option if thestyles.xmlfile references additional files like header and footer images. -
nil -
Use the default
styles.xml.
-
-
org-odt-content-template-file -
Use this variable to specify the blank
content.xmlused in the final output.
Creating one-off styles
The ODT export backend can read embedded raw OpenDocument XML from the Org file. Such direct formatting is useful for one-off instances.
- Embedding ODT tags as part of regular text
-
Enclose OpenDocument syntax in
@@odt:...@@for inline markup. For example, to highlight a region of text do the following:@@odt:<text:span text:style-name="Highlight">This is highlighted text</text:span>@@. But this is regular text.
Hint: To see the above example in action, edit the
styles.xml(see Factory styles) and add a custom Highlight style as shown below:<style:style style:name="Highlight" style:family="text"> <style:text-properties fo:background-color="#ff0000"/> </style:style>
- Embedding a one-line OpenDocument XML
The ODT export backend can read one-liner options with #+ODT: in
the Org file. For example, to force a page break:
#+ODT: <text:p text:style-name="PageBreak"/>
Hint: To see the above example in action, edit your
styles.xml (see Factory styles) and add a custom PageBreak
style as shown below.
<style:style style:name="PageBreak" style:family="paragraph"
style:parent-style-name="Text_20_body">
<style:paragraph-properties fo:break-before="page"/>
</style:style>
- Embedding a block of OpenDocument XML
-
The ODT export backend can also read ODT export blocks for OpenDocument XML. Such blocks use the
#+BEGIN_EXPORT odt…#+END_EXPORTconstructs.For example, to create a one-off paragraph that uses bold text, do the following:
#+BEGIN_EXPORT odt <text:p text:style-name="Text_20_body_20_bold"> This paragraph is specially formatted and uses bold text. </text:p> #+END_EXPORT
Customizing tables in ODT export
Override the default table format by specifying a custom table style
with the #+ATTR_ODT line. For a discussion on default formatting of
tables, see Tables in ODT export.
This feature closely mimics the way table templates are defined in the OpenDocument-v1.2 specification(note: OpenDocument-v1.2 Specification).
For quick preview of this feature, install the settings below and export the table that follows:
(setq org-export-odt-table-styles
(append org-export-odt-table-styles
'(("TableWithHeaderRowAndColumn" "Custom"
((use-first-row-styles . t)
(use-first-column-styles . t)))
("TableWithFirstRowandLastRow" "Custom"
((use-first-row-styles . t)
(use-last-row-styles . t))))))#+ATTR_ODT: :style TableWithHeaderRowAndColumn | Name | Phone | Age | | Peter | 1234 | 17 | | Anna | 4321 | 25 |
The example above used Custom template and installed two table
styles TableWithHeaderRowAndColumn and
TableWithFirstRowandLastRow. Important: The OpenDocument styles
needed for producing the above template were pre-defined. They are
available in the section marked Custom Table Template in
OrgOdtContentTemplate.xml (see Factory styles). For adding new
templates, define new styles there.
To use this feature proceed as follows:
-
Create a table template(note: See the
<table:table-template>element of the OpenDocument-v1.2 specification.).A table template is set of
table-cellandparagraphstyles for each of the following table cell categories:- Body
- First column
- Last column
- First row
- Last row
- Even row
- Odd row
- Even column
- Odd Column
The names for the above styles must be chosen based on the name of the table template using a well-defined convention.
The naming convention is better illustrated with an example. For a table template with the name
Custom, the needed style names are listed in the following table.Cell type Cell style Paragraph style Body CustomTableCellCustomTableParagraphFirst column CustomFirstColumnTableCellCustomFirstColumnTableParagraphLast column CustomLastColumnTableCellCustomLastColumnTableParagraphFirst row CustomFirstRowTableCellCustomFirstRowTableParagraphLast row CustomLastRowTableCellCustomLastRowTableParagraphEven row CustomEvenRowTableCellCustomEvenRowTableParagraphOdd row CustomOddRowTableCellCustomOddRowTableParagraphEven column CustomEvenColumnTableCellCustomEvenColumnTableParagraphOdd column CustomOddColumnTableCellCustomOddColumnTableParagraphTo create a table template with the name
Custom, define the above styles in the<office:automatic-styles>…</office:automatic-styles>element of the content template file (see Factory styles). - Define a table style(note: See the attributes
table:template-name,table:use-first-row-styles,table:use-last-row-styles,table:use-first-column-styles,table:use-last-column-styles,table:use-banding-rows-styles, andtable:use-banding-column-stylesof the<table:table>element in the OpenDocument-v1.2 specification.).
To define a table style, create an entry for the style in the
variable org-odt-table-styles and specify the following:
- the name of the table template created in step (1),
- the set of cell styles in that template that are to be activated.
For example, the entry below defines two different table styles
TableWithHeaderRowAndColumn and TableWithFirstRowandLastRow
based on the same template Custom. The styles achieve their
intended effect by selectively activating the individual cell
styles in that template.
(setq org-export-odt-table-styles
(append org-export-odt-table-styles
'(("TableWithHeaderRowAndColumn" "Custom"
((use-first-row-styles . t)
(use-first-column-styles . t)))
("TableWithFirstRowandLastRow" "Custom"
((use-first-row-styles . t)
(use-last-row-styles . t))))))-
Associate a table with the table style.
To do this, specify the table style created in step (2) as part of the
ATTR_ODTline as shown below.#+ATTR_ODT: :style TableWithHeaderRowAndColumn | Name | Phone | Age | | Peter | 1234 | 17 | | Anna | 4321 | 25 |
Validating OpenDocument XML
Sometimes ODT format files may not open due to .odt file corruption.
To verify if such a file is corrupt, validate it against the
OpenDocument Relax NG Compact (RNC) syntax schema. But first the
.odt files have to be decompressed using zip. Note that .odt
files are ZIP archives: File Archives. The contents of
ODT files are in XML. For general help with validation—and
schema-sensitive editing—of XML files: Introduction.
Customize org-odt-schema-dir to point to a directory with
OpenDocument RNC files and the needed schema-locating rules. The ODT
export backend takes care of updating the
rng-schema-locating-files.
Org Export
org export backend creates a normalized version of the Org document in current buffer. The exporter evaluates Babel code (see Evaluating Code Blocks) and removes content specific to other backends.
Org export commands
-
C-c C-e O o(org-org-export-to-org)
Export as an Org file with a .org extension. For myfile.org,
Org exports to myfile.org.org, overwriting without warning.
-
C-c C-e O v(~~)
Export to an Org file, then open it.
Texinfo Export
Texinfo export commands
-
C-c C-e i t(org-texinfo-export-to-texinfo)
Export as a Texinfo file with .texi extension. For myfile.org,
Org exports to myfile.texi, overwriting without warning.
-
C-c C-e i i(org-texinfo-export-to-info)
Export to Texinfo format first and then process it to make an Info
file. To generate other formats, such as DocBook, customize the
org-texinfo-info-process variable.
Texinfo specific export settings
The Texinfo export backend has several additional keywords for customizing Texinfo output. Setting these keywords works similar to the general options (see Export Settings).
-
SUBTITLE
The document subtitle.
-
SUBAUTHOR
Additional authors for the document.
-
TEXINFO_FILENAME
The Texinfo filename.
-
TEXINFO_CLASS
The default document class (org-texinfo-default-class), which must
be a member of org-texinfo-classes.
-
TEXINFO_HEADER
Arbitrary lines inserted at the end of the header.
-
TEXINFO_POST_HEADER
Arbitrary lines inserted after the end of the header.
-
TEXINFO_DIR_CATEGORY
The directory category of the document. Defaults to Misc.
-
TEXINFO_DIR_NAME
The directory name of the document.
This is the short name under which the m command will find your
manual in the main Info directory. It defaults to the base name of
the Texinfo file.
The full form of the Texinfo entry is * DIRNAME: NODE. where NODE
is usually just (FILENAME). Normally this option only provides the
DIRNAME part, but if you need more control, it can also be the full
entry (recognized by the presence of parentheses or a leading ~* ~).
-
TEXINFO_DIR_DESC
The directory description of the document. Defaults to the title of the document.
-
TEXINFO_PRINTED_TITLE
The printed title of the document.
Texinfo file header
After creating the header for a Texinfo file, the Texinfo backend
automatically generates a name and destination path for the Info file.
To override this default with a more sensible path and name, specify
the TEXINFO_FILENAME keyword.
Along with the output's file name, the Texinfo header also contains
language details (see Export Settings) and encoding system as set in
the org-texinfo-coding-system variable. Insert TEXINFO_HEADER
keywords for each additional command in the header, for example:
#+TEXINFO_HEADER: @synindex
Instead of repeatedly installing the same set of commands, define
a class in org-texinfo-classes once, and then activate it in the
document by setting the TEXINFO_CLASS keyword to that class.
Texinfo title and copyright page
The default template for hard copy output has a title page with
TITLE and AUTHOR keywords (see Export Settings). To replace the
regular title with something different for the printed version, use
the TEXINFO_PRINTED_TITLE and SUBTITLE keywords. Both expect raw
Texinfo code for setting their values.
If one AUTHOR line is not sufficient, add multiple SUBAUTHOR
keywords. They have to be set in raw Texinfo code.
#+AUTHOR: Jane Smith
#+SUBAUTHOR: John Doe
#+TEXINFO_PRINTED_TITLE: This Long Title@@inlinefmt{tex,@*} Is Broken in @TeX{}
Copying material is defined in a dedicated headline with a non-nil
COPYING property. The backend inserts the contents within
a @copying command at the beginning of the document. The heading
itself does not appear in the structure of the document.
Copyright information is printed on the back of the title page.
* Legalese :PROPERTIES: :COPYING: t :END: This is a short example of a complete Texinfo file, version 1.0. Copyright \copy 2016 Free Software Foundation, Inc.
Info directory file
The end result of the Texinfo export process is the creation of an
Info file. This Info file's metadata has variables for category,
title, and description: TEXINFO_DIR_CATEGORY, TEXINFO_DIR_NAME,
and TEXINFO_DIR_DESC keywords that establish where in the Info
hierarchy the file fits.
Here is an example that writes to the Info directory file:
#+TEXINFO_DIR_CATEGORY: Emacs #+TEXINFO_DIR_NAME: Org Mode #+TEXINFO_DIR_DESC: Outline-based notes management and organizer
Headings and sectioning structure
The Texinfo export backend uses a pre-defined scheme to convert Org
headlines to equivalent Texinfo structuring commands. A scheme like
this maps top-level headlines to numbered chapters tagged as
@chapter and lower-level headlines to unnumbered chapters tagged as
@unnumbered. To override such mappings to introduce @part or
other Texinfo structuring commands, define a new class in
org-texinfo-classes. Activate the new class with the
TEXINFO_CLASS keyword. When no new class is defined and activated,
the Texinfo export backend defaults to the
org-texinfo-default-class.
If an Org headline's level has no associated Texinfo structuring command, or is below a certain threshold (see Export Settings), then the Texinfo export backend makes it into a list item.
The Texinfo export backend makes any headline with a non-nil
APPENDIX property into an appendix. This happens independent of the
Org headline level or the TEXINFO_CLASS keyword.
The Texinfo export backend creates a menu entry after the Org
headline for each regular sectioning structure. To override this with
a shorter menu entry, use the ALT_TITLE property (see Table of Contents). Texinfo menu entries also have an option for a longer
DESCRIPTION property. Here's an example that uses both to override
the default menu entry:
* Controlling Screen Display :PROPERTIES: :ALT_TITLE: Display :DESCRIPTION: Controlling Screen Display :END:
The text before the first headline belongs to the Top node, i.e.,
the node in which a reader enters an Info manual. As such, it is
expected not to appear in printed output generated from the .texi
file. See The Top Node, for more information.
Indices
The Texinfo export backend recognizes these indexing keywords if used
in the Org file: CINDEX, FINDEX, KINDEX, PINDEX, TINDEX and
VINDEX. Write their value as verbatim Texinfo code; in particular,
{, } and @ characters need to be escaped with @ if they do not
belong to a Texinfo command.
#+CINDEX: Defining indexing entries
For the backend to generate an index entry for a headline, set the
INDEX property to cp or vr. These abbreviations come from
Texinfo that stand for concept index and variable index. The Texinfo
manual has abbreviations for all other kinds of indexes. The backend
exports the headline as an unnumbered chapter or section command, and
then inserts the index after its contents.
* Concept Index :PROPERTIES: :INDEX: cp :END:
Quoting Texinfo code
Use any of the following three methods to insert or escape raw Texinfo code:
Richard STALLMAN commence' GNU. #+TEXINFO: @need800 This paragraph is preceded by... #+BEGIN_EXPORT texinfo @auindex Johnson, Mark @auindex Lakoff, George #+END_EXPORT
Plain lists in Texinfo export
The Texinfo export backend converts unordered and ordered lists in
the Org file using the default command @itemize.
Ordered lists are numbered when exported to Texinfo format. Such
numbering obeys any counter (see Plain Lists) in the first item of
the list. The :enum attribute also let you start the list at a
specific number, or switch to a lettered list, as illustrated here:
1. Alpha 2. Bravo 3. Charlie
The Texinfo export backend by default converts description lists in
the Org file using the default command @table, which results in
a table with two columns. To change this behavior, set :table-type
attribute to either ftable or vtable value. For more information,
see Two-column Tables.
The Texinfo export backend by default also applies a text highlight
based on the defaults stored in org-texinfo-table-default-markup.
To override the default highlight command, specify another one with
the :indic attribute.
Org syntax is limited to one entry per list item. Nevertheless, the
Texinfo export backend can split that entry according to any text
provided through the :sep attribute. Each part then becomes a new
entry in the first column of the table.
The following example illustrates all the attributes above:
#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis - foo, bar :: This is the common text for variables foo and bar.
becomes
@vtable @asis @item foo @itemx bar This is the common text for variables foo and bar. @end table
The :compact attribute is an alternative to the :sep attribute,
which allows writing each entry on its own line. If this attribute is
non-nil and an item in a description list has no body but is
followed by another item, then the second item is transcoded to
@itemx. This example is transcoded to the same output as above.
#+ATTR_TEXINFO: :table-type vtable :indic asis :compact t - foo :: - bar :: This is the common text for variables foo and bar.
Support for this compact syntax can also be enabled for all lists in
a file using the compact-itemx export option, or globally using the
variable org-texinfo-compact-itemx.
The Texinfo export backend also supports two approaches to writing Texinfo definition commands (see Definition Commands). One of them uses description lists and is described below, the other relies on special blocks (see Special blocks in Texinfo export).
Items in a description list in an Org file that begin with Function:
or certain other prefixes are converted using Texinfo definition
commands. This works even if other items in the same list do not have
such a prefix; if necessary a single description list is converted
using multiple tables (such as @vtable) and definition commands
(such as @defun).
- Function: org-texinfo-drawer drawer contents info :: Transcode a DRAWER element from Org to Texinfo.
becomes
@defun org-texinfo-drawer drawer contents info :: Transcode a DRAWER element from Org to Texinfo. @end defun
The recognized prefixes are Command:, Function:, Macro:,
Special Form:, Variable: and User Option:. These are the same
prefixes that appear in the Info file for the respective definition
commands. For example a Function: item in the Org file is converted
to a @defun command in the Texinfo file, which in turn is converted
to a definition prefixed with -- Function: in the Info file.
As a special case the prefix Key: is also recognized. No Texinfo
definition command exists for key bindings and the output in Info
files also lacks the Key: prefix. Even so this special case is
supported because it provides a convenient shorthand, as illustrated
here:
- Key: C-c C-c (do-something) :: This command does something. - User Option: do-something-somehow :: This option controls how exactly ~do-something~ does its thing.
becomes
@table @asis
@item @kbd{C-c C-c} (@code{do-something})
@kindex C-c C-c
@findex do-something
This command does something.
@end table
@defopt do-something-somehow
This option controls how exactly @code{do-something} does its thing.
@end defopt
Command in parentheses, as done above, is optional.
Tables in Texinfo export
When exporting tables, the Texinfo export backend uses the widest
cell width in each column. To override this and instead specify as
fractions of line length, use the :columns attribute. See example
below.
#+ATTR_TEXINFO: :columns .5 .5 | a cell | another cell |
Images in Texinfo export
Insert a file link to the image in the Org file, and the Texinfo
export backend inserts the image. These links must have the usual
supported image extensions and no descriptions. To scale the image,
use :width and :height attributes. For alternate text, use :alt
and specify the text using Texinfo code, as shown in the example:
#+ATTR_TEXINFO: :width 1in :alt Alternate @i{text}
[[#ridt_002epdf][ridt.pdf]]
Quotations in Texinfo export
You can write the text of a quotation within a quote block (see
Paragraphs). You may also emphasize some text at the beginning of
the quotation with the :tag attribute.
#+ATTR_TEXINFO: :tag Warning #+BEGIN_QUOTE Striking your thumb with a hammer may cause severe pain and discomfort. #+END_QUOTE
To specify the author of the quotation, use the :author attribute.
#+ATTR_TEXINFO: :author King Arthur #+BEGIN_QUOTE The Lady of the Lake, her arm clad in the purest shimmering samite, held aloft Excalibur from the bosom of the water, signifying by divine providence that I, Arthur, was to carry Excalibur. That is why I am your king. #+END_QUOTE
Key bindings in Texinfo export
Org does not provide any markup for key bindings that corresponds to
Texinfo's @kbd and @key commands. One way to deal with this is to
fall back to code syntax. ~C-x SPC~, for example, is transcoded to
@code{C-x SPC}.
A better approach is to define and use an Org macro named kbd. To
make that easier the function org-texinfo-kbd-macro is provided,
which is intended to be used like this:
#+macro: kbd (eval (org-texinfo-kbd-macro $1)) Type =C-c SPC=.
which becomes
Type @kbd{C-c @key{SPC}}.
Special blocks in Texinfo export
The Texinfo export backend supports two approaches to writing Texinfo definition commands. One of them is described here, the other in Plain lists in Texinfo export.
The Texinfo export backend converts special blocks to commands with
the same name. It also adds any :options attributes to the end of
the command, as shown in this example:
#+ATTR_TEXINFO: :options org-org-export-to-org ... #+BEGIN_defun A somewhat obsessive function name. #+END_defun
becomes
@defun org-org-export-to-org ... A somewhat obsessive function name. @end defun
A Texinfo example
Here is a more detailed example Org file. See GNU Sample Texts for an equivalent example using Texinfo code.
#+TITLE: GNU Sample 9.8.5
#+SUBTITLE: for version 9.8.5,
#+AUTHOR: A.U. Thor
#+EMAIL: bug-sample@gnu.org
#+OPTIONS: ':t toc:t author:t email:t
#+LANGUAGE: en
#+MACRO: version 2.0
#+MACRO: updated last updated 4 March 2014
#+TEXINFO_FILENAME: sample.info
#+TEXINFO_HEADER: @syncodeindex pg cp
#+TEXINFO_DIR_CATEGORY: Texinfo documentation system
#+TEXINFO_DIR_NAME: sample
#+TEXINFO_DIR_DESC: Invoking sample
#+TEXINFO_PRINTED_TITLE: GNU Sample
This manual is for GNU Sample (version 9.8.5,
).
* Copying
:PROPERTIES:
:COPYING: t
:END:
This manual is for GNU Sample (version 9.8.5,
), which is an example in the Texinfo documentation.
Copyright \copy 2016 Free Software Foundation, Inc.
#+BEGIN_QUOTE
Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License,
Version 1.3 or any later version published by the Free Software
Foundation; with no Invariant Sections, with no Front-Cover Texts,
and with no Back-Cover Texts. A copy of the license is included in
the section entitled "GNU Free Documentation License".
#+END_QUOTE
* Invoking sample
#+PINDEX: sample
#+CINDEX: invoking @command{sample}
This is a sample manual. There is no sample program to invoke, but
if there were, you could see its basic usage and command line
options here.
* GNU Free Documentation License
:PROPERTIES:
:APPENDIX: t
:END:
#+INCLUDE: fdl.org
* Index
:PROPERTIES:
:INDEX: cp
:END:
iCalendar Export
A large part of Org mode's interoperability success is its ability to easily export to or import from external applications. The iCalendar export backend takes calendar data from Org files and exports to the standard iCalendar format.
By default, iCalendar export only includes headings that contain
active timestamps or diary sexps(note: Diary sexp events, except
certain built-in types (see icalendar-export-sexp-enumerate-all),
are exported up to icalendar-export-sexp-enumeration-days into
future.).
If a timestamp contains a time, but doesn't have an explicit end time
(i.e. time range), then by default the exported event will have a
duration of 2 hours, but this can be overridden with
org-agenda-default-appointment-duration.
The iCalendar export backend can also incorporate TODO entries based
on the configuration of the org-icalendar-include-todo variable.
The backend exports plain timestamps as VEVENT, TODO items as
VTODO, and also create events from deadlines that are in non-TODO
items.
The backend uses the deadlines and scheduling dates in Org TODO items
for setting the start and due dates for the iCalendar TODO entry.
Consult the org-icalendar-use-deadline,
org-icalendar-use-scheduled, and
org-icalendar-todo-unscheduled-start variables for more details.
For tags on the headline, the iCalendar export backend makes them
into iCalendar categories. To tweak the inheritance of tags and TODO
states, configure the variable org-icalendar-categories. To assign
clock alarms based on time, configure the org-icalendar-alarm-time
variable.
The iCalendar format standard requires globally unique identifier—or
UID—for each entry. The iCalendar export backend creates UIDs
during export. To save a copy of the UID in the Org file set the
variable org-icalendar-store-UID. The backend looks for the ID
property of the entry for reusing the same UID for subsequent
exports.
Since a single Org entry can result in multiple iCalendar entries—timestamp, deadline, scheduled item, or TODO item—Org adds prefixes to the UID, depending on which part of the Org entry triggered the creation of the iCalendar entry. Prefixing ensures UIDs remains unique, yet enable synchronization programs trace the connections.
-
C-c C-e c f(org-icalendar-export-to-ics)
Create iCalendar entries from the current Org buffer and store them
in the same directory, using a file extension .ics.
-
C-c C-e c a(org-icalendar-export-agenda-files)
Create iCalendar entries from Org files in org-agenda-files and
store in a separate iCalendar file for each Org file.
-
C-c C-e c c(org-icalendar-combine-agenda-files)
Create a combined iCalendar file from Org files in
org-agenda-files and write it to
org-icalendar-combined-agenda-file file name.
The iCalendar export backend includes SUMMARY, DESCRIPTION,
LOCATION, TIMEZONE and CLASS properties from the Org entries
when exporting. To force the backend to inherit the LOCATION,
TIMEZONE and CLASS properties, configure the
org-use-property-inheritance variable.
SUMMARY, LOCATION, and DESCRIPTION properties can define
multi-line summary, location, or description using <PROPERTY>+
syntax (see Property Syntax):
* Meeting at location with multi-line address :PROPERTIES: :LOCATION: Someplace :LOCATION+: Some Street 5 :LOCATION+: 12345 Small Town :END: <2024-01-08 Mon 14:20-15:00>
When Org entries do not have SUMMARY, DESCRIPTION, LOCATION and
CLASS properties, the iCalendar export backend derives the summary
from the headline, and derives the description from the body of the
Org item. The org-icalendar-include-body variable limits the
maximum number of characters of the content are turned into its
description.
The TIMEZONE property can be used to specify a per-entry time zone,
and is applied to any entry with timestamp information. Time zones
should be specified as per the IANA time zone database format, e.g.,
Asia/Almaty. Alternately, the property value can be UTC, to force
UTC time for this entry only.
The CLASS property can be used to specify a per-entry visibility
class or access restrictions, and is applied to any entry with class
information. The iCalendar standard defines three visibility classes:
-
PUBLIC - The entry is publicly visible (this is the default).
-
CONFIDENTIAL - Only a limited group of clients gets access to the event.
-
PRIVATE - The entry can be retrieved only by its owner.
The server should treat unknown class properties the same as
PRIVATE.
The exported iCalendar file can advise clients how often to check for
updates. This duration can be set globally with the
org-icalendar-ttl variable, or on a per-document basis with the
ICAL-TTL keyword. This option should be set using the iCalendar
notation for time durations; consult the docstring of
org-icalendar-ttl for more details.
Exporting to iCalendar format depends in large part on the capabilities of the destination application. Some are more lenient than others. Consult the Org mode FAQ for advice on specific applications.
Other Built-in Backends
Other export backends included with Org are:
ox-man.el: Export to a man page.
To activate such backends, either customize org-export-backends or
load directly with (require 'ox-man). On successful load, the
backend adds new keys in the export dispatcher (see The Export Dispatcher).
Follow the comment section of such files, for example, ox-man.el,
for usage and configuration details.
Advanced Export Configuration
Export hooks
The export process executes two hooks before the actual exporting
begins. The first hook, org-export-before-processing-functions,
runs before any expansions of macros, Babel code, and include keywords
in the buffer. The second hook,
org-export-before-parsing-functions, runs before the buffer is
parsed.
Functions added to these hooks are called with a single argument: the export backend actually used, as a symbol. You may use them for heavy duty structural modifications of the document. For example, you can remove every headline in the buffer during export like this:
(defun my-headline-removal (backend)
"Remove all headlines in the current buffer.
BACKEND is the export backend being used, as a symbol."
(org-map-entries
(lambda ()
(delete-region (point) (line-beginning-position 2))
;; We need to tell `org-map-entries' to not skip over heading at
;; point. Otherwise, it would continue from _next_ heading. See
;; the docstring of `org-map-entries' for details.
(setq org-map-continue-from (point)))))
(add-hook 'org-export-before-parsing-functions #'my-headline-removal)Filters
Filters are lists of functions to be applied to certain parts for a given backend. The output from the first function in the filter is passed on to the next function in the filter. The final output is the output from the final function in the filter.
The Org export process has many filter sets applicable to different
types of objects, plain text, parse trees, export options, and final
output formats. The filters are named after the element type or
object type: org-export-filter-TYPE-functions, where TYPE
is the type targeted by the filter. Valid types are:
| body | bold | babel-call |
| center-block | clock | code |
| diary-sexp | drawer | dynamic-block |
| entity | example-block | export-block |
| export-snippet | final-output | fixed-width |
| footnote-definition | footnote-reference | headline |
| horizontal-rule | inline-babel-call | inline-src-block |
| inlinetask | italic | item |
| keyword | latex-environment | latex-fragment |
| line-break | link | node-property |
| options | paragraph | parse-tree |
| plain-list | plain-text | planning |
| property-drawer | quote-block | radio-target |
| section | special-block | src-block |
| statistics-cookie | strike-through | subscript |
| superscript | table | table-cell |
| table-row | target | timestamp |
| underline | verbatim | verse-block |
Here is an example filter that replaces non-breaking spaces ~ ~ in the
Org buffer with ~ for the LaTeX backend.
(defun my-latex-filter-nobreaks (text backend info)
"Ensure \" \" are properly handled in LaTeX export."
(when (org-export-derived-backend-p backend 'latex)
(replace-regexp-in-string " " "~" text)))
(add-to-list 'org-export-filter-plain-text-functions
'my-latex-filter-nobreaks)
A filter requires three arguments: the code to be transformed, the
name of the backend, and some optional information about the export
process. The third argument can be safely ignored. Note the use of
org-export-derived-backend-p predicate that tests for latex
backend or any other backend, such as beamer, derived from
latex.
Defining filters for individual files
The Org export can filter not just for backends, but also for
specific files through the BIND keyword. Here is an example with
two filters; one removes brackets from time stamps, and the other
removes strike-through text. The filter functions are defined in
a code block in the same Org file, which is a handy location for
debugging.
#+BIND: org-export-filter-timestamp-functions (tmp-f-timestamp)
#+BIND: org-export-filter-strike-through-functions (tmp-f-strike-through)
#+BEGIN_SRC emacs-lisp :exports results :results none
(defun tmp-f-timestamp (s backend info)
(replace-regexp-in-string "&[lg]t;\\|[][]" "" s))
(defun tmp-f-strike-through (s backend info) "")
#+END_SRC
Summary of the export process
Org mode export is a multistep process that works on a temporary copy of the buffer. The export process consists of 4 major steps:
- Process the temporary copy, making necessary changes to the buffer text;
- Parse the buffer, converting plain Org markup into an abstract syntax tree (AST);
- Convert the AST to text, as prescribed by the selected export backend;
- Post-process the resulting exported text.
Process temporary copy of the source Org buffer (note: Unless otherwise specified, each step of the export process only operates on the accessible portion of the buffer. When subtree export is selected (see The Export Dispatcher), the buffer is narrowed to the body of the selected subtree, so that the rest of the buffer text, except export keywords, does not contribute to the export output.):
- Execute
org-export-before-processing-functions(see Export hooks); - Expand
#+includekeywords in the whole buffer (see Include Files); - Remove commented subtrees in the whole buffer (see Comment Lines);
- Replace macros in the whole buffer (see Macro Replacement),
unless
org-export-replace-macrosis nil; -
When
org-export-use-babelis non-nil (default), process code blocks:- Leave code blocks inside archived subtrees (see Internal archiving) as is;
- Evaluate all the other code blocks according to code block headers (see Limit code block evaluation);
- Remove code, results of evaluation, both, or neither according
to
:exportsheader argument (see Exporting Code Blocks).
Parse the temporary buffer, creating AST:
- Execute
org-export-before-parsing-functions(see Export hooks). The hook functions may still modify the buffer; - Calculate export option values according to subtree-specific export
settings, in-buffer keywords,
#+BINDkeywords, and buffer-local and global customization. The whole buffer is considered; - When
org-org-with-cite-processorsis non-nil (default), determine contributing bibliographies and record them into export options (see Citations). The whole buffer is considered; - Execute
org-export-filter-options-functions; -
Parse the accessible portion of the temporary buffer to generate an AST. The AST is a nested list of lists representing Org syntax elements (see Org Element API for more details):
(org-data ... (heading (section (paragraph (plain-text) (bold (plain-text)))) (heading) (heading (section ...))))
Past this point, modifications to the temporary buffer no longer affect the export; Org export works only with the AST;
-
Remove elements that are not exported from the AST:
- Headings according to
SELECT_TAGSandEXCLUDE_TAGSexport keywords;task,inline,archexport options (see Export Settings); - Comments;
- Clocks, drawers, fixed-width environments, footnotes, LaTeX
environments and fragments, node properties, planning lines,
property drawers, statistics cookies, timestamps, etc. according
to
#+OPTIONSkeyword (see Export Settings); - Table rows containing width and alignment markers, unless the
selected export backend changes
:with-special-rowsexport option to non-nil (see Column Width and Alignment); - Table columns containing recalc marks (see Advanced features).
- Headings according to
- Expand environment variables in file link AST nodes according to
the
expand-linksexport option (see Export Settings); - Execute
org-export-filter-parse-tree-functions. These functions can modify the AST by side effects; - When
org-org-with-cite-processorsis non-nil (default), replace citation AST nodes and#+print_bibliographykeyword AST nodes as prescribed by the selected citation export processor (see Citation export processors).
Convert the AST to text by traversing the AST nodes, depth-first:
- Convert the leaf nodes (without children) to text as prescribed
by "transcoders" in the selected export backend
(note: See transcoders and
:translate-alistin the docstrings oforg-export-define-backendandorg-export-define-derived-backend.); - Pass the converted nodes through the corresponding export filters (see Filters);
- Concatenate all the converted child nodes to produce parent node contents;
- Convert the nodes with children to text, passing the nodes themselves and their exported contents to the corresponding transcoders and then to the export filters (see Filters).
Post-process the exported text:
- Post-process the converted AST, as prescribed by the export
backend. (note: See
inner-templatein the docstring oforg-export-define-backend.) This step usually adds generated content (like Table of Contents) to the exported text; - Execute
org-export-filter-body-functions; - Unless body-only export is selected (see The Export Dispatcher), add the necessary metadata to the final document, as prescribed by the export backend. Examples: Document author/title; HTML headers/footers; LaTeX preamble;
- When
org-org-with-cite-processorsis non-nil (default), add bibliography metadata, as prescribed by the citation export processor; - Execute
org-export-filter-final-output-functions.
Extending an existing backend
Some parts of the conversion process can be extended for certain elements to introduce a new or revised translation. That is how the HTML export backend was extended to handle Markdown format. The extensions work seamlessly so any aspect of filtering not done by the extended backend is handled by the original backend. Of all the export customization in Org, extending is very powerful as it operates at the parser level.
For this example, make the ascii backend display the language used
in a source code block. Also make it display only when some attribute
is non-nil, like the following:
#+ATTR_ASCII: :language t
Then extend ASCII backend with a custom "my-ascii" backend.
(defun my-ascii-src-block (src-block contents info)
"Transcode a SRC-BLOCK element from Org to ASCII.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(if (not (org-export-read-attribute :attr_ascii src-block :language))
(org-export-with-backend 'ascii src-block contents info)
(concat
(format ",--[ %s ]--\n%s`----"
(org-element-property :language src-block)
(replace-regexp-in-string
"^" "| "
(org-element-normalize-string
(org-export-format-code-default src-block info)))))))
(org-export-define-derived-backend 'my-ascii 'ascii
:translate-alist '((src-block . my-ascii-src-block)))
The my-ascii-src-block function looks at the attribute above the
current element. If not true, hands over to ascii backend. If
true, which it is in this example, it creates a box around the code
and leaves room for the inserting a string for language. The last
form creates the new backend that springs to action only when
translating src-block type elements.
To use the newly defined backend, evaluate the following from an Org buffer:
(org-export-to-buffer 'my-ascii "*Org MY-ASCII Export*")Further steps to consider would be an interactive function, self-installing an item in the export dispatcher menu, and other user-friendly improvements. See <https://orgmode.org/worg/dev/org-export-reference.html> for more details.
Export Region
Some export backends include commands to convert a region of Org formatted text to another format, such as HTML or LaTeX. The conversion replaces the original source. Here are such commands:
-
org-export-region-to-ascii
Convert the selected region into ASCII.
-
org-export-region-to-utf8
Convert the selected region into UTF-8.
-
org-export-region-to-html
Convert the selected region into HTML.
-
org-export-region-to-latex
Convert the selected region into LaTeX.
-
org-export-region-to-texinfo
Convert the selected region into Texinfo.
-
org-export-region-to-md
Convert the selected region into Markdown.
The in-place conversion is particularly handy for quick conversion of
tables and lists in non-Org buffers. For example, in an HTML buffer,
write a list in Org syntax, select it, and convert it to HTML with
M-x org-html-convert-region-to-html.
Footnotes
-
6
Many desktops intercept
M-TABto switch windows. UseC-M-iorESC TABinstead.Backrefs: 1
-
42
For export to LaTeX format—or LaTeX-related formats such as Beamer—, the
org-latex-package-alistvariable needs further configuration. See LaTeX specific export settings.Backrefs: 1
-
43
At the moment, some export backends do not obey this specification. For example, LaTeX export excludes by default every unnumbered headline from the table of contents, unless you set the custom variable
org-latex-toc-include-unnumberedtotor add:UNNUMBERED: tocto the section's properties.Backrefs: 1
-
44
Note that
org-link-search-must-match-exact-headlineis locally bound to non-nil. Therefore,org-link-searchonly matches headlines and named elements.Backrefs: 1
-
45
Since commas separate the arguments, commas within arguments have to be escaped with the backslash character. So only those backslash characters before a comma need escaping with another backslash character.
Backrefs: 1
-
46
If
BEAMER_ENVis set, Org export addsB_environmenttag to make it visible. The tag serves as a visual aid and has no semantic relevance.Backrefs: 1
-
47
Please note that exported formulas are part of an HTML document, and that signs such as
<,>, or&have special meanings. See MathJax TeX and LaTeX in HTML documents.Backrefs: 1
-
48
This does not allow setting different bibliography compilers for different files. However, "smart" LaTeX compilation systems, such as latexmk, can select the correct bibliography compiler.
Backrefs: 1