LaTex - cllu/.rc GitHub Wiki

There is a discussion on stackoverflow.

Squeeze spaces

vspace is the king.

  • \setlength{\abovecaptionskip}{2pt} to set the space between images and caption inside a figure

Working with tikz figures

tikz should in a separate file

% file image.tex
\documentclass[tikz]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
  \draw (0, 0) circle [radius=1];
\end{tikzpicture}
\end{document}

Then in the main file, in the preamble:

\usepackage{tikz}
\usepackage{standalone}

Then in the main tex, use \includestandalone[height=3cm]{image} (NO .tex extension).

Use source control

Bitbucket is my best choice.

Indent sentences by yourself

When writing a pragraphs, start each sentences at the beginning of a line, and if it spills over, each subsequent line is tabbed

In fact, I will indent the paragraph by sentence structure. This makes my life easier when I check the git diff.

Math

Don't use `eqnarray` as it "produces inconsistent spacing of the equal signs and make no attempt to prevent overprinting of the equation body and equation number."

define a todo tag and use it

Keep an eye on what need to be done.

% use \todo{} to highlight TODO items
\usepackage{color}
\newcommand{\todo}[1]{\textcolor{red}{[TODO: #1]}}

Some common tricks

enable figure and table caption numbers in beamer

By default, there is no number in figure/table captions. This can be fixed by adding the following to you header.

% figures and tables should be numbered
\setbeamertemplate{caption}[numbered]

Remove header and navigation icons in beamer

% remove header
\setbeamertemplate{headline}{}
% remove navigation
\setbeamertemplate{navigation symbols}{}

Commonly used snippets

% use \todo{} to highlight TODO items
\usepackage{color}
\newcommand{\todo}[1]{\textcolor{red}{[TODO: #1]}}

% use \*x instead of \mathbf{x} to save space
\def\*#1{\mathbf{#1}}
% use \norm{}  to type euclidean norm || x ||
\newcommand{\norm}[1]{\left\lVert #1 \right\rVert}
% use \abs{} to type absolute symbol
\newcommand{\abs}[1]{\left| #1 \right|}

% differentials
\renewcommand{\d}[1]{\;\textsf{d}#1}
\newcommand{\pd}[1]{\partial #1}
\newcommand{\D}{\;\textsf{D}}

% \R instead of \mathbb{R}
\newcommand{\R}{\;\textbb{R}}

Equation

As suggested in Avoid eqnarray! by Lars Madsen, we should never use eqnarray environment. Instead, use align environment provided in amsmath package(which is already included in most conference style) or equation+split environment for single equation.

\begin{align*}
  x = {} & y
           & + z \\
     = {} & y+z
\end{align*}
\begin{equation}
\begin{split}
  x & =  y
     & = y+z
\end{split}
\end{equation}

Centering

Use \centering instead of \begin{center} … \end{center} inside a figure or table environment. This center environment can cause additional vertical space.

Using macros

\documentclass{article}
\usepackage{amssymb,amsmath}

\newcommand{\R}{{\mathbb R}}
\renewcommand{\vector}[1]{(x_1,x_2,\ldots,x_{#1})}
\newcommand{\avector}[2]{(#1_1,#1_2,\ldots,#1_{#2})}
\newcommand{\aDEFvector}[2][a]{(#1_1,#1_2,\ldots,#1_{#2})}

\begin{document}

Consider the following vectors with entries in $\R$: $\mathbf
x=\vector{6}$, $\mathbf u=\avector{u}{7}$, $\mathbf a=\aDEFvector{8}$,
$\mathbf w=\aDEFvector[w]{n+1}$.

\end{document}

Install getnonfreefonts

http://tug.org/fonts/getnonfreefonts/

$ sudo su
# PATH=$PATH:/usr/local/texlive/2015/bin/x86_64-darwin/ texlua install-getnonfreefonts

You would encounter

$ /usr/local/texlive/2015/bin/x86_64-darwin/getnonfreefonts -l
sh: kpsewhich: command not found
! ERROR: The variable TEXMFHOME is not set.

Try set the TEXMFHOME by:

/usr/local/texlive/2015/bin/x86_64-darwin/tlmgr conf texmf TEXMFHOME "~/Library/texmf"

credit

Not working?

PATH=$PATH:/usr/local/texlive/2015/bin/x86_64-darwin/ TEXMFHOME=/Users/cllu/Library/texmf /usr/local/texlive/2015/bin/x86_64-darwin/getnonfreefonts -l
⚠️ **GitHub.com Fallback** ⚠️