我正在尝试使用以下代码构建一个表:
\documentclass{article}
\usepackage[inline]{enumitem}
\begin{document}
\begin{table}[h]
\begin{tabular}{p{.3\linewidth}p{.7\linewidth}}
\multicolumn{2}{l}{\bf{Time windows and limits:}} \\
\begin{itemize*}[itemjoin={\newline}]\item soft delivery time windows \emph{(sd)} \end{itemize*} & Time window may be violated, or only a preferred start time of the delivery is provided.\\
\begin{itemize*}\item hard delivery time windows \emph{(hd)} \end{itemize*} & Deliveries must be made within a defined time window.\\
\begin{itemize*}\item hard delivery start time \emph{(hs)} \end{itemize*} & Deliveries may not commence before a predefined time.\\
\begin{itemize*}\item vehicle usage time \emph{(sv)} \end{itemize*} & Vehicles may only be used for a certain amount of time, or may not be available during certain periods, e.g.\ due to maintenance.\\
\multicolumn{2}{l}{\bf{Instrumentation:}} \\
\multicolumn{2}{l}{\begin{itemize*}\item For some deliveries, specialized equipment must be present. Either the delivery truck has this equipment, or an additional vehicle must be scheduled. \end{itemize*}}\\
\multicolumn{2}{l}{\bf{Fleet:}} \\
\begin{itemize*}\item homogeneous \emph{(ho)} \end{itemize*} & All vehicles are identical.\\
\begin{itemize*}\item heterogeneous \emph{(he)} \end{itemize*} & Vehicles differ in capacity or equipment carried.\\
\end{tabular}
\end{table}
\end{document}
其结果是:
您应该注意到,还有改进的空间:
- 项目符号不太好。以第一个项目符号为例:“dows”的开头应该与“soft”的开头对齐,而不是与项目符号对齐。
- “Instrumentation:”下面的行不尊重表格边框。
我们也热烈欢迎任何能改善表格整体外观和可读性的额外建议。
更新
根据 Gonzalo Medina 提供的出色答案(见下文),我想添加分页符,即自动将表格拆分为多页。为此,我执行以下操作:
- 包括软件包
longtable
,ltxtable
- 将表格放在单独的
.tex
文件中。替换\begin{tabularx}{\linewidth}{>{$\bullet$}c@{\hspace{6pt}}p{.3\linewidth}X}
为\begin{longtable}{>{$\bullet$}c@{\hspace{6pt}}p{.3\linewidth}X}
。显然,进行\end{tablularx}
相应的更改。 .tex
使用以下方式将表加载到主文件中\LTXtable{\linewidth}{table.tex}
这对我来说很有效。关于用法的更详细的例子ltxtable
可以在这里找到博客。
答案1
一种选择是使用附加列来自动包含项目符号;这也将提供所需的缩进。我还使用该tabularx
包来避免手动计算列宽,并进行了更改arraystretch
:
\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\begin{document}
\begin{table}
\renewcommand\arraystretch{1.2}
\begin{tabularx}{\linewidth}{>{$\bullet$}c@{\hspace{6pt}}p{.3\linewidth}X}
\multicolumn{3}{l}{\bfseries Time windows and limits:} \\
& soft delivery time windows \emph{(sd)} & Time window may be violated, or only a preferred start time of the delivery is provided.\\
& hard delivery time windows \emph{(hd)} & Deliveries must be made within a defined time window.\\
& hard delivery start time \emph{(hs)} & Deliveries may not commence before a predefined time.\\
& vehicle usage time \emph{(sv)} & Vehicles may only be used for a certain amount of time, or may not be available during certain periods, e.g.\ due to maintenance.\\
\multicolumn{3}{l}{\bfseries Instrumentation:} \\
& \multicolumn{2}{@{}p{\dimexpr\linewidth-23pt\relax}}{For some deliveries, specialized equipment must be present. Either the delivery truck has this equipment, or an additional vehicle must be scheduled.}\\
\multicolumn{2}{l}{\bfseries Fleet:} \\
& homogeneous \emph{(ho)} & All vehicles are identical.\\
& heterogeneous \emph{(he)} & Vehicles differ in capacity or equipment carried.\\
\end{tabularx}
\end{table}
\end{document}
请注意\bf
,已弃用,您应该使用\bfseries
,它们是字体开关,而不是接收参数的命令。
答案2
我将itemize
里面的内容包裹起来minipage
。还将列表命名为xitemize
:
\documentclass{article}
\begin{document}
\newenvironment{xitemize}
{\begin{minipage}[t]{\hsize}\begin{itemize}\leftskip=-1.5em}
{\end{itemize}\end{minipage}}
\begin{table}[h]
\begin{tabular}{p{.3\linewidth}p{.7\linewidth}}
\multicolumn{2}{l}{\bf{Time windows and limits:}} \\
\begin{xitemize}\item soft delivery time windows \emph{(sd)} \end{xitemize} & Time window may be violated, or only a preferred start time of the delivery is provided.\\
\begin{xitemize}\item hard delivery time windows \emph{(hd)} \end{xitemize} & Deliveries must be made within a defined time window.\\
\begin{xitemize}\item hard delivery start time \emph{(hs)} \end{xitemize} & Deliveries may not commence before a predefined time.\\
\begin{xitemize}\item vehicle usage time \emph{(sv)} \end{xitemize} & Vehicles may only be used for a certain amount of time, or may not be available during certain periods, e.g.\ due to maintenance.\\
\multicolumn{2}{l}{\bf{Instrumentation:}} \\
\multicolumn{2}{l}{\begin{xitemize}\item For some deliveries, specialized equipment must be present. Either the delivery truck has this equipment, or an additional vehicle must be scheduled. \end{xitemize}}\\
\multicolumn{2}{l}{\bf{Fleet:}} \\
\begin{xitemize}\item homogeneous \emph{(ho)} \end{xitemize} & All vehicles are identical.\\
\begin{xitemize}\item heterogeneous \emph{(he)} \end{xitemize} & Vehicles differ in capacity or equipment carried.\\
\end{tabular}
\end{table}
\end{document}
输出: