Graphics, Figures & TablesAdding Source Citation to Figure

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
h0ps
Posts: 17
Joined: Thu Nov 08, 2012 10:29 pm

Adding Source Citation to Figure

Post by h0ps »

Hi guys

I have tried google this problem but I haven't been able to found a satisfactory solution yet. My problem is that in addition to the figure number I would also like to add the source. Any suggestions?

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Adding Source Citation to Figure

Post by cgnieder »

h0ps wrote:My problem is that in addition to the figure number I would also like to add the source.
I have no idea what you mean by that. Please try to elaborate and possibly add a Infominimal working example to illustrate what you want and what you have.

Regards
site moderator & package author
h0ps
Posts: 17
Joined: Thu Nov 08, 2012 10:29 pm

Adding Source Citation to Figure

Post by h0ps »

Right now I have the following code

Code: Select all

\begin{figure}[!t]
\centering
\includegraphics[width=10cm]{DKinflation.pdf}
\caption{Different measures of inflation in Denmark, 2000-2011}
\label{figure:DKinflation}
\end{figure}
Above the figure number caption I would like to have a line with the source of the graph. So it is like

"Source: http://www.latex-community.org"
"Figure 1: Blahblahblah"
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Adding Source Citation to Figure

Post by cgnieder »

Here is an idea using the caption package:

Code: Select all

\documentclass{article}
\usepackage{graphicx}

\usepackage{caption}
\DeclareCaptionFormat{citation}{%
  \ifx\captioncitation\relax\relax\else
    \captioncitation\par
  \fi
  #1#2#3\par}
\newcommand*\setcaptioncitation[1]{\def\captioncitation{\textit{Source:}~#1}}
\let\captioncitation\relax
\captionsetup{format=citation,justification=centering}

\usepackage{mwe}% for example pictures
\begin{document}

\begin{figure}[ht]
 \centering
 \includegraphics[scale=.5]{example-image-a}
 \caption{Example caption}
\end{figure}

\begin{figure}[ht]
 \centering
 \includegraphics[scale=.5]{example-image-b}
 \setcaptioncitation{somewhere on the world wide web.}
 \caption{Example caption with citation}
\end{figure}

\end{document}
captcite.png
captcite.png (15.9 KiB) Viewed 49082 times
Regards
site moderator & package author
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Adding Source Citation to Figure

Post by localghost »

I think a simple \caption* command that is provided by caption would do also.


Thorsten
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Adding Source Citation to Figure

Post by cgnieder »

localghost wrote:I think a simple \caption* command ...
Huh, somehow I missed that one...
site moderator & package author
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Adding Source Citation to Figure

Post by localghost »

cgnieder wrote:Huh, somehow I missed that one...
That happens quite often to this command.
h0ps
Posts: 17
Joined: Thu Nov 08, 2012 10:29 pm

Re: Adding Source Citation to Figure

Post by h0ps »

It was exactly what I needed. Thx!
Post Reply