Jon Dehdari



How do I do X in LaTeX?


How do I do squiggly lines in LaTeX?

\usepackage[normalem]{ulem}	% Part of the standard distribution
...
\uwave{text goes here}
	

How do I do strikethrough lines in LaTeX?

For normal text,
\usepackage[normalem]{ulem}	% Part of the standard distribution
...
\sout{text goes here}
	

For math mode,

\usepackage{cancel}		% Part of the standard distribution
...
\cancel{math text goes here}
	

How do I use my favorite TrueType font (TTF) in LaTeX?

Use the command lualatex or xelatex   – both of which are included in TeXLive, MikTeX, and MacTeX – and in the preamble add the following:
\usepackage{fontspec}
\setmainfont{Arial Unicode}	% For example
	
This also works for OpenType fonts (OTF), which is a superior format.

The above command sets that font for the entire document. If you want to use a special font for just a snippet of text, do the following:

\usepackage{fontspec}
\newfontfamily\myfont{Arial Unicode}
...
Foo \myfont{bar} baz
	

How do I do hanging/old-style numbers in LaTeX?

You can get them by using Palatino, one of the finest and most mature fonts available. However, avoid the palatino package itself.
\usepackage[osf]{mathpazo}	% Mathpazo package includes accompanying math fonts
	

How do I draw dependency arrows in LaTeX?

One way is to use the tree-dvips package, part of the texlive-humanities package in Debian/Ubuntu. Unfortunately you'll need to run the old-fashioned latex, dvipdf sequence since it depends on PostScript code.
\usepackage{tree-dvips}
...
\node{the}{the} \node{dog}{dog} \node{eats}{eats} \node{food}{food}

\anodecurve[t]{the}{dog}{1.1em}
\anodecurve[t]{eats}{the}{1.8em}
\anodecurve[t]{eats}{food}{1.2em}
	
Dependency arrows with tree-dvips

How do I get argmax in LaTeX formulas?

\DeclareMathOperator*{\argmax}{arg\,max}   % In your preamble
...
\argmax_{...}                              % In your formula
	

How do I get really really small fonts in LaTeX?

For a font smaller than \tiny (or larger than \Huge), add the following in your preample:
\def\Tiny{ \font\Tinyfont = cmr10 at 3pt \relax  \Tinyfont}
	
Now you can use {\Tiny ... }. Replace the 3pt with any positive real-numbered value as you see fit. Unfortunately this only uses Computer Modern fonts with the roman typeface.

A less robust, but more elegant solution is to put the following command in your preamble:

\def\Tiny{\fontsize{5pt}{5pt} \selectfont}
	
The usage is the same as before, but this only scales down to 5pt. It works with most fonts. You can use the type1cm package for smaller sizes.

A really robust, but very different way is to use the \scalebox command from the graphicx package:

\usepackage{graphicx}                        % In your preamble.
...
\scalebox{0.20}{Really small text here}
	
You could of course define a macro in your preamble using this:
\usepackage{graphicx}                        % In your preamble.
\newcommand{\teeny}[1]{\scalebox{0.20}{#1}}  % In your preamble
...
\teeny{Really small text here, with math $\alpha_i$}
	

How do I get bold Greek letters in math mode?

This is one of the lamest quirks about LaTeX 2ε. Anyways, here's the sad answer:
\usepackage{amsmath}	% In your preamble.  or \usepackage{amsbsy}
...
$\boldsymbol{\lambda}$
	
If   \boldsymbol{}   still doesn't work (like for ∑, ∏, ∫, etc.), then use the "poor man's bold", a bunch of jittered copies:
$\pmb{\sum}$
		

How do I prevent a linguistic gloss from getting split across pages?

Use the samepage environment around the whole block.
    \begin{samepage}
    \exg. Dies ist eine erste Glosse \\
          This is a first gloss

    \end{samepage}
	
The above example uses the Linguex package, but the samepage environment should work for others as well.

How do I do multi-line comments or verbatims?

\usepackage{verbatim}	% Part of the standard distribution
...
\begin{comment}
This is a comment
!@#$%^&*()_+{}|\][:";'<>?,./
This is another comment
\end{comment}
	
The verbatim package also supports multiple line verbatims, using the verbatim environment.

How do I do use the verbatim package in Beamer?

Set your frame to fragile:
\usepackage{verbatim}  % Part of the standard distribution
...
\begin{frame}[fragile]
\frametitle{The Frame Title}
\begin{verbatim}
!@#$%^&*()_+{}|\][:";'<>?,./
\end{verbatim}
\end{frame}

	

How do I do hanging indents?

The easiest way is to use the description environment, with argumentless items:
\begin{description}
  \item Text goes here
  \item More text goes here
\end{description}
	

How do I do force math-mode subscripted items underneath, in running text or in fractions?

Instead of the underscore _ use \limits_ :
	... so that we have $ \sum\limits_{i \in C} g(i)$ and then ...
	
	\begin{equation}
		r = \frac{ \sum\limits_{j=1} f(i) }{Z}
	\end{equation}
	
Use judiciously.

How do I put a big "DRAFT" stamp across the first page of my document?

\usepackage[firstpage]{draftwatermark}  % Not part of the standard distribution.
	
Download the package at CTAN . If you want the message on every page, remove the optional argument, so just \usepackage{draftwatermark} . You can customize or change the message, such as \SetWatermarkText{Hi!} . See the documentation for more details.

How do I produce an A4 (or Letter) document?

Current LaTeX distributions do not honor the page dimensions option (eg. a4paper or letterpaper) to your \documentclass command very well. You can put the following TeX commands in your preamble:
\pdfpagewidth=210 true mm
\pdfpageheight=297 true mm
	
Another solution is to use the geometry package, as:
\usepackage[a4paper]{geometry}   % Part of the standard distribution
	
This is a great package, but it will change your default margins as well. Manually adjusting the margins with this package is pretty easy; see the documentation for details.

How do I do inline comments?

\newcommand{\comment}[1]{}
...
Hello \comment{My Comment} world
	

How do I extract a vector image from a PDF, to use in my LaTeX document?

One relatively easy way is to use Inkscape, an excellent Free vector graphics program.
  1. Open the PDF in Inkscape, selecting the page number that the image is found on.
  2. Select the entire range of the image, from one corner of a rectangle that would enclose it, to the opposite corner.
  3. Copy the selection, using the usual Control-C or clicking Edit->Copy.
  4. Create a new document, either by typing Control-N or clicking the top-left icon.
  5. Paste the saved image selection into the new document, using the usual Control-V or clicking Edit->Paste.
  6. Go to the Document Properties dialog box, either by typing Shift-Control-D or clicking File->Document Properties.
  7. Click on "Resize Page to Content", then on the button "Resize Page to Drawing or Selection"
  8. Now save the new document, either by the usual Control-S or clicking File->Save.
  9. In the bottom-right corner, choose the file type Portable Document Format (PDF).
  10. You can leave most of the defaults, although I recommend making sure that the button "Convert texts to paths" is unchecked. This will allow text in the image to be searchable in your LaTeX document.
  11. Now you can use this image PDF as a normal image in your LaTeX file, using the usual \includegraphics{} command (from the graphicx package).
  12. Enjoy your awesome document! Don't forget to cite the original authors in your caption.


`` '' –LaTeX