Graphics, Figures & TablesCiting pages in a subfloat

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
peterdbr
Posts: 1
Joined: Wed Jul 02, 2014 4:38 pm

Citing pages in a subfloat

Post by peterdbr »

Hi all,

I want to create a figure with 3 subfigures in which the caption of each of these subfigures includes a citation with a page reference. If I try to do this via the code below, I get an error.

Apparently, the problem is caused by the citing of the pages because a reference without pages (e.g., \citet{author1}) does not return an error.

Can anyone help me how to solve this?

Thanks!

Peter

\begin{figure}
\subfloat[Caption subfig1 \citet[p.~100]{author1}]{
\includegraphics{img1.pdf}
\label{fig:1}
} \hfill
\centering
\subfloat[Caption subfig2 \citet[p.~200]{author2}]{
\includegraphics{img2.pdf}
\label{fig:2}
} \hfill
\centering
\subfloat[Caption subfig3 \citet[p.~300]{author3}]{
\includegraphics{img3.pdf}
\label{fig:3}
}
\centering
\caption{General caption \label{fig}}
\end{figure}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Citing pages in a subfloat

Post by Johannes_B »

Not really a solutinon for the problem at hand, but:

Instead of using package subfig, you could use package subcaption. It is actively maintained and works well with the caption package (it's the same author).

BTW: In the following example i just biblatex in conjunction with biber to handle the bibliography. You should check it out.

Code: Select all

\documentclass{article}
\usepackage{subcaption}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite[p.~200]{knuth:ct:a}\par
\cite[p.~100]{westfahl:space}\par
\citetitle{knuth:ct:a}\par
\citeauthor{knuth:ct:a}\par
\begin{figure}
	\begin{subfigure}{0.3\linewidth}
		\rule{3cm}{2cm}
		\caption{Caption subfig1 \cite[p.~100]{westfahl:space}}
		\label{fig:1}
	\end{subfigure}\hfill
	\begin{subfigure}{.3\linewidth}
		\rule{3cm}{2cm}
		\caption{Caption subfig2 \cite[p.~200]{knuth:ct:a}}
		\label{fig:2}
	\end{subfigure}
	\caption{General caption \label{fig}}
\end{figure}
\end{document}
Please always post a minimal working example with your question. This is immediately compilable to supporters, meaning they can start testing and finding a solution.
I had to look up which packages to use which needs some time.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply