Notes on LaTeX
Typesetting isn't that easy
By Harshvardhan in package
June 19, 2021
Cosmetics
-
Bold math symbols: Use the command
\mathbf{}
to write bold faced symbols like matrix variables. -
Margins: The easiest way is to add
\usepackage[margin=0.5in]{geometry}
in the preamble. -
Outer quotes: Latex doesn’t understand " as outer quotes. By default, you have to use ``. Here is a way out.
\usepackage [autostyle, english = american]{csquotes}
\MakeOuterQuote{"}
-
Some handy commands:
\hfill, \vfill, \hskip, \vskip, \hspace, \vspace
. Just Google to know their usage. They’re needed for extra spaces here and there in Latex documents. -
Horizontal Line:
\hrulefill
for all non-tabular environments.
Images
- Inserting Images: Use \usepackage{graphicx,graphics} in preamble. Then, add image with the following code block.
\begin{figure}
\centering
\includegraphics[width=5in]{example.png}
\caption{An example of fitting \texttt{GP} model in 1-d function with seven data points.}
\label{fig:example}
\end{figure}
Tables
- Inserting Table: Use Table Generator online. Create the schema and then fill in the content.
Exact Math Symbols
- argmin and argmax: Use this in preamble:
\DeclareMathOperator*{\argmax}{argmax}
\DeclareMathOperator*{\argmin}{argmin}
Then, \underset{x} \argmax f(x)
or \underset{x} \argmax f(x)
. This might not be very right according to this thread, but okay – it serves the purpose. If you find something better, tell me.
-
Sum (Sigma):
\sum_{i = 1}^{n} x_n
-
Integral:
\int_a^b f(x) \di x
-
Tab: The simple tab (horizontal space) can be worked with
\quad
. -
Drawing any symbol: It is difficult to find the appropriate symbol every time, so use Detexify to identify what you need.
-
Writing algorithms in LaTeX. Use
algorithm
andalgorithmic
. See this article for quick review.
Typesetting Exactly
- To place pictures exactly in a slide, use tikz package. Exact coordinates by cm:
\begin{tikzpicture}[remember picture,overlay]
%% (x coord, y coord) -> (0 cm, 6.5 cm)
\node[anchor=south west,inner sep=0pt] at ($(current page.south west)+(0cm,6.5cm)$) {
{picture.png}
};
\end{tikzpicture}
The best part is that it also works for exact text placements.
Referencing and Cross-referencing
- Bibliography and References: Understand that in most academic writings they are different and Latex considers references as default. To add them, add following lines at the end of file, just before
\end{document}
.
\bibliographystyle{apalike}
\bibliography{bibfile}
Don’t forget to add \usepackage{natbib}
in the preamble. Note that bibfile.bib contains all bibliographies. If you can’t get the BibTeX citations right, use Google Scholar.
- Citations Generator: Use this tool online to generate citations: https://truben.no/latex/bibtex/.
Meta
-
New Commands: Outline format is
\newcommand{newname}{definition}
. See this and this for more details. -
Style File (
.sty
): Basically, they’re instructions that can be used to redefine the preexisting values in the document. See my Github for two examples that I’ve created - one for homework assignments and other for IIM Indore’s official presentation.
Templates
-
Overleaf Gallery is the best. Otherwise, you can find some repositories on Google.
-
By Me: If you are searching for reports or presentations, or are an IIM Indore student looking for presentations, check my templates.