此论坛主题正是我所寻找的。我希望我的描述环境能够产生以下内容:
Label is long text
lab2 blalballalaa
label3 possible second rule
label four hello world
有人提出了这样的建议:
\newenvironment{mydescription}[1]
{\begin{list}{}%
{\renewcommand\makelabel[1]{##1:\hfill}%
\settowidth\labelwidth{\makelabel{#1}}%
\setlength\leftmargin{\labelwidth}
\addtolength\leftmargin{\labelsep}}}
{\end{list}}
效果很好(参数是最长的标签),但我认为应该enumitem
能够做到这一点。不幸的是,它的文档对我来说非常混乱。有人可以告诉我如何使用实现相同的结果吗enumitem
?
答案1
这是一种可能性:
\documentclass{article}
\usepackage{calc}
\usepackage{enumitem}
\begin{document}
\begin{description}[leftmargin=!,labelwidth=\widthof{\bfseries The longest label}]
\item[The longest label] text
\item[Short] long long long long long long long long long long long long long long long long long long long long long long long long long long long long long long text
\end{description}
\end{document}
答案2
\documentclass[twocolumn]{article}
\usepackage{scrextend}
\begin{document}
\begin{labeling}{alligator} % alligator is the longest label
\item [\textbf{ant}]really busy all the time
\item [chimp] likes bananas
\item [alligator] very dangerous animal, sharp teeth, long
muscular tail and a bit of text that is longer than one
line and shows the alignment of text quite nicely
\end{labeling}
\end{document}