LaTeX
Contents
Some links
LaTeX Cheat Sheets
If you are on Linux you'll find these two cheats come in very handy.
file:///usr/share/doc/texlive-doc/latex/latexcheat/latexsheet.pdf
file:///usr/share/doc/texlive-doc/latex/latexcheat-de/latexsheet-de.pdf
LaTeX Installation
1 PACKAGES=(
2 texlive texlive-base texlive-bibtex-extra texlive-binaries texlive-extra-utils \
3 texlive-font-utils texlive-fonts-extra-links texlive-fonts-recommended \
4 texlive-fonts-recommended-doc texlive-lang-greek texlive-latex-base \
5 texlive-latex-base-doc texlive-latex-extra-doc texlive-latex-recommended \
6 texlive-latex-recommended-doc texlive-luatex texlive-metapost \
7 texlive-metapost-doc texlive-pictures texlive-pictures-doc \
8 texlive-plain-generic texlive-pstricks texlive-pstricks-doc texlive-science \
9 texlive-science-doc texlive-xetex
10 )
11 apt --mark-auto install ${PACKAGES}
TeXDoc
Instantly get local style documentation instead of searching CTAN.
LuaTeX
Links
About
- Downwards compatible to pdfTeX
- Native UTF-8 support
OpenType fonts
- embedded scripting language Lua
LuaTeX is an extended version of pdfTeX using Lua as an embedded scripting language. The LuaTeX project's main objective is to provide an open and configurable variant of TeX while at the same time offering downward compatibility. From the user perspective we have pdfTeX as stable and more or less frozen 8 bit engine, XeTeX as unicode input and font aware engine using libraries for font handling, and LuaTeX as engine that is programmable and delegates as much as possible to Lua, with the objective to keep the core engine lean and mean. Each engine has its benefits and drawbacks (more details here).
About Lua
Lua is a powerful, efficient, lightweight, embeddable scripting language. It supports procedural programming, object-oriented programming, functional programming, data-driven programming, and data description.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode with a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
xcolor
Extract names and definitions from xcolors
1 DIR="/usr/share/texlive/texmf-dist/tex/latex/xcolor"
2 OUT="/home/tobias/Dokumente/logo/xcolor_definitions.txt"
3 grep -rh -A20 definecolorset "$DIR/xcolor.sty" \
4 |grep -E -e '^ +\{?[[:alnum:],./]+\}?;?%?$' -e '^\\definecolorset' \
5 |sed 's/\\definecolorset{//;s/^ {/ /' \
6 |tr -d '{;%}' \
7 > "$OUT"
8 echo '### RGB' >> "$OUT"
9 grep -Eh -e '^[[:alnum:],./]+' "$DIR/"*.def \
10 |sed 's/\\definecolorset{//;s/^ {/ /' \
11 |tr -d '{;%}' \
12 >> "$OUT"
Kile - an Integrated LaTeX Editing Environment
About
Features
Why i use it
- Projects gather up complex documents and project relevant settings
- live-preview with automatic scrolling on save (Ctrl+s)
- highly customizable (tools, tool-sequences)
- auto-completion
- nice short-cuts (like Ctrl+Shift+UP/DOWN, Ctrl+Enter)
- konsole integration
- vim-mode
- dark-themes for the editor (window-borders in dark system-colors)
Install
Make sure you get a version ≥ 2.9.93-1 or you will receive application crashes when right clicking the source tabs.
1 apt-cache policy kile
2 kile:
3 Installiert: 4:2.9.93-1
4 Installationskandidat: 4:2.9.93-1
5 Versionstabelle:
6 *** 4:2.9.93-1 500
7 500 http://ftp.de.debian.org/debian bullseye/main amd64 Packages
8 300 http://ftp.debian.org/debian sid/main amd64 Packages
9 100 /var/lib/dpkg/status
10 4:2.9.92-2 500
11 500 http://ftp.de.debian.org/debian buster/main amd64 Packages
On Ubuntu you'll need at least Ubuntu 20.04 LTS (Focal Fossa)
Ubuntu packages: kile
Configuration files and directories
~/.config/kilerc
~/.local/share/kile
Options
General
Cleanup
Options > Kile > General
Let kile remove temporary files on close.
~/.config/kilerc
Tools
Create tools via Options > Tools > Create
I copied the text from ~/.config/kilerc to get a condensed definition. But you should configure it using the GUI.
You should especially give the tool QuickMK-pdflua a try!!1! Compiling has never been simpler…
latexmk
Latexmk completely automates the process of compiling a LaTeX document. Essentially, it is like a specialized relative of the general make utility, but one which determines dependencies automatically and has some other very useful features. In its basic mode of operation latexmk is given the name of the primary source file for a document, and it issues the appropriate sequence of commands to generate a .dvi, .ps, .pdf and/or hardcopy version of the document.
man latexmk
LatexMK has no heuristic to determine which compiler to chose.
Always specify one of:
-pdf, -pdfdvi, -pdflatex, -pdflua, -pdfps, -pdfxe
Compile all .tex file in the current working directory with lualatex
1 latexmk -pdflua
You may customize the bahaviour in ~/.latexmkrc, ./.latexmkrc, ./latexmkrc in perl syntax. Here are some example rcfiles.
~/.latexmkrc for usage of lualatex
Configure kile
~/.config/kilerc
1 [Tool/LatexMK-pdf/Default]
2 autoRun=yes
3 checkForRoot=yes
4 class=LaTeX
5 close=
6 command=latexmk
7 jumpToFirstError=yes
8 menu=Compile
9 options=-pdf --synctex=1 --interaction=nonstopmode --shell-escape %source
10 to=pdf
11 type=Process
12
13 [Tool/LatexMK-pdflua/Default]
14 autoRun=yes
15 checkForRoot=yes
16 class=LaTeX
17 close=
18 command=latexmk
19 jumpToFirstError=yes
20 menu=Compile
21 options=-pdflua --synctex=1 --interaction=nonstopmode --shell-escape %source
22 to=pdf
23 type=Process
24
25 [Tool/QuickMK-pdf/Default]
26 autoRun=no
27 checkForRoot=no
28 class=Sequence
29 close=
30 jumpToFirstError=no
31 menu=Quick
32 sequence=lacheck,LatexMK-pdf,qpdf-linearize
33 type=Sequence
34
35 [Tool/QuickMK-pdflua/Default]
36 autoRun=no
37 checkForRoot=no
38 class=Sequence
39 close=
40 jumpToFirstError=no
41 menu=Quick
42 sequence=lacheck,LatexMK-pdflua,qpdf-linearize
43 type=Sequence
44
45 [Tools]
46 LatexMK-pdf=Default
47 LatexMK-pdflua=Default
48 QuickMK-pdf=Default
49 QuickMK-pdflua=Default
50
51 [ToolsGUI]
52 LatexMK-pdf=Compile,application-x-executable
53 LatexMK-pdflua=Compile,application-x-executable
54 QuickMK-pdf=Quick,application-x-executable
55 QuickMK-pdflua=Quick,application-x-executable
latexmk and glossaries
To enable support for generating glossaries put the following configuration in your
~/.latexmkrc or ./latexmkrc
Source: tex.stackexchange.com - How to make Latexmk use makeglossaries?
LivePreview-LuaLaTeX
Create the LivePreview
~/.config/kilerc
1 [Tool/LivePreview-LuaLaTeX/Default]
2 autoRun=yes
3 checkForRoot=no
4 class=LaTeXLivePreview
5 command=lualatex
6 from=
7 jumpToFirstError=yes
8 options=--synctex=1 --interaction=nonstopmode --shell-escape --output-directory=%dir_target --shell-escape %source
9 to=pdf
10 type=Process
11
12 [Tools]
13 LivePreview-LuaLaTeX=Default
14
15 [ToolsGUI]
16 LivePreview-LuaLaTeX=Other,application-x-executable
To change the Live-Preview options use editor and change it in .kilerc
With the flag --shell-escape you may use external programs like pygmentize for the LaTeX minted package.
lacheck
~/.config/kilerc
LuaLaTex
~/.config/kilerc
1 [Tool/LivePreview-LuaLaTeX/Default]
2 autoRun=yes
3 checkForRoot=no
4 class=LaTeXLivePreview
5 command=lualatex
6 from=
7 jumpToFirstError=yes
8 options=--synctex=1 --interaction=nonstopmode --output-directory=%dir_target %source
9 to=pdf
10 type=Process
11
12 [Tools]
13 LivePreview-LuaLaTeX=Default
14
15 [ToolsGUI]
16 LivePreview-LuaLaTeX=Other,application-x-executable
qpdf-linearize
Optimize for streaming/web
~/.config/kilerc
1 [Tool/qpdf-linearize/Default]
2 autoRun=
3 checkForRoot=
4 class=Convert
5 close=
6 command=qpdf
7 from=pdf
8 jumpToFirstError=
9 menu=Compile
10 options=--linearize --replace-input %S.pdf
11 to=pdf
12 type=Process
13
14 [Tools]
15 qpdf-linearize=Default
16
17 [ToolsGUI]
18 qpdf-linearize=Other,application-x-executable
QuickLua
~/.config/kilerc
1 [Tool/QuickLua/Default]
2 autoRun=no
3 checkForRoot=no
4 class=Sequence
5 close=
6 jumpToFirstError=no
7 menu=Quick
8 sequence=lacheck,LuaLaTeX,MakeIndex,MakeIndexGls,MakeGlossaries,LuaLaTeX,qpdf-linearize
9 type=Sequence
10
11 [Tool/QuickLua2/Default]
12 autoRun=no
13 checkForRoot=no
14 class=Sequence
15 close=
16 jumpToFirstError=no
17 menu=Quick
18 sequence=lacheck,LuaLaTeX,LuaLaTeX,qpdf-linearize
19 type=Sequence
20
21 [Tools]
22 QuickLua=Default
23 QuickLua2=Default
24
25 [ToolsGUI]
26 QuickLua=Quick,application-x-executable
27 QuickLua2=Quick,application-x-executable
ViewPDF - SyncTex with kile and okular
SyncTeX - this awesome feature allows syncing the line in the preview with the line in source code forward and inverse.
You can now avoid scrolling to the relevant position in source and vice versa.
Thanks for this pice of gold:
Forward and Inverse Search with syncTex forOkular and $Editor=Kile, VimJan Heiland
In preamble of document
1 \synctex=1
~/.config/kilerc
1 [Tool/ViewPDF/Okular]
2 class=View
3 command=okular
4 from=pdf
5 options=%target
6 state=Viewer
7 to=pdf
8 type=Process
9
10 [Tool/ViewPDF/Okular Unique]
11 class=View
12 command=okular
13 from=pdf
14 options=--unique %target
15 state=Viewer
16 to=pdf
17 type=Process
18
19 [Tools]
20 ViewPDF=Okular Unique
21
22 [ToolsGUI]
23 ViewPDF=View,okular
In Kile Preferences > Tools > Create chose ViewPDF and select the configuration "Okular Unique". Just click in the source code to jump to the corresponding line in the preview.
In Okular Preferences > Editor chose Kile with Command kile --line %l. Use SHIFT+LEFT_CLICK in the live preview to jump to the line in source code. I don't yet know if it is neccessary to compile it with luatex/xetex/pdflatex from time to time.
Random problems
Missing menubar
Sometime the menubar is completely missing. This is when this trick helps.
~/.config/kilerc
MoinMoin LaTeX Integration
Templates
Cookbook
Clone it via git
1 git clone https://git.rockstable.it/Rockstable/cookbook.git
LaTeX Errors
I had this error in conjunction with xcookybooky.
Strings contains an invalid utf-8 sequence
Well it turned out the style file was encoded in ISO-8859-1. So i converted it.
Works now.
Gitlab CI-pipeline
If you are using gitlab to revision your tex sources, you also may want to compile them on upload and keeping the latest artifacts/PDFs ready for download. This is how the process got automated.
.gitlab-ci.yml
1 ### https://docs.gitlab.com/ee/ci/yaml/
2
3 #image: registry.gitlab.com/islandoftex/images/texlive:latest
4 image: danteev/texlive:latest
5
6 variables:
7 SOURCE1: "cookbook_cuisine"
8 SOURCE2: "cookbook_xcookybooky"
9 PATH_XCOOKY: "/usr/share/texlive/texmf-dist/tex/latex/xcookybooky"
10
11 before_script:
12 - apt-get update -qq
13 - apt-get install -y -qq qpdf
14 - >
15 cp "$PATH_XCOOKY/xcookybooky.sty"
16 "$PATH_XCOOKY/xcookybooky_org.sty"
17 - >
18 iconv -f ISO-8859-1 -t UTF-8
19 -o "$PATH_XCOOKY/xcookybooky.sty"
20 "$PATH_XCOOKY/xcookybooky_org.sty"
21
22 build:
23 script:
24 - lacheck "$SOURCE1.tex"
25 - lacheck "$SOURCE2.tex"
26 #- lualatex --interaction=nonstopmode "$SOURCE1.tex"
27 - latexmk -pdflua
28 - qpdf --linearize --replace-input "$SOURCE1.pdf"
29 - qpdf --linearize --replace-input "$SOURCE2.pdf"
30 #after_script:
31 #- cat $SOURCE1.log
32 #- cat $SOURCE2.log
33 artifacts:
34 paths:
35 - $SOURCE1.pdf
36 - $SOURCE2.pdf
Convert ODS to CSV to TEX
1 #!/bin/bash
2
3 ### USE IT LIKE
4 # ./convert.sh file.ods "2 3" export
5
6 FILE_ODS="$1"
7 FILE="${FILE%%.ods}"
8 SHEETS="$2"
9 DIR_OUT="${3:-.}"
10
11 ### COVERT ODS SPREADSHEET TO CSV
12 # PLEASE SEE:
13 # https://help.libreoffice.org/latest/de/text/shared/guide/convertfilters.html
14 # https://help.libreoffice.org/latest/de/text/shared/guide/csv_params.html
15 # FILTER_OUT POSITIONAL PARAMETERS
16 # Token-Position Definition
17 # 1 Feldtrennzeichen (ASII-Dezimal) 44 (,)
18 # 2 Texttrennzeichen 34 (")
19 # 3 Zeichensatz UTF-8
20 # 4 Zeilennummer, ab der gelesen werden soll. 1
21 # 5 Zellformatcodes für jede Spalte NULL
22 # 6 Sprachkennung 0
23 # 7 Felder in Hochkommata als Text formatieren false
24 # 8 Erweiterte Zahlerkennung false
25 # 9 Zellinhalt wie angezeigt speichern true
26 # 10 Zellformeln exportieren false
27 # 11 Leerzeichen entfernen true (default: false)
28 # 12 Tabellen exportieren 2
29 # 13 Als Formeln importieren false
30
31
32 for SHEET in $SHEETS; do
33 FILTER_OUT="csv:Text - txt - csv (StarCalc):44,34,UTF-8,1,,0,false,false,true,false,true,$SHEET,false"
34 #FILTER_OUT="Text - txt - csv (StarCalc):44,34,76"
35 #FILTER_OUT="Text - txt - csv (StarCalc):44,34,ANSI,1,,0,false,true,true"
36 libreoffice \
37 --headless \
38 --convert-to "$FILTER_OUT" \
39 --outdir "$DIR_OUT" \
40 "$FILE_ODS"
41 done
42
43 ### CONVERT CSV TO LATEX
44 find "$DIR_OUT" -name "$FILE*.csv" \
45 |sed -r 's/.csv$//' \
46 |xargs -I{} -P $(nproc) -- \
47 pandoc -f csv -t latex \
48 "{}.csv" -o "{}.tex"
Now include it in your Latex-file