tags:

views:

355

answers:

5

Hi,

I find that the caption in my longtable takes two lines but it seems that it can fit in one line. See the figure below: alt text

My code is:

\begin{longtable}{|c|c|c|c||c|c|c|}  
\caption{Testing error for training size 100000 and 8000 random counts}\\  
\hline  
\multicolumn{2}{|c|}{Concept} & \multicolumn{2}{c||}{Negative Class} & \multicolumn{2}{c|}{Positive Class} & Error rate \\  
\hline  
...  
\end{longtable}

How to make the caption fit into a single line?

Thanks and regards!


EDIT:

Thank, Geoff. But I tried "\usepackage{fullpage}" as you suggested, the whole content in the pdf file is messed up.

As you can see, there is still lot of space on the left of the caption. If the caption can be moved to the left, it will fit into a single line.

+1  A: 

My guess is that your table is wider than the page. In other words, your caption is as wide as the margins allow, while your table is simply too wide.

Try putting \usepackage{fullpage} in your preamble.

Geoff
Thank, Geoff. But I don't think that is the problem. As you can see, there is still lot of space on the left of the caption. If the caption can be moved to the left, it will fit into a single line.
Tim
+2  A: 

Two options:

  1. The longtables documentation says that there is an LTcapwidth variable that you can set, that defaults to 4in. Try \setlength{LTcapwidth}{5.2in}. I'm not sure how this works if you just want to change one caption width, so

  2. You could force an hbox in the caption of the right dimensions:

  \caption{\hskip -0.7in \hbox to 5.2in{Testing error for training size 100000 and 8000 random counts}}
 
Charles Stewart
A: 

Just a guess, but try:

\usepackage[margin=1cm]{caption}
billynomates
+1  A: 

Hello, one way to force writing on a single line is to include the title of your caption within mbox as in

\mbox{This is a very long title}

You can try

\caption{\mbox{This is a very long title}} 

or

\mbox{\caption{This is a very long title}}
yCalleecharan
Thanks! It puts the caption into a single line. But the title is not centered, leaving more space on the left of the caption than on its right. How to center the caption?
Tim
The caption "Table x" will be aligned to the start of the table on the left. The only way I can think of to have equal space on both sides will be to increase the width of your table. One way to do so is to add more columns in between and putting space such as \hspace{1cm} in these blank columns. These blank columns should be evenly spread among your actual columns for aesthetic reasons. Doing so will increase the width of your table and will let you write a long caption well centered. You will have to play with the width a little and adding \centerline in the caption can help a little.
yCalleecharan
You should also insert \begin{center} and \end{center} just after your line \begin{longtable} and before the line \end{longtable} respectively. This will center your table. Doing this and implementing the solution that I gave you in my previous comment should give you the desired result.
yCalleecharan
You can use for example \hspace{0.05\textwidth} rather than \hspace{1cm} to make it more general to the text width of your document.
yCalleecharan
+1  A: 

\LTcapwidth=\textwidth

\begin{longtable} ...

xl42ii