This Month's Top Questions
Every month, we compile the most frequently asked LaTeX questions from Reddit's r/LaTeX, TeX StackExchange, and our community. These aren't just quick answers—we provide complete solutions with explanations, code examples, and troubleshooting tips.
December 2025 saw recurring questions about bibliographies, figure placement, and formatting challenges. Let's dive into expert-level answers.
Q1: How do I make my bibliography appear correctly?
Source: r/LaTeX, asked multiple times this month
The Problem
Einstein discovered \cite{einstein1905} but I see [?] instead.You compile your document and instead of proper citations, you see question marks [?] in your output.
The Complete Solution
LaTeX requires multiple compilation passes to resolve citations. The standard workflow:
# Step 1: First LaTeX pass - identifies citations
pdflatex main.tex
# Step 2: Process bibliography
biber main # If using biblatex
# or
bibtex main # If using natbib/traditional BibTeX
# Step 3-4: Resolve cross-references
pdflatex main.tex
pdflatex main.texWhy so many passes?
- First pass: LaTeX writes citation keys to
.auxfile - BibTeX/Biber: Reads
.aux, creates.bblwith formatted references - Second pass: Includes bibliography, writes reference numbers to
.aux - Third pass: Resolves all cross-references
Using latexmk (Recommended)
Instead of running commands manually, use latexmk which handles the sequence automatically:
# For pdflatex + bibtex
latexmk -pdf main.tex
# For pdflatex + biber
latexmk -pdf -bibtex main.texCommon Causes of Citation Problems
Question marks for all citations: BibTeX/Biber wasn't run. Run the full compilation sequence.
Question marks for some citations: Key mismatch between your \cite command and .bib file. Check spelling carefully.
Bibliography doesn't appear: Missing the \printbibliography or \bibliography command. Add the appropriate one for your package.
"I found no citation commands": No \cite commands in your document. Add citations or ignore the warning.
Biber errors: Backend mismatch. Make sure backend=biber in your package options matches running biber (not bibtex) in terminal.
Sample Working Setup
With biblatex (modern, recommended):
\documentclass{article}
\usepackage[backend=biber, style=authoryear]{biblatex}
\addbibresource{references.bib}
\begin{document}
Einstein \parencite{einstein1905} revolutionized physics.
\printbibliography
\end{document}With natbib (traditional):
\documentclass{article}
\usepackage[authoryear]{natbib}
\begin{document}
Einstein \citep{einstein1905} revolutionized physics.
\bibliographystyle{plainnat}
\bibliography{references}
\end{document}Q2: Why is my figure on the wrong page?
Source: TeX StackExchange, recurring question
The Problem
\begin{figure}
\includegraphics{my-figure.png}
\caption{My important figure}
\end{figure}
% Figure appears 3 pages later!Understanding LaTeX Float Behavior
LaTeX treats figures and tables as "floats" that can move to optimize page layout. This is actually a feature—it prevents awkward whitespace when figures don't fit on the current page.
However, when you need precise control, here are your options:
Solution 1: Force Exact Placement with [H]
\usepackage{float}
\begin{figure}[H] % H = HERE, exactly where specified
\includegraphics[width=\textwidth]{my-figure.png}
\caption{This figure stays put}
\end{figure}Important: Use capital H, not lowercase h. The lowercase h is only a suggestion.
Solution 2: Placement Specifiers
Standard float placement options:
| Specifier | Meaning |
|-----------|---------|
| h | Here (if there's room) |
| t | Top of page |
| b | Bottom of page |
| p | Dedicated float page |
| ! | Override restrictions |
Combine them for flexibility:
\begin{figure}[htbp] % Try: here, then top, then bottom, then float page
\includegraphics{figure.png}
\caption{Flexible placement}
\end{figure}Solution 3: Adjust Float Parameters
LaTeX has strict default limits. Relax them in your preamble:
\renewcommand{\topfraction}{0.9} % Allow figures to take 90% of page top
\renewcommand{\bottomfraction}{0.9} % Allow figures to take 90% of page bottom
\renewcommand{\textfraction}{0.1} % Require only 10% text on page
\renewcommand{\floatpagefraction}{0.7}% Require float pages 70% fullSolution 4: Use \FloatBarrier
The placeins package adds barriers that floats cannot cross:
\usepackage[section]{placeins} % Floats can't cross section boundaries
% Or manually:
\FloatBarrier % Force all pending floats to appear hereBest Practices for Figure Placement
- Write first, place later: Don't worry about exact placement until final draft
- Use references: Write "see Figure~\ref..." not "see the figure below"
- Size appropriately: Oversized figures cause more placement issues
- Group related floats: Multiple small figures can go in one float
Q3: How do I change equation/figure/table numbering format?
Source: r/LaTeX
The Problem
Equations show as (1) but you want (1.1) (chapter.equation).
Solution: Number Within Sections or Chapters
% Number equations by chapter
\numberwithin{equation}{chapter} % Requires amsmath
% Number figures by section
\numberwithin{figure}{section}
% Number tables by chapter
\numberwithin{table}{chapter}Custom Number Formats
For completely custom formats:
% Equations as Section.Number
\renewcommand{\theequation}{\thesection.\arabic{equation}}
% Figures as Chapter-Number
\renewcommand{\thefigure}{\thechapter-\arabic{figure}}
% Reset counter at each chapter
\makeatletter
\@addtoreset{equation}{chapter}
\makeatotherRemove Numbering Entirely
% Unnumbered equation
\begin{equation*}
E = mc^2
\end{equation*}
% Or with align
\begin{align*}
a &= b \\
c &= d
\end{align*}Q4: My table is too wide for the page. Help!
Source: TeX StackExchange
The Problem
Your table extends past the margins, running into or off the page.
Solution 1: Use tabularx for Automatic Width
\usepackage{tabularx}
\begin{table}[htbp]
\begin{tabularx}{\textwidth}{|l|X|X|} % X columns stretch equally
\hline
ID & Description & Notes \\
\hline
1 & This is a long description that wraps & Additional notes here \\
2 & Another long description & More notes \\
\hline
\end{tabularx}
\caption{Flexible width table}
\end{table}Solution 2: Scale the Entire Table
\usepackage{graphicx}
\begin{table}[htbp]
\resizebox{\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
Column 1 & Column 2 & Column 3 & Column 4 & Column 5 & Column 6 \\
\hline
Data & Data & Data & Data & Data & Data \\
\hline
\end{tabular}
}
\caption{Scaled table}
\end{table}Warning: Scaling also shrinks text, which can make tables hard to read.
Solution 3: Reduce Font Size
\begin{table}[htbp]
\small % or \footnotesize, \scriptsize
\begin{tabular}{|c|c|c|c|c|c|}
...
\end{tabular}
\caption{Smaller text table}
\end{table}Solution 4: Landscape Orientation
For very wide tables:
\usepackage{pdflscape}
\begin{landscape}
\begin{table}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
% Wide table content
\end{tabular}
\caption{Landscape table}
\end{table}
\end{landscape}Solution 5: Break Across Pages
\usepackage{longtable}
\begin{longtable}{|l|l|l|}
\hline
\textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\
\hline
\endfirsthead % End of first page header
\hline
\textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\
\hline
\endhead % End of continuation headers
Data row 1 & Content & More content \\
Data row 2 & Content & More content \\
% Many more rows...
\hline
\end{longtable}Q5: How do I add code with syntax highlighting?
Source: r/LaTeX, multiple posts
Option 1: listings Package (Simple)
\usepackage{listings}
\usepackage{xcolor}
\lstset{
basicstyle=\ttfamily\small,
keywordstyle=\color{blue},
commentstyle=\color{gray},
stringstyle=\color{red},
numbers=left,
numberstyle=\tiny,
breaklines=true,
frame=single
}
\begin{lstlisting}[language=Python]
def hello_world():
"""A simple greeting function."""
print("Hello, World!")
if __name__ == "__main__":
hello_world()
\end{lstlisting}Option 2: minted Package (Pretty)
\usepackage{minted}
\begin{minted}[
linenos,
frame=lines,
framesep=2mm,
bgcolor=lightgray!20
]{python}
def fibonacci(n):
"""Calculate the nth Fibonacci number."""
if n <= 1:
return n
return fibonacci(n-1) + fibonacci(n-2)
\end{minted}Requirements for minted:
- Python installed with Pygments:
pip install pygments - Compile with
-shell-escapeflag:pdflatex -shell-escape main.tex
Option 3: Inline Code
% Simple monospace
Use the \texttt{print()} function.
% With listings
Use the \lstinline|print()| function.
% With minted
Use the \mintinline{python}{print()} function.Q6: Why does $ $ give an error in my text?
Source: Beginners, frequently asked
The Problem
The price is $50. % Error: Missing $ insertedThe Solution
In LaTeX, $ starts and ends math mode. To print a literal dollar sign, escape it:
The price is \$50. % Correct: displays $50All Special Characters and Their Escapes
Here are the special characters in LaTeX and how to escape them:
- Dollar sign
$— Escape with\$(math mode delimiter) - Percent
%— Escape with\%(comment character) - Ampersand
&— Escape with\&(table column separator) - Hash
#— Escape with\#(macro parameter) - Underscore
_— Escape with\_(subscript in math) - Caret
^— Escape with\^(superscript in math) - Braces — Escape with
\{and\}(grouping characters) - Tilde
~— Use\textasciitilde(non-breaking space) - Backslash — Use
\textbackslash(command prefix)
Handling Many Special Characters
For text with lots of special characters, use \verb or the verbatim environment:
% Inline
The regex \verb|^[a-z]+$| matches lowercase words.
% Block
\begin{verbatim}
$price = 50;
echo "Cost: $" . $price;
\end{verbatim}Q7: How do I make a clickable table of contents?
Source: TeX StackExchange
The Solution
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
pdftitle={My Document},
pdfauthor={Author Name},
}
\begin{document}
\tableofcontents % Now clickable!
\section{Introduction}
Content here...
\section{Methods}
More content...
\end{document}Customization Options
\hypersetup{
colorlinks=true, % Color instead of boxes
linkcolor=black, % Internal links
citecolor=blue, % Citation links
filecolor=magenta, % File links
urlcolor=cyan, % URL links
bookmarks=true, % Create PDF bookmarks
bookmarksnumbered=true,
pdfstartview=FitH, % PDF opens fitting width
}For Print Documents (No Colored Links)
\hypersetup{
hidelinks % Links exist but aren't visible
}Q8: Why do my PDFs have weird fonts?
Source: r/LaTeX
The Problem
Your PDF looks different on different computers, or fonts appear blocky/pixelated.
Solution: Embed Fonts Properly
% Use T1 font encoding
\usepackage[T1]{fontenc}
% Use a modern font that embeds well
\usepackage{lmodern} % Latin Modern (improved Computer Modern)Alternative Font Packages
% Times-like
\usepackage{newtxtext}
\usepackage{newtxmath}
% Palatino-like
\usepackage{newpxtext}
\usepackage{newpxmath}
% Libertine (elegant open-source)
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
% Source Sans Pro (modern sans-serif)
\usepackage[default]{sourcesanspro}Checking Font Embedding
Use this command to verify fonts are embedded:
pdffonts your-document.pdfLook for "emb" column—all fonts should show "yes".
Q9: How do I add line numbers to my document?
Source: r/LaTeX (for journal submission)
The Solution
\usepackage{lineno}
\linenumbers % Enable line numbers
\begin{document}
Your text with line numbers in the margin...
\end{document}Customization Options
% Number every 5th line
\modulolinenumbers[5]
% Number on right side
\rightlinenumbers
% Number only certain sections
\begin{linenumbers}
This section has line numbers.
\end{linenumbers}
This section doesn't.For Double-Spaced Drafts
\usepackage{setspace}
\usepackage{lineno}
\doublespacing
\linenumbers
\begin{document}
Double-spaced text with line numbers, ready for review.
\end{document}Q10: My document compiles forever. What's wrong?
Source: All platforms
Common Causes and Fixes
1. Infinite Loop from Recursive \input
% file1.tex
\input{file2}
% file2.tex
\input{file1} % Infinite loop!Fix: Check your \input and \include structure.
2. Huge Images
Large images (especially vector PDFs) slow compilation dramatically.
% Compile faster with draft mode
\documentclass[draft]{article}
% Or resize images before importing
\includegraphics[width=\textwidth]{huge-image} % Still slowFix: Resize images externally or use draft mode during writing.
3. Complex TikZ Diagrams
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/] % Cache TikZ as separate PDFs4. Package Conflicts
Use binary search to identify:
% Comment out half your packages
% If it compiles, problem is in the commented half
% Otherwise, problem is in the remaining half
% Repeat until you find the culprit5. Quick Diagnosis
# Add timeout to see where it hangs
timeout 30 pdflatex document.tex
# Check log file for last processed content
tail -50 document.logBonus: Expert Tips from the Community
One Sentence Per Line (u/LaTeX_enjoyer):
"Put each sentence on its own line. Version control diffs become readable, and you can easily reorder sentences."
Continuous Compilation (@texpert):
"Use
latexmk -pvcfor live compilation while writing. Saves the compile-check-compile cycle."
Smart References (StackExchange):
"The cleveref package is amazing.
\cref{fig:x}automatically writes 'Figure 1' or 'Figures 1 and 2'. Never manually type 'Figure' again."
The Draft Flag (TeXpert):
"During writing, compile with
\documentclass[draft]{article}. Images become empty boxes and compilation is instant."
Have a Question?
We'll feature the best questions in next month's roundup.
- Reddit: r/LaTeX
- StackExchange: tex.stackexchange.com
- Discord: Join the LaTeX community servers
Get instant answers while you write with Thetapad—client-side compilation means real-time preview without waiting.