![如何在表格环境(带有空列)内插入空行/空格?](https://linux22.com/image/389008/%E5%A6%82%E4%BD%95%E5%9C%A8%E8%A1%A8%E6%A0%BC%E7%8E%AF%E5%A2%83%EF%BC%88%E5%B8%A6%E6%9C%89%E7%A9%BA%E5%88%97%EF%BC%89%E5%86%85%E6%8F%92%E5%85%A5%E7%A9%BA%E8%A1%8C%2F%E7%A9%BA%E6%A0%BC%EF%BC%9F.png)
我有一个表格环境,我想用空行或空格分隔“段落”。段落左侧有一个主标题,而右侧的列有几行。以下是示例:
\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}