我需要三个相邻的项目列表,每个列表都有一个居中的标题。使用multicol
-package似乎不符合我的需求作为它不允许我独立填写我的专栏,是吗?
把所有东西都放到一张表中,似乎也不合适。
我想到了一个解决方案minipage
,虽然感觉有点过度,但它非常接近我想要的。但我无法设法将小页面并排排列,并在列之间留出一些间距。如何让三个小页面使用 100% 的空间,比如说:
第一列占 30%,空白占 5%,第二列占 30%,空白占 5%,第三列占 30%
我尝试过\hspace
但是没有成功。
\documentclass[11pt,a4paper]{article}%
\usepackage{enumitem}
\begin{document}
\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 1}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\item four
\end{itemize}
\end{minipage}
\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 2}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two.one \\ two.two
\item three
\item four
\end{itemize}
\end{minipage}
\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 3}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\end{itemize}
\end{minipage}
\end{document}
有什么事情可以更容易地实现我的愿望吗?
答案1
您不仅需要添加列间空间,还需要\noindent
在第一个小页面前添加。否则,您就会超出列宽。事实上,小页面是处理这种多列问题的好方法。
已修改,通过插入行尾百分号来删除 David 指出的 2 个杂散空格。
\documentclass[11pt,a4paper]{article}%
\usepackage{enumitem}
\begin{document}
\noindent\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 1}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\item four
\end{itemize}
\end{minipage}%
\kern.05\textwidth%
\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 2}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two.one \\ two.two
\item three
\item four
\end{itemize}
\end{minipage}%
\kern.05\textwidth%
\begin{minipage}[t]{0.30\textwidth}
{\centering \subsection*{Header 3}}
\begin{itemize}[align=left,leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\end{itemize}
\end{minipage}
\end{document}
答案2
只是为了展示表格解决方案:
% arara: pdflatex
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage[inline]{enumitem}
\newcommand*\myTableHeader[1]{\multicolumn{1}{c}{\large\textbf{#1}}}
\begin{document}
\noindent\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}p{0.3\linewidth}p{0.3\linewidth}p{0.3\linewidth}@{}}
\myTableHeader{Header 1} & \myTableHeader{Header 2} & \myTableHeader{Header 3} \\\addlinespace
\begin{itemize*}[itemjoin={\newline}]
\item one one one one one one
\item two
\item three
\item four
\end{itemize*}
&
\begin{itemize*}[itemjoin={\newline}]
\item one one one one one one
\item two.one \newline two.two
\item three
\item four
\end{itemize*}
&
\begin{itemize*}[itemjoin={\newline}]
\item one one one one one one
\item two
\item three
\end{itemize*}\\
\end{tabular*}
\end{document}
更新:
您仍然可以在此处使用旧itemize
定义。但为此,您必须操纵第二行前面的空白高度。图像显示了未经校正的结果。代码已经包含一个,\vspace{-10pt}
看起来相当不错。
\documentclass{article}
\usepackage{array}
\usepackage{enumitem}
\newcommand*\myTableHeader[1]{\multicolumn{1}{c}{\large\textbf{#1}}}
\begin{document}
\noindent\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}p{0.3\linewidth}p{0.3\linewidth}p{0.3\linewidth}@{}}
\myTableHeader{Header 1} & \myTableHeader{Header 2} & \myTableHeader{Header 3} \vspace{-10pt}\\
\begin{itemize}[align=left, leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\item four
\end{itemize}
&
\begin{itemize}[align=left, leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two.one \newline two.two
\item three
\item four
\end{itemize}
&
\begin{itemize}[align=left, leftmargin=*,labelsep=1ex]
\item one one one one one one
\item two
\item three
\end{itemize}\\
\end{tabular*}
\end{document}