latex notes

who forced us to use this thing

SEAN K.H. LIAO

latex notes

who forced us to use this thing

latex

oneliner ($! == last arg of last command):

1(export f=main && pdflatex $f && bibtex $f  && pdflatex $f  && pdflatex $f)>/dev/null

text

 1\textbf{bold text}
 2\textit{italics}
 3\texttt{some inline code}
 4\underline{underlined}
 5
 6\emph{context sensitive emphasis}
 7
 8\footnote{some footnote here}
 9
10\caption{a caption}
11
12\label{some:labelname}
13\ref{some:labelname}

list

1\begin{itemize}
2  \item unordered 1
3  \item unordered 2
4\end{itemize}
5
6\begin{enumerate}
7  \item ordered 1
8  \item ordered 2
9\end{enumerate}

placement

images
1\usepackage{graphicx}
2\graphicspath{ {./images/} }
3
4\begin{figure}[h]
5  \centering
6  \label{some:name}
7  \caption{This is a caption}
8  \includegraphics[width=0.4\textwidth]{name-of-image}
9\end{figure}
table

after tabular:

between lines:

1\begin{center}
2\begin{tabular}{ |c|c|c| }
3 \hline
4 cell1 & cell2 & cell3 \\
5 cell4 & cell5 & cell6 \\
6 cell7 & cell8 & cell9 \\
7 \hline
8\end{tabular}
9\end{center}
code
 1\usepackage{listings}
 2\usepackage{framed}
 3
 4\lstdefinestyle{mystyle}{
 5  frame=single,
 6  basicstyle=\ttfamily\small
 7  breakatwhitespace=false,
 8  breaklines=true,
 9  captionpos=b,
10  keepspaces=true,
11  numbers=left,
12  numbersep=5pt,
13  showspaces=false,
14  showstringspaces=false,
15  showtabs=false,
16  tabsize=2
17}
18
19% include from a file
20\lstinputlisting{file.name}
21
22% code block
23\begin{lstlisting}[caption=some caption]
24some
25large
26block
27of
28code
29\end{lstlisting}

multifile

1\usepackage{import}
2
3\newpage
4\import{tasks/}{task-4.tex}

bibliography

tex
1\usepackage{biblatex}
2\addbibresource{references.bib}
3
4\cite{somereference}
5
6
7\printbibliography
bib

reference: bibliography management

@article{an-article,
  author  = {Author 1 and Author 2},
  title   = {Some Title},
  year    = {2020},
  journaltitle = {Some Journal},
}

@report{a-technical-report,
  author  = {Author 1},
  title   = {Some Title},
  year    = {2020},
  institution = {Some Institution},
}

@manual{a-technical-manual,
  title   = {Some Title},
  year    = {2020},
}

@online{an-online-resource,
  author  = {Author 1},
  title   = {Some Title},
  year    = {2020},
  url     = {some://url},
}

@misc{anything-else,
  author  = {Author 1},
  title   = {Some Title},
  year    = {2020},
}