1

Hi I usually use tabular to create my table. However I am currently in the process of creating a unavoidable huge multi-page table in landscape more. I am using TeXstudio 2.12.10. However I am having several issues with landscape longtable that after many hours of trying, I can to seem to fix. I was hoping that something can advice me with the following issues I am currently facing:

Prob 2: when I write long sentences on "samples" (column 4) "notes" (column 5), the text just keeps on going outside of the page border rather than wrapping around. Which brings us to problem number 2,

Prob 1: I cannot set the width of the table to \textwidth to limit the size of the table

Prob 3: \shortstack option that I implemented perfectly on tabular does not appear to work here as it is not dividing up the lines.

I am happy for the first 3 rows to be smalls as they will contain only a few words, but the last 2 columns must be able to wrap text around with the use of something like shortstack so I can write in different lines. Any advice. I have attempted the following 1, 2, 3 advice without a solution. Please do let me know if you have questions. With the codes provided below I get something like this:

enter image description here

%%%%%%%%%%%% latex code %%%%%%%%%%%%

\begin{landscape} \begin{center}

\begin{longtable}{lcccl}

    \caption{A simple longtable example}                                \\
    \hline
    reference & technique & geometry & suspension   & notes             \\
    \hline
    \endfirsthead
    \multicolumn{5}{c}%
    {\tablename\ \thetable\ -- \textit{continued from previous page}} \\
    \hline
    reference & technique & geometry & suspension   & notes \\
    \hline
    \endhead
    \hline \multicolumn{5}{r}{\textit{continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot

    \citet{AbbottEtAl_Experimental_1991}        & MR    & Couette   
    & \shortstack{particles: PMMA // $ \bar{\phi} = 39, 45, 50, 55, 60\% $} 
    & \shortstack{sample contained both unimodal and un-sieved particles \\ shows migration time scale is independent of $ \eta_f $ \\ presents transient concentration profiles of $ \bar{\phi} = 50\%$ \\ presents steady state migration profiles of $ \bar{\phi} = 45, 50 , 55\%$}\\        

\end{longtable} \end{center} \end{landscape}

Following the advice provided below I have amended

\begin{longtable}{lcccl} with \begin{longtable}{ p{3cm} p{1cm} p{2cm} p{3cm} p{5cm} }

While this DOES limit the table size, it does still does not wrap the text around.

enter image description here

  • longtable is the same as tabular replace your c and l columns (which are one-line cells) by p{3cm} or whatever width you need. Also (unrelated) don't put longtable in a center environment. – David Carlisle Oct 7 '18 at 23:11
  • did you intend \\ where you have // in the shortstack? – David Carlisle Oct 7 '18 at 23:13
  • @DavidCarlisle that's such a silly mistake. I should've noticed it. Many thanks. – Abhi Oct 7 '18 at 23:25
  • @DavidCarlisle I have replaced the \begin{longtable}{lcccl} with \begin{longtable}{ p{3cm} p{1cm} p{2cm} p{3cm} p{5cm} } However that still does not wrap the texts to fit the column width. I have attached a picture with the original post. – Abhi Oct 7 '18 at 23:28
  • you know how big your page is (you have not provided an example document so we do not know) choose suitable column widths the text will wrap to the specified column widths and the widths add up to whatever you make them add up to. – David Carlisle Oct 8 '18 at 7:04
2

Here is a solution with the xltabular package which mixes the properties of longtable and tabularx in its xltabular environment. I also use makecelland multirow:

\documentclass{article}
\usepackage{geometry}
\usepackage{lscape}
 \usepackage{array, ltablex, caption, multirow, makecell}
\usepackage{xltabular} 
\usepackage{natbib}
\newcommand\nl{\newline}

\begin{document}

 \begin{landscape}
\setlength{\extrarowheight}{3pt}
\begin{xltabular}{\linewidth}{lccc >{\arraybackslash}X}

    \caption{A simple longtable example}                                \\
    \hline
    reference & technique & geometry & suspension   & notes             \\
    \hline
    \endfirsthead
    \multicolumn{5}{c}%
    {\tablename\ \thetable\ -- \textit{continued from previous page}} \\
    \hline
    reference & technique & geometry & suspension   & notes \\
    \hline
    \endhead
    \hline \multicolumn{5}{r}{\textit{continued on next page}} \\
    \endfoot
    \hline
    \endlastfoot

    \citet{AbbottEtAl_Experimental_1991}        & MR    & Couette   
    & \multirowcell{2}{particles: PMMA \\ $ \bar{\phi} = 39, 45, 50, 55, 60\,\% $}
    & sample contained both unimodal and un-sieved particles \nl shows migration time scale is independent of $ \eta_f $
    \nl presents transient concentration profiles of $ \bar{\phi} = 50\%$ \nl presents steady state migration profiles of $ \bar{\phi} = 45, 50 , 55\,\%$
\end{xltabular}
\end{landscape}

\end{document} 

enter image description here

  • That works perfectly @Bernard. Many thanks for all your help. – Abhi Oct 8 '18 at 0:46

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.