LaTeX Tricks
LaTeX Space
Space between Columns: Reduce Column Paddings
\setlength{\tabcolsep}{-2pt} % set length to -2pt
\addtolength{\tabcolsep}{-2pt} % reduce space by -2pt
Space between Rows:
\def\arraystretch{1.5}
Horizontal Alignmenti (requires package array)
p{width} % equivalent to \parbox[t]{width}
m{width} % centered vertically
b{width} % equivalent to \parbox[b]{width}
\newcolumntype{C}[2]{>{\centering\arraybackslash\hspace{#1}}m{#2}}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
\begin{tabular{|C{-1mm}{20mm}|c|c|c|}
Wide Table Option: Shrink Table to Width
\resizebox{\columnwidth}{!}{ \begin{tabular}{} ... \end{tabular} }
Math Space
\arraycolsep=5pt % distance between 2 columns
\thinmuskip=3mu % space between ordinary and operator atoms
\medmuskip=4mu plus 2mu minus 4mu % space between ordinary and binary atoms
\thickmuskip=5mu plus 5mu % space between ordinary and relation atoms
Vertical Space:
\setlength\jot{-30pt}
\renewcommand\arraystretch{1}
\def\>{\mskip\medmuskip}
\def\;{\mskip\thickmuskip}
\def\!{\mskip-\thinmuskip
Before/After Math Expressions:
\abovedisplayskip=12pt plus 3pt minus 9pt
\belowdisplayskip=12pt plus 3pt minus 9pt
\abovedisplayshortskip=0pt plus 3pt
\belowdisplayshortskip=7pt plus 3pt minus 4pt
Iteration and Emulation Space
\def\itemhook{\topsep=1ex \itemsep=0ex}
\def\enumhook{\topsep=0ex \itemsep=0ex}
\def\descripthook{\topsep=0ex \itemsep=0ex}
Heading Space
\usepackage[medium,compact]{titlesec}
\titlespacing*{\section}{0pt}{*0.8}{*0.8}
\titlespacing*{\subsection}{0pt}{*0.8}{*0.8}
\titlespacing*{\subsubsection}{0pt}{*0.3}{*0.3}
Caption Space
\abovecaptionskip=3pt % above caption
\belowcaptionskip=3pt % below caption
Vertical Space for Flating
\textfloatsep=3pt % between top and bottom of float and text
\intextsep=3pt % between floats
Modify Enumeration:
\renewcommand{\labelenumi}{[\Alph{enumi}]}
Figure
Wrapfigure: Required package: wrapfig
\begin{wrapfigure}[16]{r}{0.6\textwidth} % [16] is optional, generally works better
\vspace{-20pt}
\includegraphics[width=0.59\textwidth]{Figure}
\caption{Figure Caption} \label{Fig:Caption}
\vspace{-20pt}
\end{wrapfigure}
Side-by-side figures
\begin{figure}
\centerinn{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=\textwidth]{Figure-1}
\captionof{figure}{Figure 1 Caption}
\label{Figure-1-label}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=\textwidth]{Figure-1}
\captionof{figure}{Figure 2 Caption}
\label{Figure-2-label}
\end{minipage}
\end{figure}
Subfig: Required package: subfig
\begin{figure}
\centering
\subfloat[Caption 1\label{fig1}]{
\includegraphics[width=3in]{figure1}
}
\quad
\subfloat[Caption 2\label{fig2}]{
\includegraphics[width=3in]{figure2}
}
\caption{Caption of the entire figure}
\end{figure}
Change Figure Directory: \graphicspath{ {./Figures/} }
Rename Caption: \renewcommand{\figurename}{Fig.}
Include PDF File
Required package: pdfpages
\includepdf[pages={1-},noautoscale]{PDF-page-file}
Over- and underbrackets
\underbrace{...}
\underbracket[LineThickness][Height]{...}
\overbrace{...}
\overbracket[LineThickness][Height]{...}
Font Packages
\usepackage{times} similar to \usepackage{mathptm}
\usepackage{fourier}
\usepackage{palatino} similar to \usepackage{mathpple}
\usepackage{bookman} % very wide fonts
\usepackage{charter}
\usepackage{newcent}
Using algorithmic package
\IF{condition} \STATE \ELSE \STATE \ENDIF
\FOR{condition} \STATE \ENDFOR
\FOR{condition} \TO {condition} \STATE \ENDFOR
\FORALL{condition} \STATE \ENDFOR
\WHILE{condition} \STATE \ENDWHILE
\REPEAT \STATE \UNTIL {condition}
\LOOP \STATE \ENDLOOP
Change Floatname: \floatname{algorithm}{Protocol}
Using algorithm in beamer
Problem: The algorithm floating does not work well with beamer.
Solution: \begin{algorithm}[H]...\end{algorithm}
Remove beamer navigation symbols
\beamertemplatenavigationsymbolsempty
Other Links
Squeezing Space in LaTeX
LaTeX Math Symbols
Detexify Symbol Table
Math Mode
LaTeX Color