我列出了带有描述的事物,但有些描述不太适合这一行,使得列表看起来不太美观。我目前得到的只是一个 itemize 环境,它看起来有点像这样
item in list: item description
another item in list:
description of the item that is too long for
the line and it goes down here
third item in list: a description that fits
我想要做的是:
item in list: item description
another item in list: description of the item that is too long for
the line and it goes down here
third item in list: a description that fits
或者
item in list: item description
another item in list: description of the item that is too long for
the line and it goes down here
third item in list: a description that fits
我尝试了对齐环境,但没有起到作用。
我一直在尝试寻找解决方案,但我真的不知道该用谷歌搜索什么。
答案1
您可以使用longtable
环境。在下面的示例中,我选择p
让第二列允许自动换行。设置列宽p
以适合您的页面布局(我们目前对此一无所知)。
\documentclass{article}
\usepackage{longtable}
\begin{document}
\begin{longtable}{ l p{3in} } % choose suitable width for "p" column
item in list: & item description \\
another item in list: & description of the item that is too long for the line and it goes down here\\
third item in list: & a description that fits\\
\end{longtable}
\end{document}
答案2
这里还有更多选项,使用tabularx
或列表(通过enumitem
) 以充分利用文本块宽度。
\documentclass{article}
\usepackage{tabularx,array}
\usepackage{enumitem}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{@{}l<{:}@{\ }X@{}}
item in list & item description \\
another item in list & description of the item that is too long for
the line and it goes down here \\
third item in list & a description that fits
\end{tabularx}
\bigskip
\noindent
\begin{tabularx}{\textwidth}{@{}r<{:}@{\ }X@{}}
item in list & item description \\
another item in list & description of the item that is too long for
the line and it goes down here \\
third item in list & a description that fits
\end{tabularx}
\bigskip
\newsavebox{\descbox}
\savebox{\descbox}{\bfseries another item in list:}
\SetLabelAlign{Left}{\makebox[\wd\descbox][l]{#1}}
\begin{description}[leftmargin=\dimexpr\wd\descbox+\labelsep,align=Left]
\item[in list:] item description
\item[another item in list:] description of the item that is too long for
the line and it goes down here
\item[third item in list:] a description that fits
\end{description}
\bigskip
\SetLabelAlign{Right}{\makebox[\wd\descbox][r]{#1}}
\begin{description}[leftmargin=\dimexpr\wd\descbox+\labelsep,align=Right]
\item [in list:] item description
\item[another item in list:] description of the item that is too long for
the line and it goes down here
\item [third item in list:] a description that fits
\end{description}
\end{document}
类似方法tabular
(前两种)不会跨越页面边界,而类似列表的方法(后两种)则会。
所有格式都可以根据您的需要进行定制。