2

I'm working on an article in which I have to put a large and wide table. This table is directly at the start of a new chapter. Because it is very wide, I want to rotate this table (or use it in a landscape environment). Due to the size of the table, I want it to continue on multiple pages. This is how I've currently done this:

\documentclass[twocolumn]{article}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\onecolumn
\section{Title}

\begin{landscape}
\centering
\begin{longtable}{|p{0.5cm}|p{5.5cm}|p{5.5cm}|p{5.5cm}|}
\caption{Long and wide table} \\
\hline
 & \rule{0pt}{3ex}\textbf{Text} & \textbf{More text} & \textbf{Example} \\ \endhead
\hline
\rule{0pt}{3ex}1.1 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.2 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.3 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.4 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.5 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.6 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.7 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.8 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline 

\end{longtable}
\end{landscape}
\twocolumn
\end{document}

This works fine, except this table does not begin at the start of my section, but on the next page, leaving only the name of the new section on a blank page.

I tried to solve this by using the hvfloat package, as is done here. To get this working I switched to a table instead of a longtable, but this introduces the problem that the table is put on one page (while it should be on multiple pages, thus a large part of the table is not visible since it is outside the page). I've put many hours in getting this working and on the internet I can't find any help, so can one of you guys help me out?

  • First off, welcome to TeX.SX! And thank you for providing some partial code for people to play with. It would be really helpful if you could provide a list of the packages and document class that you're using, so that people have a Minimal Working Example of your code. Here's a link about how to create a Minimal Working Environment (MWE). I've made some edits to your original post to provide a compilable MWE. Does this revised code compile in the same way as yours? – cjms85 Feb 26 '14 at 11:54
  • Is there any reason why your tables have to be in landscape orientation? As it it the \begin{landscape} command that is causing the longtable to appear on a new page. From the example you've given your 3rd and 4th columns don't need to contain much text. Is this correct? – cjms85 Feb 26 '14 at 13:54
  • I've edited the latex code such that it matches the document I'm working on better (twocolum article, pdflscape instead of lscape). The 3rd and 4th columns now show not much information, but that is just for this example. In my original document there is text here as well and I therefore prefer a rotated table or a table in the landscape environment. – Joop Feb 26 '14 at 14:20
1

You can do this although I'm not sure I would, I'd do the commented out version to rotate the section head along with the table (I think). I also removed \centering as it has no effect on longtable.

\documentclass[twocolumn]{article}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\onecolumn

\begin{landscape}
%\section{Title}
\begin{picture}(0,0)\put(550,0){\rotatebox{-90}{\parbox{\textwidth}{\section{title}}}}\end{picture}
\begin{longtable}{|p{0.5cm}|p{5.5cm}|p{5.5cm}|p{5.5cm}|}
\caption{Long and wide table} \\
\hline
 & \rule{0pt}{3ex}\textbf{Text} & \textbf{More text} & \textbf{Example} \\ \endhead
\hline
\rule{0pt}{3ex}1.1 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.2 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.3 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.4 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.5 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.6 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.7 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline
\rule{0pt}{3ex}1.8 & \lipsum[13] & \lipsum[13]& \lipsum[13]\\
\hline 

\end{longtable}
\end{landscape}
\twocolumn
\end{document}
0

Assuming that your 3rd and 4th columns do not need to contain a substantial amount of text, then if you abandon the \begin{landscape} command you can get your table to appear directly underneath your section title using the following code. In this code, I've set the table width to \columnwidth and given the columns a proportionality value with the commands |X[0.1,l]|X[1,l]|X[1,l]|X[1,l]|. You can play around with the values 0.1 and 1 for the various columns to see what suits you best.

I have left the code for landscape orientation in the MWE, but it is commented out. If you uncomment it (delete the %), the table will move on to the next page and be oriented in the landscape position, and because the column widths are proportional rather than absolute, you won't need to adjust the individual column widths again.

I know it's not quite what you wanted, but hopefully it'll be of some use.

\documentclass[a4paper]{report}
\usepackage{lscape}
\usepackage{longtable,tabu}
\usepackage{lipsum}

\begin{document}
\section{Title}
%\begin{landscape}
\centering
\begin{longtabu} to \columnwidth{
|X[0.1,l]
|X[1,l]
|X[1,l]
|X[1,l]|
}
\caption{Long and wide table} \\
\hline
 & \rule{0pt}{3ex}\textbf{Text} & \textbf{More text} & \textbf{Example} \\ \endhead
\hline
\rule{0pt}{3ex}1.1 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.2 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.3 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.4 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.5 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.6 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.7 & \lipsum[13] & b & c \\
\hline
\rule{0pt}{3ex}1.8 & \lipsum[13] & b & c \\
\hline 
\end{longtabu}
%\end{landscape}
\end{document}
  • For more clearity I've added more lipsum text to the other columns as well, since this is also the case in the original document. If I understand the solution you just provided correctly, you made the width of the table relative to the width of the page (instead of defining this explicitly after the longtable command)? In that case it does make my code nicer, and also easier to use in future applications (thanks for that!), but that does not really solve my problem. – Joop Feb 26 '14 at 14:28

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.