使 itemize 在 longtable 中可破坏

使 itemize 在 longtable 中可破坏

我希望在里面插入长逐项列表longtable

虽然 itemize 环境通常会在适当的位置插入分页符,但当它们被包裹在 longtable 中时,它们的行为就像是牢不可破的。我该如何影响这种行为?

\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}

编译上述内容时,第一页保持空白,而longtable第二页开始。整个\itemize环境被塞进一页,并在底部溢出。

我希望分页符可以插入到任何地方:最好是在两个连续\item元素之间(或者如果\item太长,可以将其拆分)。即使插入手册\pagebreak(如提示的那样)也只会加宽相邻\item条目之间的垂直空间,而不会产生预期的行为。

我在其他地方读到这可能与一些惩罚值有关,但我不太清楚如何设置它们。

编辑: 以上是 MWE。真正的文档是一份包含很长出版物列表的报告。我使用表格结构是因为我需要复制一个包含表格的官方 Word 模板。有时我需要使用双列、拆分单元格等来复制模板,所以我确实需要一些longtable类型包。

欢迎提供涉及其他技巧和软件包的解决方案。希望您能看到我想要实现的目标。

真实情况是这样的:

\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}

答案1

对于您的目的,您不需要longtable。仅使用可以在页面之间中断的列表。\hline您可以模仿\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}

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

相关内容