答案1
这是一个使用 的可能解决方案,它结合了和xltabular
的功能。longtable
tabularx
\documentclass{article}
\usepackage{xltabular}
\begin{document}
\begin{xltabular}{\textwidth}{l|>{\itshape}X}
-- Classification A & some text \\
& some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method B & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method C & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{} \\
-- Classification A & some text some text some text some text some text some text some text some text some text some text some text some text \\
& some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method B & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method C & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{} \\
-- Classification A & some text \\
& some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method B & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method C & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{} \\
-- Classification A & some text \\
& some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method B & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{}\\
-- Method C & some text \\
& some text \\
& some text \\
\multicolumn{2}{l}{} \\
\end{xltabular}
\end{document}
第一列左对齐,宽度自动与其最宽条目一样宽。第二列两端对齐,此列中的所有条目都为斜体(用 完成>{\itshape}
)。您可能会注意到,表格比周围的文本略小。如果要删除此缩进,请使用\begin{xltabular}{\textwidth}{@{}l|>{\itshape}X@{}}
。
自动引入垂直线。为了添加行中的间隙和块之间的垂直空白,我使用了\multicolumn{2}{l}{}\\
。表格的每一行之间都可以出现分页符。如果要防止分页符,请使用\\*
而不是\\
。
答案2
我以前用过一种非常相似的格式。使用所采用的技术来leandriis
分隔表格的行,可以实现以下效果:
\documentclass{article}
\usepackage{array}
\usepackage{enumitem}
\newenvironment{mynewlist}{%
\sffamily %% Used this to match your sample -- change at will
\setlist[itemize]{nosep,
topsep=0pt,
label={},
left=0pt,
leftmargin=0pt,
partopsep=0pt,
before=\vspace{-6pt},
after=\vspace{-\baselineskip}
}
\begin{tabular}{>{--\ }l|>{\itshape\begin{itemize}}p{2in}<{\end{itemize}}}
}{%
\end{tabular}
}
\newcommand{\mysep}{\multicolumn{2}{l}{}\\}%% Inserts empty tabular row
\begin{document}
\begin{mynewlist}
Classification A&\item some text \item some text \item some text \item some text\\
\mysep
Méthode B&\item some text \item some text \item some text \item some text\\
\mysep
Method C&\item some text \item some text \item some text \item some text\\
\end{mynewlist}
\end{document}
表格的格式直接利用了第二列中的itemize
环境(借助enumitem
该环境可以轻松访问格式列表)。该array
包允许向tabular
环境的列添加格式——在这种情况下,它允许自动将短破折号添加到第一列,并允许在表格的第二列中使用环境itemize
和斜体类型。可以轻松进行更改以满足您的格式要求。
更新
对 做了一些小补充\setlist
,以改善第二列环境leftmargin=0pt
的间距。更新了 输出图形。itemize
第二次更新
出于两个原因,我不能不管它。我想大大简化数据的输入,同时通过使用xltabular.sty
(效仿)使多页表格成为可能。这需要使用fromleandriis
将整个表格主体放入 -也需要类似的技巧。作为一种简化,我用stand 代替了来简化输入,使用 stand 完全是可选的。我加了一点颜色来增加趣味性。还创建了一个可以巧妙处理输入的宏。我还在第二列中使用了悬挂缩进来表示一行非常长的文本。\itembody
\gappto
etoolbox
tabularx
|
\item
\documentclass[11pt]{article}
\usepackage[papersize={5.5in,8.5in},margin=0.5in]{geometry}
\usepackage{array}
\usepackage{xltabular} %% multipage tabularx-style tables
\usepackage{enumitem}
\usepackage{colortbl}
\usepackage{etoolbox}
\begingroup
\catcode`|=\active
\gdef\changebar{\def|{\item}}
\endgroup
\newenvironment{mynewlist}{%
\sffamily %% Used this to match your sample -- change at will
\setlength{\arrayrulewidth}{1pt}
\arrayrulecolor{red}
\catcode`|=\active
\changebar
\setlist[itemize]{nosep,
topsep=0pt,
label={},
left=0em,
partopsep=0pt,
leftmargin=1em,
itemindent=-1em,
before=\vspace{-1.25em},
after=\vspace{-\baselineskip}
}%
}{%
\begin{xltabular}{\textwidth}{@{}>{\bfseries--\ }l|
>{\itshape\begin{itemize}}X<{\end{itemize}}}
\itembody
\end{xltabular}
\vspace{-\baselineskip}
\gdef\itembody{}%
}
\newcommand{\myentry}[2]{% gather the rows of the table into \itembody
\gappto{\itembody}{%
#1\\
\multicolumn{2}{l}{}\\[-8pt]%% Change '-8pt' to adjust space between rows
}%
}
\begin{document}
\begin{mynewlist}
\myentry{Classification A}{%
|some text
|some text
|some text
|some text
}
%% The use of `|' for \item is purely voluntary.
\myentry{Méthode B}{%
\item some text
\item text that might be terribly long and go on and on and on\dots
}
\myentry{Method C}{%
|some text
|some text
|some text
|some text
}
\end{mynewlist}
\end{document}