1

As shown below, my table title does not follow directly after its number, it starts from another line. I need your help to figure out why this happens. How I can fix this problem?

enter image description here

My code is as follows:

\documentclass[tech,thesis,apacite,nochapterblankpages,uglyheadings]{puthesis-cot}
\begin{document}
\begin{table}
\centering
\caption {Square Test Result}
\begin{tabular}{llllll}
Index & Time & FileName & size & Num   & Yes/No \\ 
3, 4 & 1 & Red\_tif\_16\_100w100h.tif & 100*100 & 10000 & Yes \\ 
\end{tabular} 
\end{table}
\end{document}
  • Welcome to TeX.sx! How to know without knowing that document class and packages are you using? Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Fran May 31 '15 at 1:57
  • I use the template from our website engineering.purdue.edu/~mark/puthesis It uses \documentclass[tech,thesis,apacite,nochapterblankpages,uglyheadings]{puthesis-cot} \usepackage{indentfirst} \newcommand{\ip}{\mbox{}\indent} \usepackage{fixltx2e} ... But I did not find any packages that is for tables. Does this explanation make sense? – Yulong Zhang May 31 '15 at 2:08
  • I am sorry that I am totally fresh for the Latex, please tell me what I need to describe to let you answer the question easily. – Yulong Zhang May 31 '15 at 2:15
  • I suddenly find when I use this code in my document, I find my title under the table.\usepackage{float} \restylefloat{table} \usepackage{placeins} – Yulong Zhang May 31 '15 at 2:19
  • Thank you for your comments, I have solved the table position problem through the following code:\documentclass[12pt]{article} \usepackage{float} \floatstyle{plaintop} \restylefloat{table} \begin{document} \begin{table}[t] \caption{Four months plan: where,what how} \begin{tabular}{lclclclc} \hline \hline Month & Week & Programme\\ \hline May & 3-4 & Cycle Tour\\ June & 1-2 & DCP Project\\ July & 1-2 & Clean Energy\\ August & 3-4 & Interim Report\\ \hline \end{tabular} \end{table} \end{document} – Yulong Zhang May 31 '15 at 2:29
2

Now that we know what class you're using, we can see that putting the caption on the next line after the tablename and number is part of your class file. You can confirm this by running the MWE I've edited into your question. puthesis-cot.cls dictates this behavior in a rather long and complex \@makecaption definition.

Changing this probably a bad idea, since this is the class you're supposed to be using for your thesis. However, if you must, the operative lines are 1317--1362 in puthesis-cot.cls; it a complex definition, but for your particular use case, I think what you're looking for is 1335--1342. Change what it is now to the following:

          \centerline{#1:  #2}
%          \sbox\@tempboxa{#2}%
%          \ifdim \wd\@tempboxa >\hsize
%            \centerline{\parbox[t]{\@@captionwidth}{#2}}
%          \else
%            \centerline{#2}%
%          \fi
        }

That way the solution will work with your documentclass. You may need to fiddle with the other conditional branches in the definition for other figures and tables in your document; this only works with the MWE in the question. I don't have the time to sort through the various branchings, so I only made it work in this one case.

By the way: the puthesis-cot.cls wasn't available at the site you linked; I had to Google it to find it. It's kind to link to a non-standard document class in your question in the future.

  • You're welcome; but on TeX.SE, we don't usually post thanks; upvotes and accepted answers are the preferred form of thanks here. Welcome to TeX.SE! – dgoodmaniii May 31 '15 at 3:54
  • The proposed remedy -- \centerline{#1: #2} -- fails badly if the combined width of table title, number, and text exceeds the width of the text block. – Mico May 31 '15 at 7:53
  • Good point; but that's a problem with the class file already. And loading caption (something I would think the class designer probably should have done anyway) could override other behavior in the class. It's probably safer to change as little as possible of the class file. – dgoodmaniii May 31 '15 at 12:10
2

(Too long for a comment, hence posted as an answer.)

I suspect the problem you report -- the fact that the first part of the table caption is centered, whereas the second part is set at the far-left of the next row, after a line break -- may be due to you using an obsolete or otherwise substandard version of the document class file puthesis-cot.cls ("Purdue University College of Techology").

For sure, if I use the version of the class file that's available on the relevant github site, I get the following look for the table shown in your MWE:

enter image description here

Note that the second part of the caption is centered rather than set flush-left. The date associated with the class file downloaded from github is Dec 2014, i.e., quite recent.

If you do not want a line break between "Table 1" and "Square Test Result", I think the easiest way to proceed would be to load the caption package in the preamble.

enter image description here

\documentclass[tech,thesis,apacite,nochapterblankpages,uglyheadings]{puthesis-cot}
\usepackage{caption} % re-format captions
\usepackage{url}     % for "\path" macro
\usepackage{booktabs}% for \toprule, \midrule, and \bottomrule
\begin{document}
\begin{table}
\centering
\caption {Square Test Result}
\begin{tabular}{@{}llllll@{}}
\toprule
Index & Time & FileName & size & Num   & Yes/No \\ 
\midrule
3, 4 & 1 & \path{Red_tif_16_100w100h.tif} & 100*100 & 10000 & Yes \\ 
\bottomrule
\end{tabular} 
\end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.