Rockstable Wiki:

LaTeX

\Huge\LaTeX

LaTeX Cheat Sheets

If you are on Linux you'll find these two cheats come in very handy.

TeXDoc

Instantly get local style documentation instead of searching CTAN.

   1 texdoc -h
   2 texdoc texdoc
   3 texdoc scrguide
   4 texdoc ifthen

LuaTeX

About

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

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

   1 apt install kile

Configuration files and directories

Options

General

Cleanup

Options > Kile > General

Let kile remove temporary files on close.

~/.config/kilerc

   1 [Files]
   2 CleanUpAfterClose=true
   3 CleanUpFileExtensions=.aux .bit .blg .bbl .lof .log .lot .glo .glx .gxg .gxs .idx .ilg .ind .out .url .svn .toc .ist .glsdef .fls .fdb_latexmk

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

   1 # This shows how to use lualatex (http://en.wikipedia.org/wiki/LuaTeX)
   2 # with latexmk.  
   3 #
   4 #   WARNING: The method shown here is suitable only for ver. 4.51 and
   5 #            later of latexmk, not for earlier versions.
   6 #
   7 
   8 $pdf_mode = 4;
   9 $postscript_mode = $dvi_mode = 0;

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

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 select the menu Create > Live-Preview > LuaTex

With the flag --shell-escape you may use external programs like pygmentize for the LaTeX minted package.

lacheck

~/.config/kilerc

   1 [Tool/lacheck/Default]
   2 autoRun=yes
   3 checkForRoot=yes
   4 class=Base
   5 close=
   6 command=lacheck
   7 jumpToFirstError=yes
   8 menu=Compile
   9 options=%S
  10 type=Process
  11 
  12 [Tools]
  13 lacheck=Default
  14 
  15 [ToolsGUI]
  16 lacheck=Other,application-x-executable

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

I even took a second copy
attachment:ts5invSear.pdf

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

   1 [MainWindow]
   2 MenuBar=Disabled

MoinMoin LaTeX Integration



\section{LaTeX Example}

So \LaTeX\ is working, too.

\noindent
\textbf{Fine.}


\subsection{LaTeX Equations}

\begin{equation*}
  1 + 2 = 3
\end{equation*}

\begin{align*}
  1 + 2 &= 3\\
  1 &= 3 - 2
\end{align*}

Templates

Cookbook

Gitlab project 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.

   1 cd /usr/share/texlive/texmf-dist/tex/latex/xcookybooky
   2 file xcookybooky.sty
   3 xcookybooky.sty: LaTeX document, ISO-8859 text
   4 cp xcookybooky.sty xcookybooky.sty.org
   5 iconv -f ISO-8859-1 -t UTF-8 -o xcookybooky.sty xcookybooky_org.sty

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

Rockstable Wiki: LaTeX (last edited 2021-09-19 11:43:36 by RockStable)