0

I wish to insert long itemized lists inside a longtable.

While itemize environments normally insert pagebreaks at adequate positions, they behave as if they were unbreakable when wrapped inside a longtable. How can I influence this behavior?

\documentclass[a4paper]{article}
\usepackage{blindtext}
\usepackage{longtable}

\begin{document}

\begin{longtable}{|p{10cm}|}
\begin{itemize}
    \item   \blindtext
    \item   \blindtext
    \item   \blindtext
    %\pagebreak
    \item   \blindtext
\end{itemize}
\end{longtable}

\end{document}

When compiling the above, the first page stays empty while the longtable starts on the second page. The entire \itemize environment gets stuffed into a single page that overflows at the bottom.

I would like pagebreaks to be inserted anywhere: preferrably between two consecutive \item elements (or if an \item is too long, it may be broken up). Even inserting a manual \pagebreak (as hinted) will just widen the vertical space between the adjacent \item entries without producing the expected behavior.

I read elsewhere that this might have to do with some penalty values, but I couldn't quite figure out how to set them.

EDIT: The above is an MWE. The real document is a report with very long lists of publications. I use a tabular structure because I need to reproduce an official Word template that has everything in tables. Occasionally I need to use double columns, split cells etc., to reproduce the template, so I really need some longtable type package.

A solution involving other tricks and packages is welcome. I hope you see what I want to achieve.

The real thing is a little more like this:

\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{enumitem}
\usepackage{hyperref}

\begin{document}

\begin{longtable}{|p{\linewidth}|}

\hline
\textbf{A1. List all scientific publications} \\ \hline
Authors, titles, references, etc. \\ \hline

\setlength{\parindent}{1em}
\textbf{Journal papers}
\begin{enumerate}[start=1,label={[J\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    % many many more items here
\end{enumerate}

\setlength{\parindent}{1em}
\textbf{Patents}
\begin{enumerate}[start=1,label={[P\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    % many many more items here
\end{enumerate}

\setlength{\parindent}{1em}
\textbf{Open source code}
\begin{enumerate}[start=1,label={[O\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors: \textit{Title} \url{https://example.com/software}.
    \item Authors: \textit{Title} \url{https://example.com/software}.
    \item Authors: \textit{Title} \url{https://example.com/software}.
    % many many more items here
\end{enumerate}

\\ \hline

\end{longtable}

\end{document}
6
  • 2
    it won't work. A table cell can not be broken. Why are you using a longtable at all? Sep 9, 2020 at 22:31
  • I don't understand: isn't longtable designed precisely for the purpose of having tables that span over multiple pages, and are therefore breakable? In fact longtable breaks well as long as I don't use a long itemize inside it. Likewise, a bare itemize environment breaks well too. Why won't they break well when nested?
    – jens
    Sep 9, 2020 at 22:38
  • A longtable can only break between rows.
    – Bernard
    Sep 9, 2020 at 22:47
  • The breaking behavior is not directly related to the use of itemize but due to the itemize environment being inside if a single table row. As Bernard mentions, longtable can only add page breaks between rows not within rows.
    – leandriis
    Sep 10, 2020 at 5:42
  • Probably some background information on what exactly you want to obtain or an example that is closer to your actual table would be helpful here. Probably there is a better way to achieve the desired output.
    – leandriis
    Sep 10, 2020 at 5:50

1 Answer 1

1

For your purpose you not need longtable. Use just lists which can break between pages. \hline you can mimic with \noindent\rule{\linewidth}{0.5pt}:

\documentclass[a4paper]{article}
\usepackage{enumitem}
\usepackage{hyperref}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\noindent\rule{\linewidth}{0.5pt}

\textbf{A1. List all scientific publications}

Authors, titles, references, etc. 

\noindent\rule{\linewidth}{0.5pt}

\textbf{Journal papers}
\begin{enumerate}[start=1,label={[J\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    \item Authors, ``Title,'' Journal, vol. 00, pp. 1234-4321, 2020.
    % many many more items here
\end{enumerate}

\textbf{Patents}
\begin{enumerate}[start=1,label={[P\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
    \item Authors. Title. Code. Publication number: 123456.
\end{enumerate}

\textbf{Open source code}
\begin{enumerate}[start=1,label={[O\arabic*]},leftmargin=10mm,rightmargin=5mm]
    \item Authors: \textit{Title} \url{https://example.com/software}.
    \item Authors: \textit{Title} \url{https://example.com/software}.
    \item Authors: \textit{Title} \url{https://example.com/software}.
    % many many more items here
\end{enumerate}
\noindent\rule{\linewidth}{0.5pt}

\end{document}

enter image description here

enter image description here

enter image description here

5
  • Thanks, that's already something! But how about the vertical boundaries of the table? And what about multicolumn cells (not provided in my example, but sometimes needed in my real document)?
    – jens
    Sep 10, 2020 at 8:44
  • @jens, are vertical lines so important? If you like to have them, see tcolorbox package and their breakable boxes. multirow in one column table have not sense, actually, your question is now not clear.
    – Zarko
    Sep 10, 2020 at 8:50
  • Since I am trying to emulate an official Word template and the document goes through some kind of review process, I prefer to stick to the layout as faithfully as possible. By multirow/multicolum I meant to say that some adjacent cells (not the one containing my enumerate environment!) may contain more complex structures. For example, imagine that I wanted to split the uppermost cell containing "A1. List of all…" into two (left/right). With your technique I think it would become increasingly complex.
    – jens
    Sep 10, 2020 at 9:00
  • @jens, isn't it than simpler to stick with word? :-)
    – Zarko
    Sep 10, 2020 at 10:02
  • Sure, it's simpler! And it's what I'll do next time we write a report collaboratively, now that in my company we have Office 365! I love using LaTeX with git, but I'm sorry to say, sometimes I'm astonished as to how much effort and advanced TeX knowledge it takes to do some basic LaTeX fine-tuning. I thought my use case was a very simple and standard one, but the only solution seems to be to use a very comprehensive package like tcolorbox.
    – jens
    Sep 15, 2020 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .