Make sure that you read this document in its raw source form. If you are looking at a rendered representation, e.g. in github, you will not be able to see the org source code.
- Emacs version
Emacs version: GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-12-30 org version: 9.1.9
- LaTeX version
pdfTeX 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) kpathsea version 6.2.1 Copyright 2015 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). There is NO warranty. Redistribution of this software is covered by the terms of both the pdfTeX copyright and the Lesser GNU General Public License. For more information about these matters, see the file named COPYING and the pdfTeX source. Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX). Compiled with libpng 1.6.17; using libpng 1.6.17 Compiled with zlib 1.2.8; using zlib 1.2.8 Compiled with poppler version 0.41.0
- Org removes some of the intermediate files if the variable
org-latex-remove-logfiles
is set to true. So, for debugging, it makes sense to set it to nil. I have done this locally in this document’s local variables. - Use
pdflatex
with the option synctex=1. This option creates*.synctex.gz
files which can be used by a viewer to jump to the respective text in the Tex file upon mouse clicking within the PDF. This is very useful to check the resulting LaTeX code when doing tests. Here is my own setting of theorg-latex-pdf-process
emacs configuration variable.(setq org-latex-pdf-process (let ((cmd (concat "pdflatex -shell-escape -interaction nonstopmode" " --synctex=1" " -output-directory %o %f"))) (list cmd "cd %o; if test -r %b.idx; then makeindex %b.idx; fi" "cd %o; bibtex %b" cmd cmd)))
- Nice link for mathematical symbols on wikipedia:
the following example uses escaped angular parentheses quoting \[...\]
. This is short for putting the equation
into a displaymath environment
\begin{displaymath} ... \end{displaymath}
The rendered equation: \[coresextrapol = coresintern2013 ⋅ offl\% ⋅ \frac{gf ⋅ (volumeuser + volumeintern)}{volumeintern}\]
Note: You should not use the double dollar quoting $$...$$
(q.v. this stackexchange answer) and the deadly sins description.
Here follows an example for an equation embedded in the text. This is reached by either using the escaped round
parentheses syntax \(...\)
or the single dollar sign syntax $...$
.
$coresextrapol = coresintern2013 ⋅ offl\% ⋅ \frac{gf ⋅ (volumeuser + volumeintern)}{volumeintern}$
The text continues after the formula.
Here follows a numbered equation that also can be referenced like in the following parentheses (eq \ref{eq_1}). Note that we have to rely here on standard latex syntax, since org mode does not offer equations as a native element that we can mark up with #+NAME tags, etc. \begin{equation} \label{eq_1} coresextrapol = coresintern2013 ⋅ offl\% ⋅ \frac{gf ⋅ (volumeuser + volumeintern)}{volumeintern} \end{equation}
from an article by Stefaan Lippens on on using textnormal for including normal text correctly in a math environment.
\begin{eqnarray*}
∫_1^9 x dx & & \textrm{this is textrm}
∑_1^9 y & & \textsf{this is textsf}\
∏_1^9 z & & \textnormal{this is textnormal}
\end{eqnarray*}
Only textnormal will guarantee that the text appears in the default font of the document.
I can reference the figure like this: Fig. fig_simplegraph1.
Note
- there must be no empty line between the picture’s link and the meta definitions for name, caption, etc.
- The figure must have a caption if it is to be included in a list
of figures (see
\listoffigures
statement at the end of the document), because the caption will trigger exporting to a LaTeX figure environment. - Without a caption, an image can still be exported as a floating
image by using the
:float
option. - The OPTION
tex:t
must be set for references to work.
Specifier | Permission |
---|---|
h | Place the float here, i.e., approximately at the same point it occurs in the |
source text (however, not exactly at the spot) | |
t | Position at the top of the page. |
b | Position at the bottom of the page. |
p | Put on a special page for floats only. |
\! | Override internal parameters LaTeX uses for determining “good” float positions. |
H | Places the float at precisely the location in the LaTeX code. Requires the |
float package, e.g., \textbackslash{}usepackage{float}. This is somewhat equivalent to h!. |
A pdf can be included the same way, e.g. by specifying
#+ATTR_LATEX: :options page=10 :width 10cm [[file:myfig.pdf]]
q.v. my my plantuml example documentation.
- Documentation
- Very nice overview: https://en.wikibooks.org/wiki/LaTeX/Tables
Some interesting tips for \myindex{booktab style tables} by M. Püschel.
Booktabs can be turned on by default for all tables by setting this variable for the document or globally:
org-latex-tables-booktabs: t
Whether table captions appear above or below the table can be configured using this variable setting:
org-latex-table-caption-above: nil
Column 1 | Column 2 | Column 3 | Column 4 |
---|---|---|---|
1 | 10 | 100 | 1000 |
2 | 11 | 101 | 1001 |
3 | 12 | 102 | 1002 |
4 | 13 | 103 | 1003 |
5 | 14 | 104 | 1004 |
15 | 60 | 510 | 5010 |
Column 1 | Column 2 | Column 3 | Column 4 |
---|---|---|---|
1 | 10 | 100 | 1000 |
2 | 11 | 101 | 1001 |
3 | 12 | 102 | 1002 |
4 | 13 | 103 | 1003 |
5 | 14 | 104 | 1004 |
15 | 60 | 510 | 5010 |
Use math or inline math together with array environment.
Here we use the simple math mode
Column 1 | Column 2 |
---|---|
sin(x) | tan(x) |
This uses the inline-math
mode
Column 1 | Column 2 |
---|---|
sin(x) | tan(x) |
The font size is determined by the :font
switch in the #+ATTR_LATEX
line.
Column 1 | Column 2 |
---|---|
Some text | Some other text |
10 | 20 |
Sidenote:
- When a caption is used, the latex export uses a
table
environment. - The previous captionless table generates a
tabular
environment.
Column 1 | Column 2 |
---|---|
Some text | Some other text |
10 | 20 |
Column 1 | Column 2 |
---|---|
Some text | Some other text |
10 | 20 |
Column 1 | Column 2 |
---|---|
Some text | Some other text |
10 | 20 |
Column 1 | Column 2 |
---|---|
Some text | Some other text |
10 | 20 |
Use the float: sideways
ATTR option (The float: sidewaystable=
has
been deprecated since Org 8.3, q.v. info:org#Tables in LaTeX export)
Using the sidewaystable together with a :placement [H]
specifier
requires that the rotfloat
package is loaded.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 |
---|---|---|---|---|---|
1 | 10 | 100 | 1000 | example | result |
2 | 11 | 101 | 1001 | example | result |
3 | 12 | 102 | 1002 | example | result |
4 | 13 | 103 | 1003 | example | result |
5 | 14 | 104 | 1004 | example | result |
6 | 15 | 105 | 1005 | example | result |
7 | 16 | 106 | 1006 | example | result |
This text comes after the sidewaystable (we want to check whether the placement modifier was observed).
Even though in the info documentation it reads: “Note: :placement
is ignored for :float sideways tables.”, the modifier [H]
is
observed, as can be confirmed in the resulting TeX code.
Use the \myindex{longtabu} environment. This requires that you have loaded the \myindex{tabu} and \myindex{longtable} packages.
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
103 | repetition ahead |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
101 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
102 | bla bla |
100 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
98 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
96 | bla bla |
94 | repetition ahead |
92 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
90 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
88 | bla bla |
86 | repetition ahead |
84 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
82 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
80 | bla bla |
78 | repetition ahead |
76 | Some extremely long sentence which surely needs a linebreak if I add some additional words like these |
74 | Some other extremely long sentence which surely needs a linebreak if I add some additional words like these |
72 | bla bla |
A very nice reference for color in tables is proviced by Xavier on the texblog.org: https://texblog.org/2018/01/15/color-table-series-part-2-xcolor-package/
One can use the \rowcolors
command to define coloring of alternating rows. In
front of the table use the following
#+LATEX: \rowcolors[]{2}{blue!10}{blue!25}
The arguments translate to
[2]
start coloring in the second row{blue!10}{blue!25}
definition of the two colors for odd and even rows according to the xcolors package
In order to prevent spillover of the rowcolors definition into later table, I
wrap the whole table in #+LATEX: {
and #+LATEX: }
definitions.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 |
---|---|---|---|---|---|
1 | 10 | 100 | 1000 | example | result |
2 | 11 | 101 | 1001 | example | result |
3 | 12 | 102 | 1002 | example | result |
4 | 13 | 103 | 1003 | example | result |
5 | 14 | 104 | 1004 | example | result |
6 | 15 | 105 | 1005 | example | result |
7 | 16 | 106 | 1006 | example | result |
This needs the tabu and xcolor packages to be loaded. Use the LaTeX command
\taburowcolors
to define the colors right before the table.
#+LATEX: \taburowcolors[2]2{lightgray..white}
The options in this command translate to
[2]
start coloring in 2nd row2
: use 2 colors (so, if set to 2 then it is just alternating){lightgray..white}
defines the first and last color in the color range. This is a color series definition provided by the xcolor package.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 |
---|---|---|---|---|---|
1 | 10 | 100 | 1000 | example | result |
2 | 11 | 101 | 1001 | example | result |
3 | 12 | 102 | 1002 | example | result |
4 | 13 | 103 | 1003 | example | result |
5 | 14 | 104 | 1004 | example | result |
6 | 15 | 105 | 1005 | example | result |
7 | 16 | 106 | 1006 | example | result |
Booktabs
style does not mix well with this. The caption is too near
to the table ruler, so here some work would need to be invested to
get an aesthetically pleasing layout.
Column 1 | Column 2 | Column 3 | Column 4 | Column 5 | Column 6 |
---|---|---|---|---|---|
1 | 10 | 100 | 1000 | example | result |
2 | 11 | 101 | 1001 | example | result |
3 | 12 | 102 | 1002 | example | result |
4 | 13 | 103 | 1003 | example | result |
5 | 14 | 104 | 1004 | example | result |
6 | 15 | 105 | 1005 | example | result |
7 | 16 | 106 | 1006 | example | result |
Here, for comparison, a colored table produced by an inline LaTeX fragment. Q.v. this stackexchange discussion to understand the color series.
Note: I need to do some more testing to get a better understanding of how the color ranges are defined. E.g. here in the 5th row there is suddenly a yellow color pouring in.
Radio tables allow to send a modified representation of an org source table to a target location. Here, we send the same table to the 2 target locations below, once using a send function to LaTeX and once to an org function.
This can be useful e.g. if one wants to skip some columns that are only used for intermediate results.
First test: Exporting to a native LaTeX table
Second test: Exporting to an org mode table
Month | items | items per day |
---|---|---|
Jan | 55 | 2.4 |
Feb | 16 | 0.8 |
March | 278 | 12.6 |
In order to get nice source code formatting and markup, one needs to add the minted package. I add here the relevant excerpt from my emacs initialization file (listing listing-minted-config), which also serves as a first lisp code example
TODO: I was not yet able to figure out how to force org to place
the source code listing exactly here in the text. While the
documentation accepts a :float t
attribute (and every source
block with a caption automatically becomes a float), the placement
modifier seems not to get translated
#+ATTR_LaTeX: :float t :placement [H]
(eval-after-load "ox-latex"
'(progn
;; we want source code blocks to be syntax colored when exporting
;; via latex. We configure latex minted which uses python
;; pygments
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-listings 'minted)
;; define mappings of src-code-language to lexer that minted shall use
;;(add-to-list 'org-latex-listings-langs '(ipython "Python"))
(add-to-list 'org-latex-minted-langs '(ipython "python"))))
I also add listing listing-example-c as an example for C code markup:
#include "stdlib.h"
int main(int argc,char **argv) {
printf("Hello World");
exit(0);
}
Text Example Huge
Text Example huge
Text Example LARGE
Text Example Large
Text Example large
Text Example normalsize
Text Example small
Text Example footnotesize
Text Example scriptsize
Text Example tiny
Examples for \myindex{footnotes}: This is a text with a \myindex{footnote} 1. The footnote will be displayed on the bottom of the current page. One can also place all footnotes in a separate chapter called footnotes at the end of the org file2.
Footnotes definitions can be placed within an org section using the
[fn:1]
syntax and observing that no leading indentation is
allowed on such a line. Alternatively the footnotes can be
collected in a special section called “Footnotes”. I recommend
reading the respective INFO entry (e.g. there is also the
possibility to define footnotes inline). When using C-c C-x f
to
insert footnotes a lot of the work is taken over by org itself
(also allows footnote renumbering, etc.). One can jump between the
footnote reference and its definition by the usual C-c C-o
combination.
\myindex{Margin notes} can be inserted by directly inlining the LaTeX command
as demonstrated in the source code for this section. By default the margin notes are justified. This often looks awkward. Using this stackexchange answer, I define a macro which yields:
I like the margin notes to be left aligned instead of being justified.
Here, we show the usage of links to the text sections: Examples for References to figures are also found in chapter Figures, to tables in chapter Tables, and to equations in chapter Equations.
Other references
- Figures can be referenced like this: Fig. fig_simplegraph1.
- These are references to table tblDefault and table tblBooktabs.
- And an example of an equation reference: eq \ref{eq_1}. This reference
requires latex syntax and a latex label as target. All the other
links work based on org link syntax can use the name given to
the elements via a leading
#+NAME:
line.
One can use an org source block that contains a named source block and the matching named results tag, and then put latex instructions inside as shown in this example (thanks for the idea to a mail from Eric S Fraga)
- Hyperlink formatting
- described in the LaTeX hyperref manual.
- This is an example of how to get links that are not framed by red
rectangles, but just have a blue font color
#+LaTeX_HEADER: \hypersetup{colorlinks=true, linkcolor=blue}
- Building a LaTeX Document Class
Must be solved by including LaTeX source commands:
- Requires in the preamble
\usepackage{makeidx}
\makeindex
- Mark up words by
\index{word}
- At the location where the index should apear, use
\printindex
- to render the document, a call to the
makeindex
binary needs to be added in the build command. I use the following definition in myinit.el
.(setq org-latex-pdf-process (let ((cmd (concat "pdflatex -shell-escape -interaction nonstopmode" " -output-directory %o %f"))) (list cmd "cd %o; if test -r %b.idx; then makeindex %b.idx; fi" cmd cmd)))
Some important org references that also display that citations directly following each other will be combined cite:schulte2012multi cite:dominik2010org. And another single reference cite:feichtinger1997direct.
The #+BIBLIOGRAPHY:
command inserts the reference list at the
location where it is placed. It requires the name of the bib-file
(without .bib extension) and the name of a style (e.g. plain).
If no citations are created, make sure that the bibliography file is really found. You may have to run “bibtex myfile.aux” yourself, and for that you need to make sure that the AUX file is not removed after org runs (q.v. *Debugging section).
For HTML exports one can also pass options to the bibtex2html
binary (look at the comments section of ox-bibtex.el
and also the
bibtex2html man page).
option | functionality |
---|---|
-d | sort by date |
-a | sort as BibTeX (usually by author) default |
-u | unsorted i.e. same order as in .bib file |
-r | reverse the sort |
-t | limit to entries cited in document |
Multiple options can be combined as follows:
option:-d option:-r
To get the citations correctly processed rendered, one needs to add a bibtex invocation to the LaTeX command chain:
(setq org-latex-pdf-process
(let
((cmd (concat "pdflatex -shell-escape -interaction nonstopmode"
" --synctex=1"
" -output-directory %o %f")))
(list cmd
"cd %o; if test -r %b.idx; then makeindex %b.idx; fi"
"cd %o; bibtex %b"
cmd
cmd)))
To just produce a bibliography of all items in the bib file, one can
use the following LaTeX snippet. The \nocite{*}
command includes
an item that has not been cited in the document; a star matches all
documents, so all get included (q.v. this link).
#+BEGIN_LATEX \documentstyle{amsart} \begin{document} \nocite{*} \bibliographystyle{amsplain} \bibliography{bib-filename} \end{document} #+END_LATEX
1 This is the footnote text
2 this is another footnote