# Aligning equation in figure caption [duplicate]

I have the following code:

\begin{figure}
\centering
\includegraphics[width=1\textwidth]{Fig/cross_section.jpg}
\caption{
Photon's total cross section as a function of energy in Lead. Taken from \cite{phys}. Where:
\newline
$\sigma_{p.e.}$ = Atomic photoelectric effect\\
$\sigma_{Rayleigh}$ = Rayleigh (coherent) scattering\\
$\sigma_{compton}$= Compton (incoherent) scattering\\
$\kappa_{nuc}$ = Pair production, nuclear field\\
$\kappa_{e}$ = Pair production, electron field}
\label{fig:2.1}
\end{figure}


I want to make it so all the text is aligned with respect to the = sign. I tried using align but then my code refused to compile. The same happened when i tried using \hspace and do it manually. Can someone help me out or point out what I am doing wrong?

• Using \caption you will get into alignment trouble within \listoffigures. – user31729 Dec 4 '17 at 13:25
• So, you'll need option to that: \caption[]{} – Sigur Dec 4 '17 at 13:31
• Possible duplicate: How to have aligned equations in a caption? The unfortunate part is that the answer explains nothing. The principle is that you should use the optional argument of \caption[..]{...} in order to avoid moving arguments causing an issue and then use whatever you want in the mandatory argument to align your caption and text. – Werner Dec 5 '17 at 1:34

You can use

\captionsetup{singlelinecheck=off}


from the caption package, and then make sure to pass the optional argument to the \caption command so that the corresponding entry in the \listoffigures is accounted for appropriately.

\documentclass{article}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{caption}
\begin{document}

\begin{figure}
\centering
\captionsetup{singlelinecheck=off}
\includegraphics[width=1\textwidth]{example-image-a}
\caption[For the list of figures]{
Photon's total cross section as a function of energy in Lead. Taken from:
\begin{align*}
1 & 2\\
3 & 4
\end{align*}
}
\label{fig:2.1}
\end{figure}
\end{document}

• Thanks for the reply, it worked had to add insert the additional \text before the text but once I figured that out, it was fine. – WaleeK Dec 5 '17 at 10:03

You can just use a \parbox. You should also set the subscripts as text. Your subscripts apparently follow whatever is in the figure but subscripts with more than one letter are not recommended. Better use $\sigma_\text{R}$ for Rayleigh etc.

\documentclass{article}
\usepackage{calc,graphicx,amsmath}
\begin{document}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption[bla]{\parbox{\textwidth}{
Photon's total cross section as a function of energy in Lead. Taken from somewhere:
\begin{align*}
\sigma_\text{p.e.} &= \text{Atomic photoelectric effect}\\
\sigma_\text{Rayleigh} &= \text{Rayleigh (coherent) scattering}\\
\sigma_\text{compton}&= \text{Compton (incoherent) scattering}\\
\kappa_\text{nuc} &= \text{Pair production, nuclear field}\\
\kappa_\text{e} &= \text{Pair production, electron field}
\end{align*}
}}
\label{fig:2.1}
\end{figure}
\end{document}