I created the following table, which showed up nicely in the document on its own:
\begin{table}[!ht]
\begin{tabular}{cccc}
\caption{MyCaption}
--data goes here--
\end{tabular}
\end{table}
However, after I integrated it within my document, it completely runs off the right side of the page. How do I get it to keep its size?
Edit: it's a very small table, 4 columns, so the size isn't the problem.
\documentclass[12pt]{report}
\usepackage{thesis}
\usepackage{apacite}
\usepackage{url}
\usepackage{graphicx}
\begin{document}
%\input{MyChapter}
\begin{table}[!ht]
\caption{Performance scores from assessments of divergent and convergent thinking tests of creativity and non-creativity (control task).}
\begin{tabular}{c{3cm}c{1cm}c{1cm}c{1cm}}
\hline
Variable & \textit{N} & \textit{M} & \textit{SD}\\
\hline
XYZ & \hfill & \hfill & \hfill\\
XXX & 17 & 222 & 2222\\
XXX & 22 & 111 & 11\\
XXX & 22 & 111 & 111\\
XXX & 22 & 111 & 111\\
XYZ & \hfill & \hfill & \hfill\\
XXX & 111 & & 12\\
XXX & 111 & 2 & 1\\
\hline
\label{table:1}
\end{tabular}
\end{table}
\end{document}
I think it might be that the caption is too long. How do I get it to stay the same width as the table?
Best Answer
I suspect that you looking something like this:
Above image of table is generated by:
In my MWE I use package
showframe
only for showing page layout. In real use it had to be removed.To force caption to be the same width as table, I use package
threeparttable
. It enables to includecaption
in table. By this the caption is nod wider than table. Additionally, you can add to table list of (foot)notes, if you have them in table.In my MWE I use
p{...}
column type instead unknownc
. If you like to have centered cells contents, than you can define new column type, for examplec{...}
asI didn't figured out of purpose
\hfill
in many of your table cells, so I remove them.