1

This code gives me misaligned headers. Any idea how to fix it?

\documentclass{article}
\usepackage{longtable}
\usepackage{array}


\begin{document}
\begin{center}
\begin{longtable}{|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|>{\tiny}c|}
\caption{All the best classification results achieved by runs on the original data. In these runs [0-1] normalization is also tested.}\label{tab:resultsOriginalAllClassifiers}\\
\hline
Data &  Run &  Normalize & $TP\_{rate}$ & $FP\_{rate}$ & $TN\_{rate}$ & $FN\_{rate}$ & Precision & Recall & $F\_{measure}$ & AUC\\ \hline\hline \endfirsthead
\hline
Data &  Run &  Normalize & $TP\_{rate}$ & $FP\_{rate}$ & $TN\_{rate}$ & $FN\_{rate}$ & Precision & Recall & $F\_{measure}$ & AUC\\ \hline\hline \endhead
bt\_10x10\_alldevs & NaiveBayes & none & 0.8 & 0 & 1 & 0.2 & 1 & 0.8 & 0.888889 & 0.94\\ \hline
bt\_10x10\_alldevs & LibSVM & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
bt\_10x10\_alldevs & LibSVM & [0,1]  & 0.9 & 0.1 & 0.9 & 0.1 & 0.9 & 0.9 & 0.9 & 0.9\\ \hline
bt\_10x10\_alldevs & J48 & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
bt\_10x10\_alldevs & RandomForest & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
wifi\_5x5\_TF101 & RandomForest & [0,1]  & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
\caption{All the best classification results achieved by runs on the original data. In these runs [0,1] normalization is also tested.}
\end{longtable}
\end{center}

\end{document}
  • 2
    The header is aligned with the table on the second run but the table does not fit on the page Overfull \hbox (116.64102pt too wide) in alignment at lines 11--13 – David Carlisle Jul 8 '13 at 21:41
  • What do you mean by misaligned headers? I compiled your code and the output seemed quite ok to me (and aligned for the headers, even though it goes almost out of the page and definitely out of the margins). Could you post a picture of your output for us to see your problem? – Ludovic C. Jul 8 '13 at 21:42
3

enter image description here

The headers align, but the table is too wide. Also there is no need to specify \tiny in every column, just specify it before the table. center has no effect on longtable. Here I reduce the intercolumn space and the width of some headings but it is still 3pt or so too wide so I define \LTleft and \LTright to allow the table to extend into the margins slightly.

\documentclass{article}
\usepackage{longtable}
\usepackage{array}


\begin{document}

\noindent X\dotfill X

{\tiny
\setlength\tabcolsep{1pt}
\setlength\LTleft{0pt minus 2pt}
\setlength\LTright{0pt minus 2pt}
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|}
\caption{All the best classification results achieved by runs on the original data. In these runs [0-1] normalization is also tested.}\label{tab:resultsOriginalAllClassifiers}\\
\hline
Data &  Run &  Normalize & $TP\!\_{rate}$ & $FP\!\_{rate}$ & $TN\_{rate}$ & $FN\_{rate}$ & Precision & Recall & $F\!\_{measure}$ & AUC\\ \hline\hline \endfirsthead
\hline
Data &  Run &  Normalize & $TP\!\_{rate}$ & $FP\!\_{rate}$ & $TN\_{rate}$ & $FN\_{rate}$ & Precision & Recall & $F\!\_{measure}$ & AUC\\ \hline\hline \endhead
bt\_10x10\_alldevs & NaiveBayes & none & 0.8 & 0 & 1 & 0.2 & 1 & 0.8 & 0.888889 & 0.94\\ \hline
bt\_10x10\_alldevs & LibSVM & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
bt\_10x10\_alldevs & LibSVM & [0,1]  & 0.9 & 0.1 & 0.9 & 0.1 & 0.9 & 0.9 & 0.9 & 0.9\\ \hline
bt\_10x10\_alldevs & J48 & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
bt\_10x10\_alldevs & RandomForest & none & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
wifi\_5x5\_TF101 & RandomForest & [0,1]  & 1 & 0 & 1 & 0 & 1 & 1 & 1 & 1\\ \hline
\caption{All the best classification results achieved by runs on the original data. In these runs [0,1] normalization is also tested.}
\end{longtable}}


\end{document}
  • Specifying \tiny before the table effects the caption texts. So, I had to take it to the columns to keep the captions intact and comply to the format. However, this fixed the first table and made another longtable go out of control! Edit: putting a \pagebreak between the tables solved the second table. Thanks. – HRahimi Jul 8 '13 at 23:00
  • @HRahimi you could put \normalsize in the caption or (better) use the caption package to control caption format. \pagebreak won't affect the setting of longtable (other than making it come at the top of the page because of the forced break) – David Carlisle Jul 8 '13 at 23:13
  • The thing with \normalsize was that: although the caption text was complying the format, the table name (e.g. Table 1) was still \tiny. And I did not have enough experience with the caption package neither. – HRahimi Jul 9 '13 at 15:10

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.