# Variable Caption spacing for tikzpicture and tabular

The \abovecaptionskip option gives different results with tikzpicture and tabular.

MWE:

\documentclass{report}
\usepackage{tikz}
%
\begin{document}
\setlength{\abovecaptionskip}{0pt}
\begin{figure}
\centering
\begin{tikzpicture}
\node[rectangle] {Some Figure};
\draw (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\caption{A Caption}
%
\vspace{1cm}
%
\begin{tabular}{|l|l|}
\hline
Nonlinear & 3.720894e-0\\ \hline
\end{tabular}
\caption{B Caption}
\end{figure}
\end{document}


On an unrelated note, how do I include figure environment in standalone documentclass?

-
It's the tikzpicture orientation. Add [baseline] option to the Tikz picture and it should give similar results. And use [preview] option ; \documentclass[preview]{standalone}. – percusse Dec 13 '12 at 14:32

If you put the environment tikzpicture inside a box, it has height 15.84369pt and depth 0pt, because the reference point is at the bottom border. Then TeX applies the usual interline algorithm, the next base line has distance \baselineskip.

In case of tabular, the default reference point is centered regarding the mathematical axis (\vcenter is used for vertical centering). The result: the height is 8.9pt and the depth is 3.9pt. If the usual algorithm for \baselineskip gives a inter line space smaller than \lineskiplimit, then TeX uses \lineskip instead (default is 1pt).

If you want similar spacing then the reference point of the tabular can be moved downwards with the optional placement option b:

\documentclass{report}
\usepackage{tikz}

\begin{document}
\setlength{\abovecaptionskip}{0pt}
\begin{figure}
\centering
\begin{tikzpicture}
\node[rectangle] {Some Figure};
\draw (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\caption{A Caption}

\vspace{1cm}

\begin{tabular}[b]{|l|l|}
\hline
Nonlinear & 3.720894e-0\\ \hline
\end{tabular}
\caption{B Caption}
\end{figure}
\end{document}


Or in the other direction, the reference point of tikzpicture can be changed, e.g.:

\documentclass{report}
\usepackage{tikz}

\begin{document}
\setlength{\abovecaptionskip}{0pt}
\begin{figure}
\centering
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[rectangle] {Some Figure};
\draw (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}
\caption{A Caption}

\vspace{1cm}

\begin{tabular}{|l|l|}
\hline
Nonlinear & 3.720894e-0\\ \hline
\end{tabular}
\caption{B Caption}
\end{figure}
\end{document}


The extreme, without any space can be achieved by \nointerlineskip:

\documentclass{report}
\usepackage{tikz}

\begin{document}
\setlength{\abovecaptionskip}{0pt}
\begin{figure}
\centering
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[rectangle] {Some Figure};
\draw (current bounding box.south west) rectangle (current bounding box.north east);
\end{tikzpicture}

\nointerlineskip
\caption{A Caption}

\vspace{1cm}

\begin{tabular}{|l|l|}
\hline
Nonlinear & 3.720894e-0\\ \hline
\end{tabular}

\nointerlineskip
\caption{B Caption}
\end{figure}
\end{document}


-
This is wonderful. I am interested in getting a uniform spacing for all captions. Should I use the first or the second choice. I can always set abovecaptionskip accordingly. I ask this, as I am not aware of the complete consequences of adding baseline to all my tikzpictures. – devendra Dec 13 '12 at 15:25