# Table caption alignment

I have a table like this:

How can I align Caption with left of table not paper?!

And I want to stretch the table a little.

\documentclass{article}

\begin{document}
\begin{table}[h!]
\centering
\caption{Dimensions of simulated tissue containing a malignant tumor, all dimensions are in millimeters}
\label{tabdimension}
\begin{tabular}{ccccc}
\hline
X & Y & Z & D& R \\
\hline
120 & 60 & 25 & 12 &10 \\
\hline
\end{tabular}
\end{table}
\end{document}


Use threeparttable. In addition, part of the caption can go at the bottom of the table, as a tablenote. Using the rule of booktabs wil add some vertical padding around the rules:

\documentclass{article}
\usepackage{array, threeparttable, booktabs,  caption}

\begin{document}

\begin{table}[h!]
\centering\captionsetup{font=footnotesize}
\begin{threeparttable}
\caption{Dimensions of simulated tissue containing a malignant tumor}
\label{tabdimension}
\begin{tabular}{ccccc}
\toprule
X   & Y  & Z  & D  & R  \\
\midrule
120 & 60 & 25 & 12 & 10 \\
\bottomrule
\end{tabular}
\begin{tablenotes}[flushleft]
\footnotesize
\item All dimensions are in mm
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document}


If you prefer to have a two-line caption, you can set the caption width with \captionsetup, but can't use threeparttable In this case, a work around consists in adding a new row to the table, with this code:

\begin{table}[h!]
\centering
\captionsetup{font=footnotesize, width= 47mm}
\caption{Dimensions of simulated tissue containing a malignant tumor}
\label{tabdimension}
\begin{tabular}{ccccc}
\toprule
X   & Y  & Z  & D  & R  \\
\midrule
120 & 60 & 25 & 12 & 10 \\
\bottomrule

• The table width depends on the table contents. You can choose a fixed width, while keeping the cell contents centred with \begin{tabular}{*{5}{>{\centering p{some width}}}. The specifier p may be replaced with m or b, depending on the vertical alignment inside cells. You also may choose the overall width of the table with the \tabularx` environment. – Bernard Jul 17 '16 at 17:37