[Tex/LaTex] Problems with alignment with landscape table

floatslandscapepositioning

I'm writing a paper that includes a number of tables. Until now these have been in standard table* format, i.e.

\begin{table*}
\caption{Caption}
\label{label}
\begin{center}
\begin{tabular}{lccccccccccccccc|cc}
& \multicolumn{15}{c}{Title}& $\mu$ & $\sigma$\\

etc.

with about 15-20 subsequent rows, and renders correctly while (just) fitting the page width. However, I now need to add two further columns, making the table* too wide for portrait, and so need to switch to landscape mode. This should be a straightforward case of rotating through 90 degrees, as even in landscape there are not so many rows that the table needs to break across pages.

However, I've tried two approaches and have hit problems with both. Firstly, I have tried wrapping the table with \begin{landscape} (including lscape in \usepackage), but there is a lot of whitespace at the bottom of the page, while the left hand edge of the table is pushed through the \runningtitle and off the top of the page. Secondly, I tried replacing \begin{table*} with \begin{sidewaystable*}, but now the table is correctly spaced vertically (i.e. there is not excessive whitespace at the bottom, or a collision with \runningtitle) but is now offset horizontally – the first table runs off the 'left' of the page (left as viewed in portrait, top as viewed in landscape) while the next is rotated 180 degrees and drops off the 'right'.

In both cases, adding or removing \begin{center} or \centering doesn't appear to make any difference, and I'm out of ideas about what else to do. Apart from the usual LaTeX complaints about 'float too large for page' there is no apparent output to help me figure out what's wrong. The paper is in A&A format using the latest (v7) aa.cls. If I switch to referee mode (which triggers a shift from two-column to one-column with larger font and double spacing) then the table appears to render correctly, which makes me wonder if there's some issue with the .cls file.

Does anybody have any suggestions for a solution, workaround or alternative that might just work? I've been bashing my head against this for a couple of hours and I'm no out of ideas.

Best Answer

Instead of using table*, you could try tabular*. The *-form takes an additional <width> mandatory argument

\begin{tabular*}{<width>}{<column specification>}

which specifies the width of the tabular environment; in the regular form the width is determined by LaTeX from the contents of the tabular environment. Now, this might only help if you actually want to widen a table/tabular to a specific width. But, in your case you may need to shrink the table/tabular width. For this, there may be some tricks you can employ. However, some of these may be dependent on the journal requirements/specifications. Also, optimal solutions/choice might depend on the degree that your table extends outside the text block. I list a couple here by means of an example:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
Original\par
\begin{tabular}{*{7}{|c}|}
  Test 1 & Test 2 & Test 3 & Test 4 & Test 5 & Test 6 & Test 7
\end{tabular}

\bigskip Individual column separation modified via \verb|@{\hspace{<width>}}|\par
\begin{tabular}{*{7}{|@{\hspace{2pt}}c@{\hspace{2pt}}}|}
  Test 1 & Test 2 & Test 3 & Test 4 & Test 5 & Test 6 & Test 7
\end{tabular}

\bigskip Global column separation modified via \verb|\renewcommand{\tabcolsep}{<width>}|\par
{\renewcommand{\tabcolsep}{2pt}
\begin{tabular}{*{7}{|c}|}
  Test 1 & Test 2 & Test 3 & Test 4 & Test 5 & Test 6 & Test 7
\end{tabular}}

\bigskip Resized horizontally (keeping aspectratio) via \verb|\resizebox{<width>}{<height>}|\par
\resizebox{20em}{!}{\begin{tabular}{*{7}{|c}|}
  Test 1 & Test 2 & Test 3 & Test 4 & Test 5 & Test 6 & Test 7
\end{tabular}}

\bigskip Original\par
\begin{tabular}{*{7}{|c}|}
  Test 1 & Test 2 & Test 3 & Test 4 & Test 5 & Test 6 & Test 7
\end{tabular}
\end{document}

Differences in horizontal spacing when using the tabular environment

On a more semantic side of things, here are some suggestions to your code:

  • The use of \begin{center}...\end{center} is antiquated in LaTeX, and often produces unwanted vertical spacing even though this might not be the case with your tables. Rather use \centering. The l2tabu package gives some mention of this, plus other references to obsolete code for LaTeX2e.
  • Tabular columns specification can be simplified if you have many similarly-formatted columns. For this, using *{15}{c} is equivalent to ccccccccccccccc (as in the example above). Of course, there is a limit to this use, since *{2}{c} is less useful than cc. However, readibility is at play here as well as ease of subsequent modification.
Related Question