Comprehensive LaTeX reference with commands, templates, and troubleshooting for document typesetting
Comprehensive assistance with LaTeX document preparation, typesetting, and formatting. This skill provides quick references, templates, and troubleshooting for academic papers, presentations, reports, and technical documents.
This skill should be triggered when:
\documentclass{article} % or book, report, beamer
\usepackage{graphicx} % For images
\usepackage{amsmath} % For math
\usepackage{hyperref} % For hyperlinks
\title{Document Title}
\author{Author Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Your content here.
\subsection{Background}
More content.
\section{Conclusion}
Final thoughts.
\end{document}
Text Formatting:
\textbf{bold text} - Bold\textit{italic text} - Italic\underline{underlined} - Underline\texttt{monospace} - Typewriter font\emph{emphasized} - Emphasis (usually italic)Document Structure:
\section{Title} - Section heading\subsection{Title} - Subsection\subsubsection{Title} - Sub-subsection\paragraph{Title} - Paragraph heading\label{sec:intro} - Label for cross-reference\ref{sec:intro} - Reference to labelLists:
% Bulleted list
\begin{itemize}
\item First item
\item Second item
\end{itemize}
% Numbered list
\begin{enumerate}
\item First item
\item Second item
\end{enumerate}
% Description list
\begin{description}
\item[Term] Definition
\item[Another] Explanation
\end{description}
Math Mode:
$x^2 + y^2 = z^2$$$E = mc^2$$\begin{equation}
\int_0^1 f(x)dx = F(1) - F(0)
\label{eq:ftc}
\end{equation}
Tables:
\begin{table}[h]
\centering
\begin{tabular}{|c|c|c|}
\hline
Header 1 & Header 2 & Header 3 \\
\hline
Data 1 & Data 2 & Data 3 \\
Data 4 & Data 5 & Data 6 \\
\hline
\end{tabular}
\caption{Table caption}
\label{tab:example}
\end{table}
Figures:
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{image.pdf}
\caption{Figure caption}
\label{fig:example}
\end{figure}
Cross-References:
See Section~\ref{sec:intro} - Reference sectionAs shown in Figure~\ref{fig:example} - Reference figureEquation~\eqref{eq:ftc} - Reference equation (with parentheses)Citations:
% In preamble
\usepackage{natbib}
\bibliographystyle{plain}
% In text
According to~\cite{author2024}...
Multiple citations~\cite{author2024,smith2023}...
% At end of document
\bibliography{references} % references.bib file
Essential:
amsmath - Advanced mathematicsgraphicx - Include graphicshyperref - Clickable links and URLsgeometry - Page layoutfancyhdr - Custom headers/footersText and Fonts:
fontenc - Font encodinginputenc - Input encoding (UTF-8)babel - Language supportmicrotype - Typography improvementsTables and Lists:
booktabs - Professional tableslongtable - Multi-page tablesenumitem - Customizable listsGraphics:
tikz - Programmatic graphicspgfplots - Data plotssubfig - SubfiguresBibliography:
natbib - Citations and bibliographybiblatex - Modern bibliography systemCode Listings:
listings - Source code formattingminted - Syntax highlighting (requires Python)Advanced Graphics and Diagrams:
tikz - Create diagrams, flowcharts, and complex graphics programmaticallypgfplots - Publication-quality data plots and chartscircuitikz - Circuit diagramschemfig - Chemical structure diagramsAlgorithms and Pseudocode:
algorithm2e - Algorithm formattingalgorithmic - Pseudocodealgorithmicx - Enhanced pseudocodeAdvanced Math:
mathtools - Extensions to amsmathphysics - Physics notation shortcutssiunitx - SI unit formatting\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{tikzpicture}[node distance=2cm]
% Define nodes
\node (start) [circle, draw] {Start};
\node (process) [rectangle, draw, right of=start] {Process};
\node (end) [circle, draw, right of=process] {End};
% Draw arrows
\draw [->] (start) -- (process);
\draw [->] (process) -- (end);
\end{tikzpicture}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{tikzpicture}
\begin{axis}[
xlabel=$x$,
ylabel=$f(x)$,
legend pos=north west
]
\addplot[blue, thick] {x^2};
\addplot[red, dashed] {2*x};
\legend{$x^2$, $2x$}
\end{axis}
\end{tikzpicture}
\usepackage{algorithm2e}
\begin{algorithm}[H]
\SetAlgoLined
\KwData{Input data}
\KwResult{Output result}
initialization\;
\While{condition}{
process data\;
\If{condition}{
do something\;
}
}
\caption{Algorithm Description}
\end{algorithm}
\documentclass{beamer}
\usetheme{Madrid} % or Berlin, Copenhagen, etc.
\usecolortheme{beaver}
\title{Presentation Title}
\author{Your Name}
\date{\today}
\begin{document}
\frame{\titlepage}
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}{Introduction}
\begin{itemize}
\item<1-> First point (appears first)
\item<2-> Second point (appears second)
\item<3-> Third point (appears third)
\end{itemize}
\end{frame}
\begin{frame}[fragile]{Code Example}
\begin{lstlisting}[language=Python]
def hello_world():
print("Hello, World!")
\end{lstlisting}
\end{frame}
\end{document}
\usepackage{siunitx}
% Numbers with units
\SI{3.14e8}{\meter\per\second} % 3.14×10⁸ m/s
\SI{25}{\celsius} % 25 °C
\SI{9.81}{\meter\per\second\squared}
% Tables with aligned decimals
\begin{tabular}{S[table-format=2.3]}
\toprule
{Value} \\
\midrule
1.234 \\
12.567 \\
0.001 \\
\bottomrule
\end{tabular}
\usepackage{subcaption}
\begin{figure}[htbp]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{image1.pdf}
\caption{First subfigure}
\label{fig:sub1}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\includegraphics[width=\textwidth]{image2.pdf}
\caption{Second subfigure}
\label{fig:sub2}
\end{subfigure}
\caption{Overall caption}
\label{fig:main}
\end{figure}
\includeonly{chapter1} to compile only specific chapters\documentclass[draft]{article} (skips images)latexmk for smart recompilation\include{chapter1}biblatex with backend=biber\input for smaller files, \include for chaptersCritical order to avoid conflicts:
\usepackage[utf8]{inputenc} % First
\usepackage[T1]{fontenc} % Second
\usepackage{babel} % Third
\usepackage{amsmath} % Before hyperref
\usepackage{graphicx} % Before hyperref
\usepackage{cleveref} % After hyperref
\usepackage{hyperref} % Near end
\usepackage{bookmark} % After hyperref
This skill includes comprehensive documentation in references/:
Ready-to-use templates in assets/:
Helper scripts in scripts/:
\documentclass[twocolumn]{article}
% or
\usepackage{multicol}
\begin{multicols}{2}
Content in two columns
\end{multicols}
\usepackage{geometry}
\geometry{
a4paper,
left=1in,
right=1in,
top=1in,
bottom=1in
}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[L]{Left Header}
\fancyhead[C]{Center Header}
\fancyhead[R]{Right Header}
\fancyfoot[C]{\thepage}
\usepackage{listings}
\lstset{
language=Python,
basicstyle=\ttfamily,
numbers=left,
frame=single
}
\begin{lstlisting}
def hello():
print("Hello, World!")
\end{lstlisting}
\author{
First Author\thanks{University A} \and
Second Author\thanks{University B} \and
Third Author\thanks{University C}
}
Standard:
pdflatex document.tex
pdflatex document.tex # Run twice for references
With Bibliography:
pdflatex document.tex
bibtex document
pdflatex document.tex
pdflatex document.tex
Modern (latexmk):
latexmk -pdf document.tex # Handles all compilation steps
Undefined control sequence:
\usepackage{...})Missing $ inserted:
$...$ or \(...\) around math_ or caret ^ outside math modeFile not found:
grffile package)Overfull \hbox:
\sloppy or break long URLs with \url{}\linebreak or rephrase text\resizeboxUndefined references:
\ref{...} commands\label{} appears after \caption{}Package clash / Option clash:
\usepackage[opt1,opt2]{pkg}! LaTeX Error: Environment ... undefined:
Dimension too large:
! Missing number, treated as zero:
& or \\! Paragraph ended before ... was complete:
}\long)\label{sec:intro} not \label{s1}figures/image.pdf.bib file\include{chapter1} for chapters.tex files (Git recommended)% This explains the code\usepackage[utf8]{inputenc}cleveref for smart references: \cref{fig:plot} → "Figure 3"booktabs for professional tables (no vertical lines)biblatex instead of natbib for new projectsmicrotype for subtle typography improvements\autoref or \cref instead of manual "Figure~\ref{}"hyperref near the end of preamble (except cleveref, bookmark)latexmk for automated compilation\documentclass[draft]{article}\includeonly{} to compile only changed chaptersSee references/ directory for detailed guides on:
See assets/ directory for ready-to-use templates:
1.1.0 (2026-01-01): Enhanced with advanced LaTeX patterns
1.0.0 (2025-12-31): Initial manual creation
To enhance this skill:
assets/references/scripts/Created: Manually curated LaTeX skill Status: Production Ready Version: 1.1.0 Last Updated: 2026-01-01 Enhancement: Manual enhancement with advanced patterns and examples