Exporting
Table of Contents
Export as HTML, Markdown, LaTeX and Plain Text (Export…,
Ctrl+Alt+E, the File menu, or the palette) write the document beside
its file, or where #+EXPORT_FILE_NAME says, unsaved changes
included. The result is what Emacs's Org exporter writes: #+OPTIONS,
#+INCLUDE, macros, footnotes, tables, links and source blocks behave
as there. Kalem does not run code: source blocks show their code and
the results already in the file.
Export… lists the formats and three switches, saved in your settings
when you change them: Body only (export.body_only) writes the body
without the page around it; Open after exporting (export.open_after)
opens the exported file in the system's application; Formulas
(export.math) draws formulas in HTML as MathJax or as SVG pictures,
unless the document's #+OPTIONS: tex: says otherwise. Export as
GitHub Markdown writes Markdown as GitHub shows it (pipe tables,
fenced code, ~~strike~~), where Export as Markdown writes what
Emacs's ox-md writes. Export Subtree as HTML, Markdown, LaTeX
and PDF (LaTeX) export only the subtree the cursor is in, with its
EXPORT_ properties, as Emacs's C-c C-e C-s does.
1. LaTeX, PDF and printing
The LaTeX file is Emacs's too: #+LATEX_CLASS, #+LATEX_CLASS_OPTIONS,
#+LATEX_HEADER and #+ATTR_LATEX work as in Org's manual. Export
as PDF (LaTeX) writes the LaTeX file and compiles it in the
background with latexmk, else the TeX engine (pdflatex, or the one
#+LATEX_COMPILER names) or tectonic, whichever is installed; when
LaTeX stops on an error, the status line gives it at the line of the
Org file it comes from. Print (File menu) compiles the PDF the same
way and hands it to the system's print dialog; in a terminal without
a display the status line names the PDF for lp.
2. Word and other formats, through pandoc
With pandoc installed, Export as Word, OpenDocument, EPUB and
RTF write those formats, and Import as Org (File menu) turns a
Word, OpenDocument, Markdown, HTML, EPUB or RTF file into an Org file
beside it, its pictures in a NAME_assets folder, with pandoc's
stray anchors removed and its tables aligned. Citations go through
pandoc's --citeproc with the file #+BIBLIOGRAPHY: names, and a
link to a figure, table or equation gets the label the other exports
print. examples/book is a sample book to start from, with chapters
pulled in by #+INCLUDE, a computed table, an equation, citations,
footnotes and cross references; it exports to every format without
errors.
3. Citations
Citations ([cite:@key], [cite/t:@key] and the other styles and
variants of Org's manual) come out as Org's basic processor writes
them, "(Author, Year)", "Author (Year)", numbers, or a footnote for
the note and ft styles, with the keys looked up in the files
#+BIBLIOGRAPHY: names (BibTeX, BibLaTeX or CSL-JSON);
#+PRINT_BIBLIOGRAPHY: becomes the list of works cited, and
#+CITE_EXPORT: basic numeric (or plain) chooses its style.
#+CITE_EXPORT: csl apa uses a Citation Style Language style instead:
one of the styles Kalem ships (apa, ieee, mla,
chicago-author-date, chicago-notes, nature, vancouver and about
eighty more) or a .csl file beside the document; [cite:see @key
p. 12] passes "p. 12" as the locator, and #+LANGUAGE chooses the
style's terms. For LaTeX, #+CITE_EXPORT: biblatex and #+CITE_EXPORT:
natbib leave citations to those packages, as Org does, with the
style as the second word (biblatex authoryear, natbib plainnat);
Export as PDF then runs biber or bibtex between LaTeX runs.
Plain text is filled to 72 columns as Emacs fills it, with underlined
titles and ASCII tables; export.text_charset = "utf-8" uses UTF-8
lines, bullets and quotes instead.
4. From the command line
kalem export notes.org # notes.html kalem export notes.org --to md -o - # Markdown to standard output kalem export notes.org --to gfm # GitHub Markdown kalem export notes.org --subtree Tasks # only the subtree "Tasks" (or #CUSTOM_ID) kalem export *.org --body-only # only the body of each page kalem export paper.org --to latex # paper.tex kalem export notes.org --to txt # plain text, 72 columns (utf8 for UTF-8) kalem export paper.org --to pdf # paper.pdf; errors as paper.org:LINE: … kalem export report.org --to docx # also odt, epub, rtf (pandoc) kalem import report.docx # report.org, cleaned up (pandoc) kalem export paper.org --to latex --source-lines # %% org:LINE comments