Advanced & Layout

Spacing, Layout, Beamer & TeX Internals

Fine-tune page margins, spacing lengths, Beamer presentation slides, collaborative drafting annotations, and low-level macro expansion.

Spacing & Page Layout

Spacing & Page Layout

Comprehensive syntax, arguments, options, and copyable snippets for spacing & page layout.

Command

\quad

Horizontal space (1 em)

Example Code
$a \quad b$
Command

\qquad

Horizontal space (2 em)

Example Code
$a \qquad b$
Command

\,

Thin space

Example Code
$dx\,dy$
Command

\:

Medium space

Example Code
$a\:b$
Command

\;

Thick space

Example Code
$a\;b$
Command

\!

Negative thin space

Example Code
$a\!b$
Command Mandatory { }

\hspace{length}

Inserts horizontal space of given length

Example Code
\hspace{1cm}
Command Mandatory { }

\vspace{length}

Inserts vertical space of given length

Example Code
\vspace{1cm}
Command Mandatory { }

\hspace*{length}

Horizontal space that is not removed at line breaks

Example Code
\hspace*{1cm}
Command Mandatory { }

\vspace*{length}

Vertical space that is not removed at page breaks

Example Code
\vspace*{1cm}
Command

\smallskip

Small vertical space

Example Code
\smallskip
Command

\medskip

Medium vertical space

Example Code
\medskip
Command

\bigskip

Large vertical space

Example Code
\bigskip
Command

\noindent

Suppresses paragraph indentation

Example Code
\noindent This paragraph is not indented.
Command

\indent

Forces paragraph indentation

Example Code
\indent This paragraph is indented.
Command Mandatory { }

\setlength{\cmd}{length}

Sets a length register

Example Code
\setlength{\parindent}{0pt}
Command Mandatory { }

\addtolength{\cmd}{length}

Adds to a length register

Example Code
\addtolength{\textwidth}{2cm}
Command Mandatory { }

\newlength{\cmd}

Defines a new length register

Example Code
\newlength{\mylength}
Command

\parindent

Length register for paragraph indentation

Example Code
\setlength{\parindent}{15pt}
Command

\parskip

Length register for space between paragraphs

Example Code
\setlength{\parskip}{6pt}
Command

\baselineskip

Length register for line spacing

Example Code
\setlength{\baselineskip}{14pt}
Command

\textwidth

Length register for text block width

Example Code
\includegraphics[width=\textwidth]{fig.png}
Command

\textheight

Length register for text block height

Example Code
\setlength{\textheight}{22cm}
Command

\linewidth

Length register for current line width

Example Code
\includegraphics[width=0.5\linewidth]{fig.png}
Beamer Presentations

Beamer Presentations

Comprehensive syntax, arguments, options, and copyable snippets for beamer presentations.

Command Mandatory { }

\frame{content}

Creates a beamer slide (short form)

Example Code
\frame{\frametitle{Intro}Content here.}
Environment Mandatory { }

\begin{frame}...\end{frame}

Creates a beamer slide

Example Code
\begin{frame}
\frametitle{Introduction}
Slide content.
\end{frame}
Command Mandatory { }

\frametitle{text}

Sets the title of a beamer frame

Example Code
\frametitle{Results}
Command

\pause

Pauses slide reveal in beamer

Example Code
First point.
\pause
Second point.
Command Mandatory { }

\usetheme{name}

Sets the beamer presentation theme

Example Code
\usetheme{Madrid}
Command Mandatory { }

\usecolortheme{name}

Sets the beamer color theme

Example Code
\usecolortheme{beaver}
Drafting & Annotations (todonotes)

Drafting & Annotations (todonotes)

Comprehensive syntax, arguments, options, and copyable snippets for drafting & annotations (todonotes).

Command Mandatory { }

\todo{text}

Inserts a visible margin note for draft revisions (todonotes package)

Example Code
\todo{Check this citation}
Command

\listoftodos

Generates a list of all \todo notes (todonotes package)

Example Code
\listoftodos
Command Mandatory { }

\marginpar{text}

Places a note in the page margin (base LaTeX)

Example Code
\marginpar{See note}
Command

\linenumbers

Turns on line numbering for the document (lineno package)

Example Code
\linenumbers
Miscellaneous Utilities

Miscellaneous Utilities

Comprehensive syntax, arguments, options, and copyable snippets for miscellaneous utilities.

Command

\newif\ifname

Defines a new boolean/conditional

Example Code
\newif\ifdraft
Command Mandatory { }

\ifthenelse{cond}{true}{false}

Conditional logic (ifthen package)

Example Code
\ifthenelse{\value{page}=1}{First page}{Other page}
Command

\today

Inserts the current date

Example Code
\today
Command

\LaTeX

Typesets the LaTeX logo

Example Code
Typeset with \LaTeX.
Command

\TeX

Typesets the TeX logo

Example Code
Built on \TeX.
Command Mandatory { }

\thanks{text}

Adds a footnote to the title/author

Example Code
\author{Deb\thanks{Corresponding author}}
Command

\protect

Protects a fragile command

Example Code
\section{A \protect\footnote{note} here}
Command

\verb|text|

Inline verbatim text

Example Code
\verb|print(x)|
Command Mandatory { }

\newcounter{name}

Defines a new counter

Example Code
\newcounter{example}
Command Mandatory { }

\setcounter{name}{value}

Sets a counter's value

Example Code
\setcounter{example}{5}
Command Mandatory { }

\addtocounter{name}{value}

Adds to a counter's value

Example Code
\addtocounter{example}{1}
Command Mandatory { }

\stepcounter{name}

Increments a counter by one

Example Code
\stepcounter{example}
Command Mandatory { }

\arabic{counter}

Prints counter in Arabic numerals

Example Code
\arabic{page}
Command Mandatory { }

\roman{counter}

Prints counter in lowercase Roman numerals

Example Code
\roman{page}
Command Mandatory { }

\Roman{counter}

Prints counter in uppercase Roman numerals

Example Code
\Roman{chapter}
Command Mandatory { }

\alph{counter}

Prints counter as lowercase letter

Example Code
\alph{enumi}
Command Mandatory { }

\Alph{counter}

Prints counter as uppercase letter

Example Code
\Alph{enumi}
Low-Level TeX & Macro Expansion

Low-Level TeX & Macro Expansion

Comprehensive syntax, arguments, options, and copyable snippets for low-level tex & macro expansion.

Command

\makeatletter

Allows @ to be used in internal command names, for redefining package internals

Example Code
\makeatletter
Command

\makeatother

Restores @ to its normal catcode after \makeatletter

Example Code
\makeatother
Command

\expandafter

Delays expansion of the following token by one step (TeX primitive)

Example Code
\expandafter\def\csname foo\endcsname{bar}
Command

\csname...\endcsname

Builds a control sequence name from text, useful for dynamic command names (TeX primitive)

Example Code
\csname mycommand\endcsname
Command

\let\name=\other

Makes one command an alias/copy of another

Example Code
\let\oldsection\section
Command Mandatory { }

\def\name{def}

Low-level TeX command definition (plain TeX primitive)

Example Code
\def\half{\frac{1}{2}}
Command

\global

Makes the following assignment or definition apply globally, ignoring group scope

Example Code
\global\def\name{value}
Command Mandatory { }

\NewDocumentCommand{\name}{args}{def}

Modern flexible command definition with typed arguments (xparse package)

Example Code
\NewDocumentCommand{\greet}{m}{Hello, #1!}