i want to center the table captions.
[Tex/LaTex] How to force to center the table captions
captionshorizontal alignment
Related Solutions
NB! The link to the TABLE-package at River Valey website is dead. I have not fond the TABLE-package other places. It is not on CTAN.
You can also try the package TABLE from River Valley. The package provides the following:
- include a landscape table as a float.
- format the caption exactly to the width of the table.
- some other hooks that would add a little extra vertical space around horizontal rules in the tabular.
\documentclass{scrartcl}
\usepackage{booktabs}
\usepackage{txfonts,array}
\usepackage[debug]{Table}
\begin{document}
\TABLE{\label{desc} Descriptive Statistics over a Mean Approach to sd and a, descriping both post and pre}
{\begin{tabular}{lccccc}
\toprule
& & \multicolumn{2}{c}{pre} & \multicolumn{2}{c}{post} \\ \cmidrule(lr){3-4}\cmidrule(lr){5-6}
approach & n & mean & sd & mean & sd \\
\midrule
1 & $12$ & $24.2$ & $\phantom{0}8.3$ & $54.3$ & $11.0$ \\
2 & $12$ & $25.5$ & $\phantom{0}9.4$ & $65.2$ & $16.3$ \\
3 & $12$ & $26.3$ & $\phantom{0}9.1$ & $63.2$ & $12.5$ \\\midrule
All & $36$ & $25.3$ & $\phantom{0}8.8$ & $60.9$ & $13.9$ \\
\bottomrule
\end{tabular}
}
\end{document}
And it seems to automatically centre the table on the page.
A) With three tikzpicture
environments and without matrix
This way seems to work : three figures are aligned with the option baseline
and captions are placed inside the code with (current bounding box.base)
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[baseline]
\node (R1) {X};
\node (P1) [right=45pt of R1] {P};
\draw (R1) to (P1);
\node[below=2cm] at (current bounding box.base) {caption 1};
\end{tikzpicture}
\hfill
\begin{tikzpicture}[grow=right,baseline]
\node {A} child { node {P} } ;
\node[below=2cm] at (current bounding box.base) {caption 2};
\end{tikzpicture}
\hfill
\begin{tikzpicture}[grow=right,baseline]
\node {X}
child { node {R} }
child { node {R}
child { node {A} }
child { node {A}
child { node {P} }
child { node {P} }
child { node {P} }
}
child { node {A} }
}
child { node {R} } ;
\node[below=2cm] at (current bounding box.base) {caption 3};
\end{tikzpicture}
\end{document}
B) One tikzpicture
environment with three scope
environments and a matrix
We get the same result
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\matrix[column sep=2cm] {
\begin{scope}[baseline]
\node (R1) {X};
\node (P1) [right=45pt of R1] {P};
\draw (R1) to (P1);
\node[below=2cm] at (current bounding box.base) {caption 1};
\end{scope}
&
\begin{scope}[grow=right,baseline]
\node {A} child { node {P} } ;
\node[below=2cm] at (current bounding box.base) {caption 2};
\end{scope}
&
\begin{scope}[grow=right,baseline]
\node {X}
child { node {R} }
child { node {R}
child { node {A} }
child { node {A}
child { node {P} }
child { node {P} }
child { node {P} }
}
child { node {A} }
}
child { node {R} } ;
\node[below=2cm] at (current bounding box.base) {caption 3};
\end{scope}
\\};
\end{tikzpicture}
\end{document}
Best Answer
I recommend to use the caption package. It provides features for justification, also for centering, such as
It offers many features, just have a look at its comprehensive documentation.