LaTeX - ftsrg/cheat-sheets GitHub Wiki
See also ArXiv page.
Choosing between Word and LaTeX
Check a comparison between Word, LaTeX and InDesign: http://www.zinktypografie.nl/latex.php?lang=en (source: http://tex.stackexchange.com/questions/110133/visual-comparison-between-latex-and-word-output-hyphenation-typesetting-ligat)
BibTeX
Distributions
Windows
MiKTeX: Download from http://miktex.org/. When prompted, check the option which enables to install packages on-the-fly.
Linux
TeX Live. TeX Live is not capable of downloading packages on-the-fly (see http://www.texdev.net/2011/11/19/tex-on-windows-miktex-or-tex-live/ for details), so it is recommended to install the full package:
sudo apt-get install -y texlive-full
LaTeX symbols
Recognize hand-drawn symbols
http://detexify.kirelabs.org/classify.html
Writing Hungarian documents
-
Check out the page of the Math Institute of the Budapest University of Technology and Economics: http://www.math.bme.hu/latex/
-
Make sure that your LaTeX distribution contains version 1.5+ of the
magyar.ldf
file. If not, download the latest one. -
Use the following packages ensures that the reader is able to 1) search for accented characters 2) copy text from the document properly.
\usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \usepackage{cmap}
If you use
xetex
, use the following setup:\usepackage{ifxetex} \ifxetex \usepackage{fontspec} \else \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage{lmodern} \fi \usepackage{cmap}
Using references
- Use the
\aref{}
command to insert the correct definite article in the text (e.g.az 1. ábrán
,a 2. ábrán
). - The
hyperref
package conflicts with version 1.4 of themagyar.ldf
file. - For using "autoref/cref-like" references in Hungarian documents, see this Gist: https://gist.github.com/szarnyasg/1a2096975932e9a4667e
Use in CI
- Docker image:
texlive/texlive:latest
- GitHub Actions:
uses: ftsrg/document-converter-actions@master
Useful tools
- The LaTeX Workshop in VS Code, TeXlipse, and TeXstudio editor
Excel-to-LaTeX: Create tables faster than ever (and more maintainable)
Download: http://www.ctan.org/pkg/excel2latex Start Excel through Excel2LaTeX.xla and open your excel file. Select your formatted table and click the corresponding button under the Add-Ins (hu: Bővítmények) ribbon. And of course allow macros. Maybe you have to add LaTeX packages: bigstrut, rotating, multirow.
TablesGenerator
A bit cumbersome to use on its own (the table editor is just an HTML table, with some added convenience by a very lightweight 'formatter'). It supports multi-row and multi-column cells, as well as a custom border grid and alignments. Its main strengths are in the special options, for example:
- Scale table to text/column width
- Rotate table to landscape mode
- Split table to multiple pages
Using guillemets in listings
The lstlistings
package does not support UTF-8 characters. If you need to use guillemets (French quotation mark characters) in Xtend code: 1) change the guillemets to [guilleft]
and [guilright]
literals 2) add the following settings to the listing:
\lstset{literate=*{[guilleft]}{\guillemotleft{}}{1}{[guilright]}{\guillemotright{}}{1},}
Posters with LaTeX
See the tikzposter
class: http://ctan.ijs.si/tex-archive/graphics/pgf/contrib/tikzposter/tikzposter.pdf
Listings in UTF-8
Using UTF-8 characters in listings may produce the following error:
! Package inputenc Error: Unicode char \u8:�\expandafter not set up for use with LaTeX.
\lstset{
...
inputencoding=utf8,
extendedchars=false,
}
Note that the extendedchars
key should be set to false
.
Source: http://tex.stackexchange.com/questions/24528/having-problems-with-listings-and-utf-8-can-it-be-fixed
TikZ & PGFPlots manual
Version 2.10
http://www.texample.net/media/pgf/builds/pgfmanualCVS2012-11-04.pdf
Version 3.0
Follow this URL: http://www.ctan.org/pkg/pgf. Mirrors for the 3.0 documentation:
Using "e.g.", "i.e." and other abbreviations without French spacing
English speaking documents don't use the \frenchspacing
options. This means that every .
character is interpreted as a full stop and is followed by a double space. This way, e.g. something
is rendered as e.g. something
. A common solution to fix this is writing e.g.\ something
. However, for longer documents, this approach is error-prone, so we recommend using the following commands instead:
\newcommand{\ie}{i.e.\@\xspace}
\newcommand{\Ie}{I.e.\@\xspace}
\newcommand{\eg}{e.g.\@\xspace}
\newcommand{\Eg}{E.g.\@\xspace}
\newcommand{\etal}{et al.\@\xspace}
\newcommand{\etc}{etc.\@\xspace}
\newcommand{\vs}{vs.\@\xspace}
\newcommand{\viz}{viz.\@\xspace}
Update TeX Live on Ubuntu
Use the script provided at https://github.com/scottkosty/install-tl-ubuntu. You may need to reboot the machine to load the new TeX Live.
TikZiT
TikZiT is a handy tool for drawing tikz figures.
sudo add-apt-repository ppa:gspreemann && sudo apt-get update
sudo apt-get install tikzit
Troubleshooting
Error 131 in Adobe Reader
Adobe Reader (on both Windows and Linux), displays the following error message:
There was an error processing a page. There was a problem reading this document (131)
In my case, this was caused by an "incorrect" PNG file (included with includegraphics
). I couldn't fix the PNG (using Print Screen/GIMP/...).
The possible workarounds are the following:
- Compile the document with XeLaTeX (instead of PDFLaTeX).
- Convert the image to PDF (e.g. print it to PDF and crop it with
pdfcrop
).
Syntax highlighting
For sophisticated syntax highlighting, it is recommended to use the minted
package. This uses the pygments
Python package. On Ubuntu, use the following command to install it:
sudo apt-get install python-pygments
The following LaTeX code works with both PDFLaTeX and XeLaTeX:
% !TeX encoding = UTF-8
% use ONE of these
% !TeX program = xelatex -shell-escape -8bit %.tex
% !TeX program = pdflatex -shell-escape %.tex
\documentclass[a4paper]{article}
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\else
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\fi
\usepackage{minted}
\begin{document}
\begin{minted}{prolog}
mother_child(trude, sally).
father_child(tom, sally).
father_child(tom, erica).
father_child(mike, tom).
sibling(X, Y) :- parent_child(Z, X), parent_child(Z, Y).
parent_child(X, Y) :- father_child(X, Y).
parent_child(X, Y) :- mother_child(X, Y).
\end{minted}
\end{document}
Convert to PNG
Use the standalone
package:
\documentclass[convert]{standalone}
\begin{document}
$$\alpha$$
\end{document}
To convert, add the -shell-escape
option:
pdflatex -shell-escape hello.tex
# or
xelatex -shell-escape hello.tex
BibTeX errors with the 2017 ACM Master template
Problem: the ACM Master template throws the following error when compiling:
! Missing = inserted for \ifnum.
<to be read again>
U
l.5 ...R14, AUTOSAR, DBLP:conf/ifm/LutebergetJS16}
).
Solution: this is caused by double curly braces in an author
field of the BibTeX file, for example
author = {{AUTOSAR Consortium}},
Simply use single curly braces – the template is able to handle author names properly (and it will not invert the name as Consortium, A.).
Undefined color error by xcolor
Symptom: The build fails with the following message:
Package xcolor Error: Undefined color 'n'
Cause and solution: There is a deprecated xcolor.sty
file next to the tex
file. Remove it.
Import single character from font package
The \mapsfrom
(↤
) symbol in stmaryrd
gets translated to ←[
when copied from the text with the cmap
package activated.
If you think this is unacceptable, you can use use the \mapsfrom
character from the stix
package.
To import this character without the entire (quite heavy) stix
package, follow the instructions at Stack Exchange:
\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareSymbolFont{arrows1}{LS1}{stixsf}{m}{n}
\DeclareMathSymbol{\mapsfrom}{\mathrel}{arrows1}{"AB}
.cls
file from parent directory
Include Including \documentclass{../template/mytemplate}
from parent directory causes the following warning. In certain cases the .cls
file is not included at all (e.g. in makisyu/texlive-2020 Docker image).
LaTeX Warning: You have requested document class `../template/mytemplate',
but the document class provides `mytemplate'.
Possible solutions:
\input@path
\makeatletter
\def\input@path{{../template/}}
\documentclass{mytemplate}
\let\input@path\@undefined % restore search path if needed
\makeatother
TEXINPUTS=../template:$TEXINPUTS pdflatex myfile
(source)\subimport
fromimport
package, details: 1, 2, 3- filter warning
Diff tool
- latexdiff package:
- See description.
- Use
--flatten
to also compare included .tex files. - Copy figures (of the new version) to the folder of the diff.
- Example:
latexdiff --flatten ../old/ms.tex ../new/ms.tex > diff.tex
Cleaner
See here.
Cloning from Overleaf
When cloning from Overleaf, git will request your password for every push/pull operation. To store the password, run:
git config credential.helper store