1

I have a document and what I want is below every single tikz or image to have a small caption "source: ....". What would be the most convenient way to do that?

Code is:

    \documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{fancyhdr}
\usepackage{pgfplots}
\usepackage[letterpaper,left=2.5cm,right=2.5cm,top=2.5cm,bottom=2.5cm]{geometry} 

\usepackage{apacite}
\usepackage[utf8]{inputenc}
\usepackage{afterpage}
 \usepackage{hyperref}
 \usepackage{lipsum}
 \usepackage{ragged2e}
 \usepackage{enumitem}
 \hypersetup{
    colorlinks,
    citecolor=black,
    filecolor=black,
    linkcolor=black,
    urlcolor=black
 }

\newcommand\blankpage{%
    \null
    \thispagestyle{empty}%
    \addtocounter{page}{-1}%
    \newpage}
\date{\today}
\author{M,,,,,,k}

\title{,,,,,,}
\linespread{1.5}

\begin{document}
\clearpage\maketitle
\thispagestyle{empty} \newpage \tableofcontents \newpage
\fancyhf{} 
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}


\section{sectionsection}
\subsection{somethingdifferent}

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
xbar,
y axis line style = { opacity = 0 },
axis x line       = none,
tickwidth         = 0pt,
ytick=data,
symbolic y coords={Kesklinn, Mustamae, Kristiine, Nomme, Haabersti, Pohja-Tallinn, Lasnamae},
y tick label style={anchor=east},
nodes near coords={$\pgfmathprintnumber{\pgfplotspointmeta}\%$},
point meta=100*x,
nodes near coords align={anchor=west},
every node near coord/.append style={%
    xshift=5mm
}
]

\addplot coordinates {
    (0.034,Kesklinn)
    (-0.011,Mustamae)
    (-0.01,Kristiine)
    (0.025,Nomme)
    (0.018,Haabersti)
    (0.008,Pohja-Tallinn) 
    (0.117,Lasnamae)
};

\end{axis}
\end{tikzpicture}
\caption{Wzrost liczby podróżnych z podziałem na dzielnice po wprowadzeniu bezpłatnej komunikacji miejskiej. Opracowanie własne, na podstawie Cats (2014).} \label{fig:M1}
\end{figure}


\section{somesection}



\end{document}

I want this source thing to be above the caption and below the graph (with smaller letter than the caption).

2
  • How are those pictures included into the text? Normally, pictures are added as floats in a figure environment. There you can simply use the \caption... or do you want the caption to be part of the tikz-picture?
    – Dux
    Commented Mar 14, 2016 at 10:47
  • Ok i will post an example in a few minutes time to be more specific. Commented Mar 14, 2016 at 10:50

1 Answer 1

2

The easiest might be to name the axis plot (here A) and then put a node below it with the appropriate text:

\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}[
   xbar,
   y axis line style = { opacity = 0 },
   axis x line       = none,
   tickwidth         = 0pt,
   ytick=data,
   symbolic y coords={Kesklinn, Mustamae, Kristiine, Nomme, Haabersti, Pohja-Tallinn, Lasnamae},
   y tick label style={anchor=east},
   nodes near coords={$\pgfmathprintnumber{\pgfplotspointmeta}\%$},
   point meta=100*x,
   nodes near coords align={anchor=west},
   every node near coord/.append style={%
       xshift=5mm,
   },
   name=A
]

\addplot coordinates {
    (0.034,Kesklinn)
    (-0.011,Mustamae)
    (-0.01,Kristiine)
    (0.025,Nomme)
    (0.018,Haabersti)
    (0.008,Pohja-Tallinn) 
    (0.117,Lasnamae)
};
\end{axis}
\node[below,font=\small] at (A.below south) {Source\dots};
\end{tikzpicture}
\caption{Wzrost liczby podróżnych z podziałem na dzielnice po wprowadzeniu bezpłatnej komunikacji miejskiej. Opracowanie własne, na podstawie Cats (2014).} \label{fig:M1}
\end{figure}
1
  • 2
    Alternatively you could use the current bounding box node. Then you could even make a macro if desired, e.g. \newcommand\figsource[1]{\node [below=0.5cm,font=\small] at (current bounding box.south) {Source: #1};}, and then add \figsource{...} after \end{axis}. Saves adding name=A to all axis environments. (Edit: Arguably adding {\small Source ... \par} between tikzpicture and caption is easier.) Commented Mar 14, 2016 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .