LaTeX Tips and Tricks Collection

1 minute read

This post summarizes some common useful tips in LaTeX editing.

Figures

% Style: Figure 1(a)
\usepackage[subrefformat=parens,labelformat=parens]{subfig}

\subfloat[]{
\includegraphics[height=\textheight]{example}
\label{fig:example}
}

\subref*{fig:example}

Bibliography

% unsrt, abbrev, last option means use unsrt in \cite[xxx,yyy,ccc]
\usepackage[sorting=none,firstinits=true,sortcites=true]{biblatex}

% add this in preamble
\bibliography{dsa-verification}

% at the end
\printbibliography

Graphics

  • Graphics path
\graphicspath{{figs/}}
  • Use other file extensions:
\DeclareGraphicsExtensions{.pdf, .jpg, .png}

Table and Tabular

  • threeparttable: Use footnote in tabular
% inside tabular:
\tnote{$\dagger$}

% after tabular
\begin{tablenotes}[para] % do not break line between items
\item [$\dagger$] A foot note. % this reference to the item
\end{tablenotes}

Theorem, Definition

  • New definition/theorem
\newtheorem{definition}{Definition}
  • Useful packages:
    • ntheorem
    • amsthm

Fonts

Packages

  • csvsimple: can automatically read csv and create tabular.
  • algpseudocode: the most updated algorithm / code environment, need to sit inside with algorithm package.
  • biblatex: provides better control for Bibliography.
  • multirow: provides \multirow and \multicolumn.
  • url: provides \url.
  • xspace: prevent a command eating space.
  • flushend: provides \flushend, balance two columns.

Controlling space

  • reduce space between float and text
\setlength{\textfloatsep}{10pt plus 1.0pt minus 2.0pt}
\setlength{\floatsep}{10pt plus 1.0pt minus 2.0pt}
\setlength{\intextsep}{10pt plus 1.0pt minus 2.0pt}
  • reduce bib item separation in biblatex
\setlength\bibitemsep{0.5\itemsep}

Commands and tools:

  • latexmk: automatically compile multiple times to resolve reference.
  • biber: replacement for bibtex for biblatex
  • texdoc: use texdoc <package> to search for a manual.

IEEE

  • proof: use \IEEEproof
  • multiple equations: use \IEEEeqnarray or array.

Uncategorized

Comments