我正在使用以下设置来排版一个表格,该表格最终将包含太多行,无法放在一页上,因此使用包xtabular
中的xtab
。从概念上讲,我在每一行中都有多个子行,但我希望表格不会在这些行内中断页面,因此我使用添加换行符来\newline
创建这些子行,以便“外部”表格行包含潜在的断点xtabular
。
现在我想在一行/单元格内进行以下布局:如何使整个行/单元格“悬挂”,就像在第二段和后续段落中添加额外的水平空间一样。请参阅此 MWE:
\documentclass{article}
\usepackage{array}
\usepackage{xtab} % for tables spanning multiple pages
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{xtabular}{|L{7cm}|}
short first par\newline
longer paragraph that should be ragged right and fully indented\newline
third paragraph also indented \\ % this is the row end for tabular
\end{xtabular}
\end{document}
查看 MWE 的输出,我希望第二段和后续段落完全缩进(而不仅仅是悬挂或第一行缩进),如橙色线和箭头所示:
答案1
我倾向于做类似的事情
\documentclass{article}
\usepackage{array}
\def\zz{\def\par{\endgraf\leftskip1em\let\par\endgraf}}
\usepackage{xtab} % for tables spanning multiple pages
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\zz
\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{xtabular}{|L{7cm}|}
short first par
longer paragraph that should be ragged right and fully indented
third paragraph also indented \\ % this is the row end for tabular
\end{xtabular}
\end{document}
答案2
似乎大部分表格内容都是缩进的。因此,另一种方法是仅通过负缩进(或\undent
)调整标题(短)段落文本:
\documentclass{article}
\usepackage{array,xtab}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcommand{\undent}{\hspace*{-15pt}}
\begin{document}
\begin{xtabular}{|@{\hspace{\dimexpr15pt+\tabcolsep}}L{7cm}|}
\undent short first par
longer paragraph that should be ragged right and fully indented
third paragraph also indented \\
\undent short first par
longer paragraph that should be ragged right and fully indented
third paragraph also indented \\
\end{xtabular}
\end{document}
空间15pt
来自默认值\parindent
(重置为0pt
在 内xtabular
)。
答案3
好吧,在构思完这个问题后,我想到了一个滥用段落悬挂的方法,即声明悬挂发生在第 0 行之后。虽然不太好,但确实有效。仍然欢迎任何更清晰的想法!
\documentclass{article}
\usepackage{array}
\usepackage{xtab} % for tables spanning multiple pages
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\begin{document}
\begin{xtabular}{|L{7.5cm}|}
short first par\newline\everypar{\hangindent=1em\hangafter=0}
longer paragraph that should be ragged right and fully indented\newline
third paragraph also indented \\ % this is the row end for tabular
\end{xtabular}
\end{document}
看起来像这样: