# Add source to figure caption

How can I add a source to a figure? I need to add \ref, \cite or just free text. Something like that:

\begin{figure} [ht]
\centering
\includegraphics[width=0.95\textwidth]{res/figure.pdf}
\caption{Caption}
\source{\ref{},\cite{} or free Text}
\label{fig:gliederung}
\end{figure}


Should give me:

The source shouldn't appear in \listoffigures.

-
Have you tried \caption[Caption]{Caption. Source: here the source of the picture}? –  Daniel Jan 23 '13 at 16:26

There are many ways to do this. The source could be put inside the caption. LaTeX puts the caption in one line, if it fits there. This can be prevented by \hspace{\linewidth} in the following example. When LaTeX tests the width by putting it in a \hbox, then \hspace is taken into account. LaTeX concludes that the caption does not fit into one line and by setting it in several lines, the line break is executed and the white space right after it (\hspace{\linewidth}) is ignored:

\documentclass{article}

\newcommand*{\captionsource}[2]{%
\caption[{#1}]{%
#1%
\\\hspace{\linewidth}%
\textbf{Source:} #2%
}%
}

\begin{document}
\begin{figure} [ht]
\centering
\captionsource{Caption}{ref, cite or free Text}
\label{fig:gliederung}
\end{figure}
\end{document}


Alternatively package caption provides an option singlelinecheck, where the testing for fitting into a line can be disabled, using possible multi-line mode always.

-