我想使用具有两列的 tabu 环境进行比较。为了使其看起来美观,每列应该看起来像 itemize 环境中的两个列表(因此我使用 X 列)。第一个问题是,如果我使用 itemize,项目符号不会彼此相邻,而是会移动,如本例所示:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{tabu}
\begin{document}
\begin{tabu} to \textwidth {X[1,l] | X[1,l]}
Advantages & Disadvantages\\
\hline\\
\begin{itemize}
\item Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage
\item Another advantage Another advantage Another advantage Another advantage Another advantage Another advantage
\end{itemize}
&
\begin{itemize}
\item Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage
\item Another disadvantage Another disadvantage Another disadvantage Another disadvantage Another disadvantage
\end{itemize}
\end{tabu}
\end{document}
另一方面,如果使用 $\bullet$,则没有缩进,正如您在此处看到的:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{tabu}
\begin{document}
\begin{tabu} to \textwidth {X[1,l] | X[1,l]}
Advantages & Disadvantages\\
\hline\\
$\bullet$ Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage
&
$\bullet$ Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage\\
$\bullet$ Another advantage Another advantage Another advantage Another advantage Another advantage Another advantage
&
$\bullet$ Another disadvantage Another disadvantage Another disadvantage Another disadvantage Another disadvantage
\end{tabu}
\end{document}
因此,我尝试使用更多列并调整其间距。我的意思是:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{tabu}
\begin{document}
{\tabulinesep=2mm
\begin{tabu} to \textwidth {X[1,l] X[200,l] | X[1,l] X[200,l]}
Advantages & & Disadvantages &\\
\hline
$\bullet$ & Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage
&
$\bullet$ &Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage\\
$\bullet$ & Another advantage Another advantage Another advantage Another advantage Another advantage Another advantage
&
$\bullet$ & Another disadvantage Another disadvantage Another disadvantage Another disadvantage Another disadvantage
\end{tabu}
}
\end{document}
然而,这是一个非常非常非常非常糟糕的黑客攻击......有没有更优雅的解决方案?
马丁
答案1
这更接近您的方法。 \labelsep
是 itemize 使用的距离。
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{tabu}
\begin{document}
{\tabulinesep=2mm
\begin{tabu} to \textwidth {l@{\hspace{\labelsep}}Xl@{\hspace{\labelsep}}X}
\multicolumn{2}{l}{Advantages} & \multicolumn{2}{l}{Disadvantages} \\
\hline
\textbullet & Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage
&
\textbullet &Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage\\
\textbullet & Another advantage Another advantage Another advantage Another advantage Another advantage Another advantage
&
\textbullet & Another disadvantage Another disadvantage Another disadvantage Another disadvantage Another disadvantage
\end{tabu}
}
\end{document}
答案2
tabu
更简单:使用enumitem
和设置 itemize 内部的参数etoolbox
。我添加了一个从这个网站上偷来的技巧,以便在包含列表的单元格顶部出现不必要的垂直间距:
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{tabu}
\usepackage{enumitem}
\usepackage{etoolbox}
\AtBeginEnvironment{tabu}{\setlist[itemize]{wide = 0pt, leftmargin = *}}
\makeatletter
\newcommand*{\compress}{\@minipagetrue}
\makeatother
\begin{document}
\begin{tabu} to \textwidth {>{\compress}X[1,l] | >{\compress}X[1,l]}
Advantages & Disadvantages \\
\hline \\
\begin{itemize}
\item Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage Advantage
\item Another advantage Another advantage Another advantage Another advantage Another advantage Another advantage
\end{itemize}
&
\begin{itemize}
\item Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage Disadvantage
\item Another disadvantage Another disadvantage Another disadvantage Another disadvantage Another disadvantage
\end{itemize}
\end{tabu}
\end{document}