[Tex/LaTex] Table caption alignment

captionstables

I have a table like this:
enter image description here

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}

Best Answer

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
      \addlinespace
    \end{tabular}
    \begin{tablenotes}[flushleft]
      \footnotesize
      \item All dimensions are in mm
    \end{tablenotes}
  \end{threeparttable}
\end{table}

\end{document} 

enter image description here

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
      \addlinespace
      \multicolumn{5}{@{}l}{\footnotesize All dimensions are in mm}
    \end{tabular}
\end{table}

enter image description here