Classes - Beard

You are here: start » latex_hints » latex_tips_sheet_code



Source code to generate LaTeXTips.pdf

PDF link: LaTeXTips.pdf

\RequirePackage[l2tabu, orthodox]{nag}




% Use the T1 font encoding (which has more symbols) instead of the default OT1


	pdfauthor={Brandon Carroll},
	pdftitle={LaTeX Tips},

% Disable page numbering

% Disable right justification

% Disable column length balancing

% Disable indentation of paragraphs

% Set the weight of the vertical line between columns and the amount of space between columns for the multicols environment

% Set up a length variable for hanging indentation (1st line of paragraph not indented, subsequent lines are)

% Command to insert a horizontal line with a little extra space
\newcommand{\sectionLine}{\vspace{2pt} \hrule height 1pt \vspace{2pt}}

% Define a shorter command to insert a backslash for convenience

% Define an environment to keep a block of text together (no column or page breaks allowed in it).
% It takes the title of the block of text as a parameter, sets up a hanging indent, and inserts a line at the end of the block of text.
			\textbf{\normalsize #1}

% Define an environment that indents its text.
% (The list environment is commonly used for defining more specific environments.)
% Commands to format indefinite and definite integrals
\newcommand{\indefint}[2]{\ensuremath{\int \! #1 \, \mathrm{d} #2}}
\newcommand{\defint}[4]{\ensuremath{\int_{#1}^{#2} \! #3 \, \mathrm{d} #4}}

% Define a limit-in-the-mean operator
\DeclareMathOperator*{\limInMean}{l.\! i.\! m.}


		\textbf{\LARGE \LaTeX{} Tips}
		\begin{noteblock}{Helpful websites}
			Beginner tutorials: \url{}
			Tutorials and general reference: \url{}
			List of commands: \url{}
			List of symbols: \url{}
			Hand-drawn symbol recognition: \url{}
			Q \& A Forum: \url{}
			LaTeX source code for this document: \url{svn+ssh://}
		\begin{noteblock}{Common packages}
			Import a package with \texttt{\bs usepackage\{packageName\}}
			amsmath -- Math typesetting and environments
			amssymb -- Lots of symbol defintions.
			amslatex -- Provides the multline environment.
			graphicx -- Used to include graphics, images, etc.
			hyperref -- Creates bookmarks and clickable links in the pdf.
		%\begin{noteblock}{Math mode}
			%Inline math mode: \texttt{\$\ldots\$} or \texttt{\bs (\ldots\bs )}
			%Display math mode: \texttt{\$\$\ldots\$\$}, \texttt{\bs{[}\ldots\bs{]}}
			%Useful math environments: equation (for single equation), align (for multiple equations), multline (for equations that are too long to fit on one line)
			%Subscripts and superscripts: 
			%\texttt{\$a\_b\$} gives $a_b$, \texttt{\$a\_\{bc\}\$} gives $a_{bc}$,
			%\texttt{\$a\char`^b\$} gives $a^b$, \texttt{\$a\char`^\{bc\}\$} gives $a^{bc}$
			%Use built in commands for math functions: \texttt{\$\bs sin\bs theta\$} gives $\sin\theta$.  Don't use \texttt{\$sin\bs theta\$}, which gives $sin\theta$.
			%Fractions: \texttt{\$\bs frac\{a+b\}\{c\}\$} gives $\frac{a+b}{c}$.
		\begin{noteblock}{The align environment}
			The \texttt{\&} symbol toggles between signaling alignment and signaling column breaks.
			A double backslash (\texttt{\bs\bs}) starts a new line.
			Put \texttt{\bs label} commands before the \texttt{\bs\bs}.
			The \texttt{align$^*$} environment omits the equation numbers.
			For example, \\*
				\texttt{\bs begin\{align\}} \\*
					\texttt{x\_1\&=a+b \ \ \ \ \& \ \ \ \ x\_2\&=c+d \bs label\{eq1\} \bs\bs} \\*
					\texttt{x\_3\&=a+b+c+d \& x\_3-x\_2\&=x\_1 \bs label\{eq2\}} \\*
				\texttt{\bs end\{align\}}			
				x_1&=a+b     & x_2&=c+d \label{eq1} \\ 
				x_3&=a+b+c+d & x_3-x_2&=x_1 \label{eq2}
			Include the graphicx package: \texttt{\bs usepackage{[pdftex]}\{graphicx\}}.
			You can specify the folders that the figures are in: \texttt{\bs graphicspath\{\{folder1/\}\{folder2/figs/\}\}}.
			Tell it what file types to look for with \texttt{\bs DeclareGraphicsExtensions\{.pdf,.jpg,.png\}}.
			Example: \\*
				\texttt{\bs begin\{figure\}} \\*
					\texttt{\bs centering} \\*
					\texttt{\bs includegraphics{[width=3in]}\{filename.pdf\}} \\*
					\texttt{\bs caption\{Caption text here\}} \\*
					\texttt{\bs label\{fig1\}} \\*
				\texttt{\bs end\{figure\}}
			The \texttt{\bs label} command must come after the \texttt{\bs caption} command for references to work correctly.
			If you put the \texttt{\bs caption} command before the \texttt{\bs includegraphics} command, then the caption will appear above the figure.
			Use \texttt{\&} to break columns and \texttt{\bs\bs} to start a new line.
			Environments: matrix (no brackets), bmatrix (square brackets), Bmatrix (curly braces), pmatrix (parentheses), vmatrix (vertical bars), and Vmatrix (double vertical bars).
					\texttt{\bs( \bs begin\{bmatrix\}}
						\texttt{a \& b \& c \bs\bs} \\
						\texttt{d \& e \& f}
					\texttt{\bs end\{bmatrix\} \bs)}
						a & b & c \\
						d & e & f
			The \texttt{\bs !} command produces a small negative horizontal space (so \texttt{a\bs !a} produces a\!a).
			The following commands produce increasing amounts of horizontal space: \:	\texttt{\bs,} \: \texttt{\bs:} \: \texttt{\bs;} \: \texttt{\bs quad} \: \texttt{\bs qquad}.
			The \texttt{\bs hspace} command produces a specified amount of horizontal space (so \texttt{|\bs hspace\{.5cm\}|} produces |\hspace{.5cm}|).
			The \texttt{\bs vspace} command produces a specified amount of vertical space (the amount can be negative).
			Units of length that can be used: \texttt{pt}, \texttt{mm}, \texttt{cm}, \texttt{in}, \texttt{ex}, \texttt{em}.
		\begin{noteblock}{Custom commands}
			Define new commands with \texttt{\bs newcommand\{\bs commandName\}\{commandDefinition\}}.
			This will cause any instances of \texttt{\bs commandName} to be replaced with \texttt{commandDefinition}.
			To define commands that accept parameters, specify the number of parameters and use \texttt{\#N} in the command definition to substitute in the parameter: 
			\texttt{\bs newcommand\{\bs commandName\}{[numParams]}\{definition\}}.
			Example (a command to format an indefinite integral): 
			\texttt{\bs newcommand\{\bs indefint\}{[2]}\{\bs ensuremath\{\bs int\bs !\#1 \bs, \bs mathrm\{d\} \#2\}\}}
			causes \texttt{\bs indefint\{x(t)\}\{t\}} to be formatted as \indefint{x(t)}{t}.
		\begin{noteblock}{Custom math operators}
			You can use the \texttt{\bs DeclareMathOperator} command to define your own math operators (like the built in \texttt{\bs sin} and \texttt{\bs lim} operators).
			The \texttt{\bs DeclareMathOperator$^*$} version of the command will put superscripts and subscripts above and below the operator (like \texttt{\bs lim} does).
			Example: \texttt{\bs DeclareMathOperator$^*$\{\bs limInMean\}\{l.\bs !i.\bs !m.\}} causes 
			\texttt{\bs limInMean\_\{x \bs rightarrow 0\}f(x)} to produce 
			\( \displaystyle\limInMean_{x \rightarrow 0}f(x) \).
		\begin{noteblock}{Miscellaneous tips}
			You usually need to compile several times for all the cross references to get resolved (no warnings).
			The \texttt{\bs input\{fileName\}} command will insert all the text from fileName.tex into the document when compiled.
			The \texttt{\bs today} command will be replaced with the current date when the document is compiled.
			The \texttt{\bs ensuremath} command can be used to define commands that work either in or out of math mode.  
			E.g. \texttt{\bs newcommand\{\bs azimuth\}\{\bs ensuremath\{\bs alpha\_\{az\}\}\}}.
			\texttt{\$\bs mathcal\{ABCDEF\}\$} gives $\mathcal{ABCDEF}$.
			\texttt{\$\bs mathbb\{ABCDEF\}\$} gives $\mathbb{ABCDEF}$.
			You can easily set margins with the geometry package: 
			\texttt{\bs usepackage{[}top=1in,left=.5in,right=.5in, bottom=1in{]}\{geometry\}}
			LaTeX ignores spaces after command names with no parameters.  You can force spaces with either \texttt{\bs\textvisiblespace} or by placing \texttt{\{\}} after the command.
			%Descriptive subscripts to variables should be romanized with the \texttt{\bs mathrm\{\}} command: \( (p_\mathrm{n}, p_\mathrm{e}, p_\mathrm{d}) \), not \( (p_n, p_e, p_d) \).
			Don't just type words while in math mode---it will space the letters like a bunch of single letter variables multiplied together.  
			Put words in a \texttt{\bs mathit\{\}} or \texttt{\bs mathrm\{\}} command depending on if they should be italicized (variable names) or romanized.
			I.e., $\mathit{variable}_\mathrm{min}$ should not look like $variable_{min}$.
			If missing packages don't download automatically, you can use the MiKTeX Package Manager to download them manually.
			In TeXnicCenter, F9, F10, and F11 cycle through errors, warnings, and bad boxes respectively.
			In TeXnicCenter, ctrl-q comments out the selected block of code and ctrl-w uncomments.