# 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.

-

I know it makes a lot of time from this post but I had the same problem and found the solution you where looking for. I will post it just in case someone founds it useful.

I took the idea from Gonzalo Medina's post (http://tex.stackexchange.com/a/58300/33066).

Solution: Just add this line somewhere at the begining of you code:

\newcommand{\source}[1]{\caption*{Source: {#1}} }


How to use it: The way this command IS defined, it couldn't be more intuitive:

\begin{figure}
\includegraphics{./imageName}
\caption{Caption of the image.} \label{imageLabel}
\source{Source of the image.}
\end{figure}


And it works for either figure and table environments.

How it works: The added line creates a new command \source{} with a single input parameter: your source. (See this link for more information about creating commands: http://en.m.wikibooks.org/wiki/LaTeX/Macros). The * in \caption*{} prevents the figure caption to be accounted for LaTeX and shown in \listoffigures. In fact if you type:

\begin{figure}
\includegraphics{./imageName}
\caption{Caption of the image.}\label{imageLabel}
\caption*{Source: Source of the image.}
\end{figure}


you would obtain the same result, but the definition of the command \source{} makes it easier to deal with sources.

Style modification: I personaly like having all my sources aligned to the right, so I usually define the command above like that:

\newcommand{\source}[1]{\caption*{\hfill Source: {#1}} }


I hope it helps!

-
I believe this more elegant way of achieving this, plus one for that and of course the nice explanation too. –  Indigo Jul 22 at 10:50