#+STARTUP: content

If exporting only a subtree; the heading will be the document title if
not overwritten by the property =EXPORT_TITLE=.

Inside emacs org use =org-ref-list-of-tables= and
=org-ref-list-of-figures= to open a list of tables or figures.

* Requirements
=latexmk=: for glossary and acronym add the following to =~/.config/latexmk/latexmkrc=
#+begin_src conf
add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
$clean_ext .= " acr acn alg glo gls glg";
sub makeglossaries {
  my ($base_name, $path) = fileparse( $_[0] );
  my @args = ( "-q", "-d", $path, $base_name );
  if ($silent) { unshift @args, "-q"; }
  return system "makeglossaries", "-d", $path, $base_name;
}

add_cus_dep('glo', 'gls', 0, 'makeglo2gls');
sub makeglo2gls {
    system("makeindex -s '$_[0]'.ist -t '$_[0]'.glg -o '$_[0]'.gls '$_[0]'.glo");
}

add_cus_dep('acn', 'acr', 0, 'makeacn2acr');
sub makeacn2acr {
    system("makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"");
}
#+end_src

* Preamble
The preamble is defined by Org-keywords.

First line of the file can be used to define the spelling language of
the document.
#+begin_src org
# -*- ispell-local-dictionary: "english" -*-
# -*- ispell-local-dictionary: "german" -*-
#+end_src

The title (also used in pdf metadata field)
#+begin_src org
#+TITLE: The title
#+end_src

The subtitle
#+begin_src org
#+SUBTITLE: The subtitle
#+end_src

The date
#+begin_src org
#+DATE: May 16, 2022
#+DATE: \today
#+end_src

Author(s) (also used in pdf metadata field)
#+begin_src org
#+AUTHOR: Max Muster
#+AUTHOR: Max Muster and Maxi Muster
#+AUTHOR: Max Muster, Maxi Muster
#+end_src

Email(s)
#+begin_src org
#+EMAIL: max.muster@example.com
#+EMAIL: max.muster@example.com and maxi.muster@example.com
#+EMAIL: max.muster@example.com, maxi.muster@example.com
#+end_src

Keywords (also used in pdf metadata field)
#+begin_src org
#+KEYWORDS: manual, examples
#+end_src

Export options
#+begin_src org
# draft:t - display a block at the end of a line, which is too long (indication bad line break)
#+OPTIONS: draft:t
#+end_src

Language (en default)
#+begin_src org
#+LANGUAGE: en
#+LANGUAGE: de
#+end_src

Description (also used in pdf metadata field: subject). Keyword can be
used multiple times to extend the description.
#+begin_src org
#+DESCRIPTION: Multiline
#+DESCRIPTION: description
#+end_src

Type of the document. (The abstract template uses or can reference to
the keyword variable 'document_type' via the macro 'title-name')
#+begin_src org
#+DOCUMENT_TYPE: Seminararbeit
#+end_src

Overwrite references setup
#+begin_src org
#+BIBLATEX: \usepackage[backend=biber,citestyle=alphabetic,bibstyle=authoryear,sorting=nyt,sortcase=false]{biblatex}\setlength{\bibhang}{0pt}\addbibresource{references.bib}
#+end_src

Additional peamble setup
#+begin_src org
#+LATEX_HEADER_EXTRA: \usepackage{layout}
#+end_src

* Text
** Headline
#+begin_src org
,* 1st level heading
,** this is 2nd level heading
,*** this is 3rd level heading
#+end_src

To have a headline in Org but not in an export set the header tag
=:ignore:=.
#+begin_src org
,* Header not listed in toc but its content                           :ignore:
bla bla bla
#+end_src

To have a headline with its content in Org but not in an export set
the header tag =:noexport:=.
#+begin_src org
,* Section not exported                                             :noexport:
bla bla bla, this will not be exported
#+end_src

To have a headline unnumbered in the table of contents set the header
property =:UNNUMBERED: t=.
#+begin_src org
,* Header listed unnumbered
:PROPERTIES:
:UNNUMBERED: t
:END:
bla bla bla
#+end_src

To have a headline in a LaTeX export started on a new page use the
header property =:CLEARPAGE: t=.
#+begin_src org
,* Section will start on a clear page (LaTeX)
:PROPERTIES:
:CLEARPAGE: t
:END:
bla bla bla
#+end_src

** Formatting
#+begin_example
  *bold*
  /italic/
  _underlined_
  =verbatim=
  ~code~
  +strike-through+
  X_{subscript}
  X^{superscript}
#+end_example

** Line break
#+begin_example
  Hello, \\  (enforce line break within a paragraph)
  World.
#+end_example

** Color
- via link-decorator : [[color:#c09000][colored text in orange]]
- via makro : {{{color(002659,colored text in darkblue)}}}

** Glyphs & More
- in text
  - =\LaTeX{}= LaTeX (do not miss the brackets to get an whitespace after)
  - =\euro{}= €
  - =\leftarrow= ←
  - =\rightarrow= →
  - =\uparrow= ↑
  - =\downarrow= ↓
- in math
  - =\ho{}= (hochstellen) for math mode similar to =^{}= but sets roman font
  - =\ti{}= (tiefstellen) for math mode similar to =_{}= but sets roman font
  - =\rom{3}= iii
  - =\Rom{3}= III

** Makros
Active Org macros (=org-macro-templates=):
- Org built-ins (see
  https://www.gnu.org/software/emacs/manual/html_node/org/Macro-Replacement.html)
  - ={{{title}}}= :: {{{title}}}
  - ={{{author}}}= :: {{{author}}}
  - ={{{email}}}= :: {{{email}}}
  - ={{{date}}}= :: {{{date}}}
  - ={{{time(FORMAT)}}}= :: {{{time(%h)}}} : format see function =format-time-string=
  - ={{{input-file}}}= :: {{{input-file}}}
  - ={{{modification-time(FORMAT[,VC])}}}= ::
    {{{modification-time(%Y-%m-%d %a %H:%M:%S)}}} : vc is a toogle
    (nil,t) to retrieve the time from version control system
  - ={{{keyword(KEYWORD)}}}= :: {{{keyword(SUBTITLE)}}}
  - ={{{property(PROPERTY-NAME[,LOCATION])}}}= ::
    {{{property(CUSTOM_ID)}}} : optional location see function
    =org-link-search=
    (https://www.gnu.org/software/emacs/manual/html_node/org/Search-Options.html)
  - ={{{n}}}= ={{{n(COUNTER[,ACTION])}}}= :: {{{n}}} {{{n(ii)}}}
    {{{n(ii,-)}}} {{{n(ii,5)}}} {{{n(ii)}}} {{{n(i,x)}}} : increment
    counter name, if optional action is '-' do not increment, if
    number set to number, if somthing else reset to 1
- custom
  - ={{{textsc(text)}}}= :: {{{textsc(Gauß)}}}
  - ={{{color(hex,text)}}}= :: {{{color(884488,text)}}}
  - ={{{kbd(text)}}}= :: {{{kbd(text)}}}
  - ={{{highlight(text[,options])}}}= :: {{{highlight(text highlighted
    in default color)}}}, {{{highlight(text highlighted in
    red,red)}}}, {{{highlight(text highlighted in green and blue
    borders,green,blue)}}}

* Links
#+begin_example
[[http://example.com/]]
[[http://example.com/][description]]
#+end_example

* Rule
a horizontal rule, 5 or more only dashes
-----

* Blocks
Easy Templates (enter =<x[TAB]=)
- s #+BEGIN_SRC ... #+END_SRC
- e #+BEGIN_EXAMPLE ... #+END_EXAMPLE
- q #+BEGIN_QUOTE ... #+END_QUOTE
- v #+BEGIN_VERSE ... #+END_VERSE
- c #+BEGIN_CENTER ... #+END_CENTER
- l #+BEGIN_EXPORT latex ... #+END_EXPORT
- L #+LATEX:
- h #+BEGIN_EXPORT html ... #+END_EXPORT
- H #+HTML:
- a #+BEGIN_EXPORT ascii ... #+END_EXPORT
- A #+ASCII:
- I #+INCLUDE: file
- I #+INCLUDE: interactive version

** Lists
Org reference: https://orgmode.org/manual/Plain-lists-in-LaTeX-export.html#Plain-lists-in-LaTeX-export

Inline list:
Some ways to say "Hello":
#+ATTR_LATEX: :environment itemize*
#+ATTR_LATEX: :options [label={}, itemjoin={,}, itemjoin*={\ and}]
- Hola
- Bonjour
- Guten Tag.

Unordered list
- One
  - Two
    - Three
      - Four
      * Four 2
      + Four 3

Ordered list
1. One
2. Two
   1. Two one
   2. Two two
      1. Two two one
      2. Two two two
         1. Two two two one
20. [@20] Test
21. foo
22. baz

List with custom item spacing
#+ATTR_LATEX: :options [itemsep=5pt]
- One
- Two
- Three
- Four
- Five

Description list
- an item :: a description
  
** Tables, Figures, Listings

#+CAPTION[Optional short version for the lot, lof, lol]: Caption of the table, figure or listing

** Tables
Default tables having a placement atrribute set to =[htbp]= (still
allows to find a sweet spot).  For a 'here in place' placement use
=:placement [h]= (approximately at the same point) =:placement [H]=
(precisely at point, will deactivate settings from the =float= package,
similar to =[h!]=)

Org reference:
https://www.gnu.org/software/emacs/manual/html_node/org/Tables-in-LaTeX-export.html

Alignment using column type  =#+ATTR_LATEX: :align xxx=
- built-in
  - l: left-aligned cells
  - c: center-aligned cells
  - r: right-aligned cells
  - p{width}: top-aligned cells with fixed width
  - m{width}: middle-aligned cells with fixed width
  - b{width}: bottom-aligned cells with fixed width
  - >{declaration}: pre-column-declaration, used before lcrpmb
  - <{declaration}: post-column-type declaration, user after lcrpmb
  - @{text}: column containing the text in every cell of the column
- custom
  - L{width}: left-aligned cells with fixed width
  - C{width}: center-aligned cells with fixed width
  - R{width}: right-aligned cells with fixed width

*** Alignment and Bookstab style
#+CAPTION: Table using bookstab and align
#+ATTR_LATEX: :booktabs t :align rcl :placement [H]
|--------+--------+--------|
| right  | center | left   |
|--------+--------+--------|
| A1     | A2     | A2     |
| B1.1   | B2.1   | B3.1   |
| C1.1.1 | C2.1.1 | C3.1.1 |
|--------+--------+--------|

*** Alignment
#+CAPTION: Table using align
#+ATTR_LATEX: :align |r|cl| :placement [H]
|--------+--------+--------|
| right  | center | left   |
|--------+--------+--------|
| A1     | A2     | A3     |
| B1.1   | B2.1   | B3.1   |
| C1.1.1 | C2.1.1 | C3.1.1 |
|--------+--------+--------|

*** Fixed width / multi-line cells
Multi-line cells with fixed width cells using =pmbLCR=
and forced newline using =\newline=.
#+CAPTION[Table using custom align and newline]: Table using =#+ATTR_LATEX: :align rC{0.6\textwidth}l= and =\newline=
#+ATTR_LATEX: :bookstabs :align rC{0.6\textwidth}l :placement [H]
|--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------|
| right  | center                                                                                                                                                                                                                                                                                                                                                                                                                                                        | left   |
|--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------|
| A1     | A2                                                                                                                                                                                                                                                                                                                                                                                                                                                            | A3     |
| B1.1   | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\newline Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. | B3.1   |
| C1.1.1 | C2.1.1                                                                                                                                                                                                                                                                                                                                                                                                                                                        | C3.1.1 |
|--------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------|

*** Multi-page table / longtable
#+CAPTION: Longtable
#+ATTR_LATEX: :environment longtable :align l|lp{3cm}r|l
| ... |   ... |
| ... | 3.456 |
| ... | 2,842 |

*** Number alignment
Alignment of numbers (numprint) using column type n (numbers in math)
and N (numbers in text)
#+CAPTION: Table using column type n and N
#+ATTR_LATEX: :booktabs t :align n{5}{3}n[3]{5}{3}n[3][1]{5}{3}N{5}{3}
|-----------------+-----------------+-----------------+-----------------|
|         =n{5}{3}= |      =n[3]{5}{3}= |   =n[3][1]{5}{3}= |         =N{5}{3}= |
|-----------------+-----------------+-----------------+-----------------|
|       123.45e12 |       123.45e12 |       123.45e12 |       123.45e12 |
|   12345.678e123 |   12345.678e123 |   12345.678e123 |   12345.678e123 |
|     123.45e12.3 |     123.45e12.3 |     123.45e12.3 |     123.45e12.3 |
| 12345.678e123.3 | 12345.678e123.3 | 12345.678e123.3 | 12345.678e123.3 |
|-----------------+-----------------+-----------------+-----------------|

*** Custom caption command for LaTeX
Set caption with \LaTeX{} command
#+ATTR_LATEX: :caption \caption[HeadingA.toc]{HeadingA}
#+ATTR_LATEX: :placement [h]
| ... | ... |
| ... | ... |

*** Overlay using tikz
#+CAPTION: Table with tikz overlay
|         | 1, 2, 7                  | 3                        | 4, 6                     | 5                        | \leftarrow Oberseite              |
| Schicht | 8, 13, 14                | 12                       | 9, 11                    | 10                       | \leftarrow Unterseite             |
|---------+--------------------------+--------------------------+--------------------------+--------------------------+-----------------------------------|
|       1 | \tikzmark{LAa}Gelcoat    | \tikzmark{LAc}Gelcoat    | \tikzmark{LAe}Gelcoat    | \tikzmark{LAg}Gelcoat    | \tikzmark{LAi}Saertex(DB)         |
|       2 | SNL(Triax)               | SNL(Triax)               | SNL(Triax)               | SNL(Triax)               | FOAM                              |
|       3 | SNL(Triax)               | SNL(Triax)               | SNL(Triax)               | SNL(Triax)               | \tikzmark{LAj}Saertex(DB)         |
|       4 | \tikzmark{LAb}SNL(Triax) | E-LT-5500(UD)            | FOAM                     | Carbon(UD)               |                                   |
|       5 |                          | FOAM                     | \tikzmark{LAf}SNL(Triax) | \tikzmark{LAh}SNL(Triax) | \(\uparrow\) Längsver-            |
|       6 |                          | \tikzmark{LAd}SNL(Triax) |                          |                          | \phantom{\(\uparrow\)} steifungen |
#+begin_export latex
\tikz[remember picture,overlay] {%
  \draw[red,very thick] ([xshift=-.3ex,yshift=2ex]pic cs:LAa) -- ([xshift=-.3ex,yshift=-.5ex]pic cs:LAb) node[midway] {};%
  \draw[LimeGreen,very thick] ([xshift=-.3ex,yshift=2ex]pic cs:LAc) -- ([xshift=-.3ex,yshift=-.5ex]pic cs:LAd) node[midway] {};%
  \draw[ProcessBlue,very thick] ([xshift=-.3ex,yshift=2ex]pic cs:LAe) -- ([xshift=-.3ex,yshift=-.5ex]pic cs:LAf) node[midway] {};%
  \draw[BurntOrange,very thick] ([xshift=-.3ex,yshift=2ex]pic cs:LAg) -- ([xshift=-.3ex,yshift=-.5ex]pic cs:LAh) node[midway] {};%
  \draw[Black,very thick] ([xshift=-.3ex,yshift=2ex]pic cs:LAi) -- ([xshift=-.3ex,yshift=-.5ex]pic cs:LAj) node[midway] {};%
}%
#+end_export

[[file:./img/table-overlay-tikz.png]]

*** From Python src block output
#+begin_src python :results output table :exports results :hlines yes
a = 1.362658
b = 'foo'

result = [
  None ,
  ['b', f'_{b}_'] ,
  [r'$R^{2}$',f'{a:.3f}'] ,
  None ,
]
print(result)
#+end_src

#+RESULTS:
|---------+-------|
| b       |   _foo_ |
| $R^{2}$ | 1.363 |
|---------+-------|

** Figures
*** Include svg
#+NAME: fig-svg
#+CAPTION: svg figure
#+ATTR_ORG: :width 100
#+ATTR_LATEX: :width 1cm
[[/usr/share/icons/hicolor/scalable/apps/emacs.svg]]

See figure ref:fig-svg-import as a reference.
*** Include png
#+NAME: fig-png
#+CAPTION: png figure
#+ATTR_ORG: :width 100
#+ATTR_LATEX: :width 1cm
[[/usr/share/icons/hicolor/128x128/apps/emacs.png]]

*** tikz using data file
#+HEADER: :file (tpl-file "test-tikz")
#+HEADER: :results (tpl-results)
#+BEGIN_src latex :exports results :wrap figure
\begin{tikzpicture}
\begin{axis}[
  width=12.5cm,
  height=5cm,
  title={},
  enlarge x limits=false,
  enlarge y limits=false,
  scale only axis,
  ymajorgrids,
  grid style={gray!30},
  axis lines=left,
  xticklabel style={/pgf/number format/.cd,fixed,fixed zerofill,precision=1},
  %xticklabel style={rotate=90,anchor=near xticklabel, /pgf/number format/1000 sep={}},
  xlabel={$x$ label},
  xlabel style ={yshift=-0.5cm},
  %xtick={0,1,...,3},
  xmin=0,
  xmax=3,
  ymin=0,
  ymax=10,
  ylabel={$y$ label},
  %yticklabel style={/pgf/number format/.cd,fixed,fixed zerofill,precision=2},
  %ytick={-1,0,...,3.5},
  ]
  \addplot[red, thick, mark=x] table[x index=0, y index=1] {/absolute/path/to/data.dat}; \label{tpl:y1}
  \addplot[blue, thick, mark=x] table[x index=0, y index=2] {/absolute/path/to/data.dat}; \label{tpl:y2}
\end{axis}
\end{tikzpicture}
#+END_src

#+ATTR_LATEX: :options [H] :caption \caption[Caption in ToC]{Caption at place with ref to \(y_{1}\) \ref{tpl:y1} and \(y_{2}\) \ref{tpl:y2}}
#+RESULTS:
#+begin_figure
[[file:test-tikz.svg]]
#+end_figure

*** python using matplotlib

SRC block header =:prologue (mpl-prologue)= for non-latex exports (.svg
exports) to loads my.mplstyle including kpfonts. Other style via
optional argument, e.g. =:prologue (mpl-prologue "my-tex")= rendering
via latex including kpfonts.

SRC block header =:var fname=(mpl-var "<file_name>")= to export figure
as .pgf for latex and .svg otherwise, like HTML.

**** using my.mplstyle
Python matplotlib figure using matplotlib =my=. The style =my= renders
without LaTeX but using the kpfonts.

#+HEADER: :prologue (mpl-prologue)
#+HEADER: :var fname=(mpl-var "img/figure-matplotlib")
#+begin_src python :results output file
import math as m
import matplotlib as mpl

n = 30
t = [i/n*m.pi for i in range(n+1)]

fig, ax = plt.subplots()
[ax.plot(t, [m.sin(i+j/12*m.pi) for i in t], color=f'C{j}', label=f'$C_{j}$') for j in range(10)]
ax.legend()
ax.set_title(r'Functions: $\sin(x + \pi \, i/12)$')
ax.set_xlabel(r'$x ~ \times \pi$')
ax.set_ylabel('$y$')
ax.set_xticks([0, m.pi/4, m.pi/2, m.pi*3/4, m.pi])
ax.set_xticklabels([0.00, 0.25, 0.50, 0.75, 1.00])
ax.xaxis.set_minor_locator(mpl.ticker.AutoMinorLocator(3))
ax.grid()
ax.grid(which='minor', linestyle=':')

fig.savefig(fname)
plt.close()
print(fname, end='')
#+end_src

#+ATTR_ORG: :width 500
#+RESULTS:
[[file:img/figure-matplotlib.svg]]

**** using my-tex.mplstyle
Python matplotlib figure using matplotlib =my-tex=. The style =my-tex=
renders with LaTeX and uses the kpfonts.

#+HEADER: :prologue (mpl-prologue "my-tex")
#+HEADER: :var fname=(mpl-var "img/figure-matplotlib-tex")
#+begin_src python :results output file
import math as m
import matplotlib as mpl

n = 30
t = [i/n*m.pi for i in range(n+1)]

fig, ax = plt.subplots()
[ax.plot(t, [m.sin(i+j/12*m.pi) for i in t], color=f'C{j}', label=f'$C_{j}$') for j in range(10)]
ax.legend()
ax.set_title(r'Functions: $\sin(x + \pi \, i/12)$')
ax.set_xlabel(r'$x ~ \times \pi$')
ax.set_ylabel('$y$')
ax.set_xticks([0, m.pi/4, m.pi/2, m.pi*3/4, m.pi])
ax.set_xticklabels([0.00, 0.25, 0.50, 0.75, 1.00])
ax.xaxis.set_minor_locator(mpl.ticker.AutoMinorLocator(3))
ax.grid()
ax.grid(which='minor', linestyle=':')

fig.savefig(fname)
plt.close()
print(fname, end='')
#+end_src

#+ATTR_ORG: :width 500
#+RESULTS:
[[file:img/figure-matplotlib-tex.svg]]

** Example / Verbatim
#+BEGIN_EXAMPLE
  verbatime example
#+END_EXAMPLE

or using =:= (start the example lines with a colon followed by a space.)
: a single line example
  : can be indented

** Source
#+NAME: <name>
#+BEGIN_SRC <language> <switches> <header arguments>
  <body>
#+END_SRC

#+BEGIN_SRC python
string = 'hello' + ', world' + !*3  # comment
print(string)
#+END_SRC

* Math
** Symbols and Functions
*** Quotation, Fraction
#+begin_example
- \[\underbracket[1pt][0pt]{bla}_\text{blo}\]
- \[\Dfrac{3}{7}\]
- \[\slfrac{3}{7}\]
- \[\sfrac{3}{7}\]
- \[\nicefrac{3}{7}\]
- \[\faktor{3}{7}\]
- \[\Faktor{3}{7}\]
#+end_example
*** Units
#+begin_example
- \(\unit{123.45}{\milli\meter}\)
#+end_example
*** Fields
#+begin_example
- \(\field{X}\) : field
- \(\fA{}\) : Affine field
- \(\fC\) : Complex field
- \(\fFp\) : Finite field
- \(\fFq\) : Finite field
- \(\fGa\) : Group scheme
- \(\fK\) : Generic field (Körper)
- \(\fN\) : Natural numbers
- \(\fPj\) : Projective field
- \(\fR\) : Real numbers
- \(\fQ\) : Rational numbers
- \(\fI\) : Irrational numbers
- \(\fZ\) : Integers
- \(\Def\) : Domain of a function D (Definitionsbereich)
- \(\LM\) : Solution set L (Lösungsmenge)
#+end_example
*** Functions
#+begin_example
- \(\sins\) : Short sin
- \(\coss\) : Short cos
#+end_example
*** Operators
#+begin_example
- \(\norm{x}\) : ||x||
- \(\abs{x}\) : |x|
- \(\innerProd{x}{y}\) : <x,y>
- \(\Bild U\) : Map of a function (mapping, transformation)
- \(\rank U\) : Rank of a matrix
- \(\tr U\) : Matrix trace
- \(\dev U\) : Matrix deviation
- \(\var U\) : Variance
- \(\grad U\) : Gradiant
- \(\divergence U\) : Divergence div
- \(\rot U\) : Rotation
- \(\diag U\) : Diagonal matrix
- \(\adj\) : Adjoint operator H
- \(\adjugate U\) : Classical adjoint adj (adjugate)
- \(()^\T\) : Transpose operator
#+end_example
*** Others
#+begin_example
- \(\corresponds\) : equal sign with a hat
- \(\dt{u}\) : dot above symbol (time derivative)
- \(\ddt{u}\) : two dots above symbol (time derivative)
- \(\Eval{a}{b}{c}\) : evaluation limits a|_b^c
- \(\fdg\) : 'für die gilt' | (vertical bar)
- \(\E\) : E
- \(\qed\) : Q.E.D. quod erat demonstrandum "what was to be shown" -> "which was to be demonstrated"
- \(\euler\) : Euler e
- \(\deg\) : Degree °
- \(\degC\) : °C
- \(\TF\) : sign for transfomed values: low tilde
- \(\dif\) : d
#+end_example
*** Tensor
#+begin_example
- \(\tensor{U}\) : general bold, no further decoration
- \(\tensorI{U}\) : underline
- \(\tensorII{U}\) : two underlines
- \(\tensorIII{U}\) : tilde 3 below symbol
- \(\tensorIV{U}\) : tilde 4 below symbol
- \(\tensori{U}\) : harpoon right
- \(\tensorii{U}\) : harpoon right and left
- \(\tensoriii{U}\) : arrow right and harpoon left
- \(\tensoriv{U}\) : arrow right and left
#+end_example

** Equation
named equation:
#+name: eq-in-name
\begin{equation}
e^x = 4
\end{equation}

And refer to Eq. ref:eq-in-name in document.

** Matrix
Create math matrix objects with org tables
#+ATTR_LATEX: :mode math :environment bmatrix :math-suffix \times
| a | b |
| c | d |
#+ATTR_LATEX: :mode math :environment bmatrix
| 1 | 2 |
| 3 | 4 |

* Glossary and Acronym and References

** Glossary
See command =org-ref-glossary-gls-commands= and use
=org-ref-insert-glossary-link= to insert a link with completion (=C-c
C-l=).

Use a glossary entry using
- only link location gls:tree or gls:shrub
- link location and description [[gls:shrub][Shrub]], the description is only visible in Org
- not recommended latex command \gls{tree}

#+CAPTION: Glossary types
#+ATTR_LATEX: :booktabs t :placement [h]
|-----------+-------------------------------------------------------------|
| =gls=       | The term associated with the label                          |
| =glspl=     | The plural term                                             |
| =Gls=       | The capitalized term                                        |
| =Glspl=     | The plural capitalized term                                 |
| =glssymbol= | The symbol defined (only with latex definition)             |
| =Glssymbol= | The capitalized symbol defined (only with latex definition) |
| =glsdesc=   | The description associated with the label                   |
| =Glsdesc=   | The capitalized description associated with the label       |
|-----------+-------------------------------------------------------------|

** Acronym
See command =org-ref-acronym-types= and use =org-ref-insert-acronym-link=
to insert a link with completion (=C-c C-l=).

Use a acronyms entry using
- only link location acrfull:bb
- link location and description [[acrshort:bb][BB]] [[acrfull:qos][quality-of-service (QoS)]]

#+CAPTION: Acronym types
#+ATTR_LATEX: :booktabs t :placement [H]
|------------+-----------------------------------------------------------|
| =acrshort=   | The acronym for label                                     |
| =acrshortpl= | The acronym for label in plural                           |
| =Acrshort=   | Capitalized acronym                                       |
| =Acrshortpl= | Plural capitalized acronym                                |
| =ACRshort=   | ALL-CAPS acronym                                          |
| =ACRshortpl= | ALL-CAPS plural acronym                                   |
| =acrlong=    | The label definition                                      |
| =acrlongpl=  | The plural definition                                     |
| =Acrlong=    | Capitalized definition                                    |
| =Acrlongpl=  | Plural capitalized definition                             |
| =ACRlong=    | ALL-CAPS definition                                       |
| =ACRlongpl=  | plural ALL-CAPS definition                                |
| =acrfull=    | Both the acronym and its definition                       |
| =acrfullpl=  | Both the acronym and its definition in plural             |
| =Acrfull=    | Capitalized both the acronym and its definition           |
| =Acrfullpl=  | Capitalized both the acronym and its definition in plural |
| =ACRfull=    | Both the acronym and its definition in ALL-CAPS           |
| =ACRfullpl=  | Both the acronym and its definition in plurall ALL-CAPS   |
|------------+-----------------------------------------------------------|

** References
check regarding the style defined in the preamble
: biber --validate-datamodel <texfilebasename>

this only checks the bib with default style
: biber --tool --validate-datamodel <filename>.bib

Insert cite entry with (=C-c C-l=).

#+CAPTION: =org-ref-biblatex-types=
| Cite         | basic citation with capitalization                                            |
| parencite    | similar to cite with parentheses                                              |
| Parencite    | similar to cite with parentheses and capitalization                           |
| footcite     | Put the citation in a footnote                                                |
| footcitetext | Put the citation in a footnote using =\footnotetext=                            |
| textcite     | print the authors or editors as a subject of the sentence                     |
| Textcite     | print the authors or editors as a subject of the sentence with capitalization |
| smartcite    | like parencite in a footnote, and footcite in the body                        |
| Smartcite    | like parencite in a footnote, and footcite in the body with capitalization    |
| cite         | "similar to cite, but prints the year or title                                |
| parencite    | "similar to parencite, but prints the year or title                           |
| supercite    | superscripted numeric citation (only in numberic styles)                      |
| autocite     | handles some punctuation nuances                                              |
| Autocite     | handles some punctuation nuances with punctuation                             |
| autocite     | "same as autocite but * is passed to the backend                              |
| Autocite     | "same as Autocite but * is passed to the backend                              |
| citetitle    | the shorttitle or title field                                                 |
| citetitle    | "the full title                                                               |
| citeyear     | the year field                                                                |
| citeyear     | "the year field and extradate information if available                        |
| citedate     | the full date or year                                                         |
| citedate     | "the full date or year, including extradate information if available          |
| citeurl      | the url field                                                                 |
| fullcite     | create a full citation similar to what is in the bibliography                 |
| footfullcite | create a full citation as a footnote                                          |
| notecite     | print prenote and postnote, but no citation                                   |
| Notecite     | print prenote and postnote, but no citation with capitalization               |
| pnotecite    | similar to notecite with parentheses                                          |
| Pnotecite    | similar to Notecite with parentheses                                          |
| fnotecite    | similar to notecite in a footnote                                             |

#+CAPTION: =org-ref-biblatex-multitypes=
#+ATTR_LATEX: :center nil :placement [H]
| cites         | multicite version of cite         |
| Cites         | multicite version of Cite         |
| parencites    | multicite version of parencite    |
| Parencites    | multicite version of Parencite    |
| footcites     | multicite version of footcite     |
| footcitetexts | multicite version of footcitetext |
| smartcites    | multicite version of smartcite    |
| Smartcites    | multicite version of Smartcite    |
| textcites     | multicite version of textcite     |
| Textcites     | multicite version of Textcite     |
| supercites    | multicite version of supercite    |
| autocites     | multicite version of autocite     |
| Autocites     | multicite version of Autocite     |

Example: See reference [[cite:manual]] (will be [1]) or [[cite:article]]
[[cite:book]] (will be [2,3]) and [[cite:article]] [[cite:book]] [[cite:manual]] (will
be [1-3]).

* LaTeX
Current setup uses the lualatex compiler.

packages
- general
  - fontenc
  - hyperref
  - kpfonts
  - luainputenc
  - xurl
- text and glyphs
  - eurosym
  - menukeys
  - xcolor
- math
  - faktor
  - madthds
  - mathtools
  - MnSymbol
  - nicefrac
  - SIunits
  - xfrac
- lists
  - enumitem
- tables, figures and listings
  - float
  - caption
- tables
  - booktabs
  - longtable
  - numprint
  - array
- figures
  - svg
  - tikz
  - gnuplot-lua-tikz
  - pgfplots
- listings
  - listingsutf8
- glossaries
- pdf
  - pdfpages
  - pdflscape
    
* Examples
** Org table to data file
#+NAME: tbl-data
| 0 | 1 | 1 |
| 1 | 2 | 4 |
| 2 | 3 | 5 |
| 3 | 4 | 9 |

#+NAME: org-table-to-data-file
#+begin_src python :var data=tbl-data :results none
with open("data.dat", "w") as f:
  f.write("\n".join([" ".join(list(map(str, i))) for i in data]))
#+end_src

** Data file to Org table
#+NAME: get-data-file
#+begin_src python
with open("data.dat", "r") as f:
  data = f.read()
return data
#+end_src

#+RESULTS:
| 0 | 1 | 1 |
| 1 | 2 | 4 |
| 2 | 3 | 5 |
| 3 | 4 | 9 |
