如何在表格环境(带有空列)内插入空行/空格?

如何在表格环境(带有空列)内插入空行/空格?

我有一个表格环境,我想用空行或空格分隔“段落”。段落左侧有一个主标题,而右侧的列有几行。以下是示例:

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{}l<{}@{\ }X@{}}
    \textbf{Paragraph 1} &
    \textbf{Header 1} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text \\

    % \medskip

    \textbf{Paragraph 2} &
    \textbf{Header 2} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text 
\end{tabularx}
\end{document}

在此处输入图片描述

在中间我注释掉了\medskip插入所需空格的命令。然而,它不直观地出现在第二段标题之后,而不是之前:

在此处输入图片描述

我在这里发现了类似的问题:https://www.reddit.com/r/LaTeX/comments/5om827/vspace_after_newline_in_tabularx/

解决方案是使用\vskip命令,但不知何故,它会以我需要的表格形式带来错误消息:

ERROR: Extra alignment tab has been changed to \cr

我猜我应该调整这条线\begin{tabularx}但我不知道该怎么做。

答案1

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{}l<{}@{\ }X@{}}
    \textbf{Paragraph 1} &
    \textbf{Header 1} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text \\[2cm]

    \textbf{Paragraph 2} &
    \textbf{Header 2} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text 
\end{tabularx}
\end{document}

或者可能更好

\documentclass{article}
\usepackage{tabularx}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{}l<{}@{\ }X@{}}
    \textbf{Paragraph 1} &
    \textbf{Header 1} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text 

\vspace{2\baselineskip}\\

    \textbf{Paragraph 2} &
    \textbf{Header 2} \\
    & Next line \\
    & Third piece of text \\
    & Fourth line of text 
\end{tabularx}
\end{document}

相关内容