0

I want a table fullfilling this points

  • landscape (90° rotated) excluding pagefoot/-head
  • over multiple pages (like longtable)
  • table width to full page
  • content of each cell need to auto wrap
  • content of each cell need with hyphenation
  • 5 basic columns where the width can be specified as its amount on the complete table width (e.g. 12% 22% 22% 22% 22% )
  • some multicolumns

I tried a lot of packages and combinations of them. The most problematic point for me is that the combination of auto-wrapping cell-content and autoadjusted width of the cells.

For auto-wrapping I need to use p columns. I don't know how to calculate the width in that case - for the basic columns and for the multicolumns.

Which packages would you use and how would you solve this problem?

Here is a pseudo-code

%% XeTeX
\documentclass{article}
\usepackage{mwe}

% \usepackage{ ??? }

\begin{document}

\begin{ROTATE TO LANDSCAPE BUT WITHOUT PAGE FOOT/HEADER} 
    \begin{A TABLE OVER MULTIPLE PAGES} {5 COLUMNS, AUTO HYPHENATION/LINE WRAPING, FULL PAGE WIDTH}
        % example X[1]X[4]X[4]X[4]X[4] like in tabu-package
        % or {0.1\linewidth}{0.2\linewidth}...
        key&\blindtext&\blindtext&\blindtext&\blindtext\\
        &\multicolumn{2}{ ?? }{\blindtext} & \multicolumn{2}{ ?? }{\blindtext}\\
        &\multicolumn{4}{ ?? }{\blindtext}\\
        % and again
    \end{A TABLE ...}
\end{ROTATE TO ...}

\end{document}
  • 1
    you just need lscape and a normal longtable it seems – David Carlisle Sep 8 '17 at 20:23
2

You didn't show what you tried but it seems a standard longtable would meet those requirements, something like

\documentclass{article}
\usepackage{lscape,longtable,array}
\newlength\tmplen
\begin{document}
\begin{landscape}
\setlength\tmplen{\dimexpr\linewidth-10\tabcolsep}
  \begin{longtable}{>{\raggedright\arraybackslash}p{.12\tmplen}
                   *{4}{>{\raggedright\arraybackslash}p{.22\tmplen}}}
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
    aaaa aaa aaa &
    bb bb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb bbb&
    cc cc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc ccc&
    dd dd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd ddd&
    ee ee eee eee eee eee eee eee eee eee eee eee eee
    \\
  \end{longtable}
\end{landscape}
\end{document}
  • I don't understand the length calculation in the column format. And the multicolumns are missing. Which column specifiers would I need there? That is (one of) the point. The combination with multicolumn. – buhtz Sep 9 '17 at 7:15
  • 1
    @buhtz it means 0.12 times \templen ie exactly what you asked for: 12% of the target width (after taking account of the space added either side of each column) – David Carlisle Sep 9 '17 at 7:54
  • 1
    @buhtz you just use multicolumn as normal, whatever you want \multicolumn{3}{c}{hello} for example why do you think it is affected by the landscape rotation? – David Carlisle Sep 9 '17 at 7:55
  • 1
    \tmplen is the sum of the widths of the column contents, so the width of the page minus 10 times tabcolsep (as there are 5 columns) – David Carlisle Sep 9 '17 at 7:57
  • 1
    @buhtz please take the time to read a basic latex tutorial, hyphenation does work in the columns here just as in any other table. there is not much hyhenation in my example (and you provided no usable example at all) because i used fake text and \raggedright If you want justified text not ragged just remove the \raggedright – David Carlisle Sep 9 '17 at 10:13
0

The answer is based on the answer from @David Carlisle and the comments on the answer.

%% XeTeX
\documentclass{article}
\usepackage{mwe}
% original lipsum is to long for a table cell
\newcommand{\mytext}{Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi}

\usepackage{pdflscape, longtable, array}
\begin{document}
\begin{landscape} % rotate the table content

    % „the sum of the widths of the column contents, so the width
    % of the page minus 10 times tabcolsep (as there are 5 columns)“
    \newlength\tmplen
    \setlength\tmplen{\dimexpr\linewidth-10\tabcolsep}
    \begin{longtable}{%
            % col 1
            >{\arraybackslash}p{.12\tmplen}%
            % col 2-5
            *{4}{>{\arraybackslash}p{.22\tmplen}}%
        }
        key&\mytext&\mytext&\mytext&\mytext\\
        &\multicolumn{2}{>{\arraybackslash}p{.44\tmplen}}{\mytext} & \multicolumn{2}{>{\arraybackslash}p{.44\tmplen}}{\mytext}\\
        &\multicolumn{4}{>{\arraybackslash}p{.88\tmplen}}{\mytext}\\
    \end{longtable}

\end{landscape}
\end{document}

This is working as an example and with real code using a lot of real-data-text as cell content. It is fullfilling all needs specified in the question.

Please feel free to edit/update this answer.

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.