Latex Notes

This is a summary of some of the things I learned about using latex. This post is being constantly updated over the years. (Every time I learn something new, I will update this document).

I am breaking this notes into several sections, including Math symbols, Bibliography, Text highlighting and organization and Figures.

Figures

  1. 0.5textwidth is half a page, good for two column publications
  2. Placement of figures (horizontally in two columns) in a separate post
    1. https://yunmingzhang.wordpress.com/2016/01/07/how-to-horizontally-place-figures-in-latex/
  3. Crop images
    1. images are often too big with lots of white space, we can use trim command to do it, the order is the following
      1. An example: \includegraphics[trim={5cm 0 0 0},clip]{example-image-a}
      2. The order: trim={<left> <lower> <right> <upper>}
        1. Pitfall: be careful not trimming out the legends or the axis labels
  4. ImageWidth
    1.  \includegraphics[page=1,trim=4cm 11cm 0cm 0cm, clip, width=1.5\linewidth]
  5. Caption
    1. adjust width: use package caption, and then do
      1. captionsetup{width=\columnwidth}
    2. adjust the starting point, shift caption to the right
      1.  \captionsetup{oneside,margin=25pt}

Math

  1. math symbols
    1. need to start and end with $ symbols, $ math symbols $
    2. $ \left|V\right| $ for absolute value |V|
  2. display a percent sign
    1. percentage: \%
  3. x (4x speedup or multiplication)
    1. $\times$

Text

  1. \textit for specific optimization’s name
  2. \paragraph for highlighting the starting word of the paragraph
  3. \noindent to start the paragraph without indentation
  4. \bf for bold font
  5. underscore, \texttt{\_testtext}
    1. http://tex.stackexchange.com/questions/48632/underscores-in-words-text

Bibliography

  1. use {{paper Name}} in the bibliography to keep the caption of letters. you can also do {paper {N}ame}, but it is a lot more annoying.
  2. use /url package when trying to insert a URL. This avoids latex’ issues displaying with weird special characters such as “_” and “~” in the url
  3. IEEE bibliography package doesn’t show the “url” field

 

Define useful commands

  1. \newcommand\punt[1]{}      \\use \punt { } as comment
  2. \newcommand\TODO[1]{\mbox{\textcolor{red}{#1}}}   \\ TODO command
  3. \newcommand{\segmenting}{CSR segmenting}    \\if we are not sure what command to use

 

Useful tricks to save space (Credit to Professor Matei Zaharia)

add the following packages

\usepackage[font={small}, skip=6pt,belowskip=-10pt]{caption}

\usepackage[belowskip=2pt]{subcaption}

\usepakage[small, compact]{titlesec}

remove the following

\captionsetup[figure]{labelfont=bf,textfont=bf}

 

\newenvironment{denseitemize}{
\begin{itemize}[topsep=2pt, partopsep=0pt, leftmargin=1.5em]
\setlength{\itemsep}{4pt}
\setlength{\parskip}{0pt}
\setlength{\parsep}{0pt}
}{\end{itemize}}

 

In  the algorithm environment, use \small immediately after the begin of the environment

\begin{algorithm}
\small

change the fonts to make it smaller

\usepackage{times}
\usepackage{microtype}

Figures often do not need to occupy the full \columnwidth or \textwidth

use a percentage can often save a lot of space. [width=0.8\textwidth]

References

Useful commands from Supertech Group at MIT,

\newcommand{\secref}[1]         {Section~\ref{sec:#1}}

\newcommand{\figref}[1]         {Figure~\ref{fig:#1}}

\newcommand{\tabref}[1]         {Table~\ref{tab:#1}}

Author information 

The new \authorinfo command is fairly easy to use, here is the default example. The second one is particularly useful for the cases where you want to put multiple authors in the same line.

%\authorinfo{Name1}
% {Affiliation1}
% {Email1}
%\authorinfo{Name2\and Name3}
% {Affiliation2/3}
% {Email2/3}

For multiple emails sharing the suffix, do

\authorinfo{author1,author2}

{affiliation}

{$\left\{author1,author2}\right\}&@gmail.com }

You can use

\autorinfo{author1, author2 \\ author3} to control authors in different lines.

Or, you can do everything by hand with this cool use of the basic \author{}

\author{Yunming Zhang,  $^\dag$Person2 \\Aff1, $^\dag$Aff2}

Show algorithms

The official documentation

http://tug.ctan.org/macros/latex/contrib/algorithmicx/algorithmicx.pdf

algorithmic[1] is with line number, [0] is without line number.

Usually lines begin with \Statement,

Common commands include \Procedure \EndProcedure, \Comment (usually following  \Satement) …

Always begin and end statements with $, this can significantly shorten the lines (pack the content close to each other).

For example,

\Statement $a\gets b$

You can also set the location of the algorithm like a normal float environment.

\begin{algorithm}[t]

Advertisements
This entry was posted in Latex. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s