使用描述时,如何根据给定的字长调整每个的特定缩进description
?
或者说,我如何才能获得诸如 之类的命令\settowidth
,\hangindent
并\mbox
在 下工作description
?
【代码】
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage{setspace}
\begin{document}
\begin{description}
\item [Short head] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\item [Head]Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.
\begin{spacing}{2}
\item [Long long long long head] Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabiturdictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\end{spacing}
\end{description}
\end{document}
答案1
这里有一个选项,只要您愿意使用\item[<description>]{text}
(我添加\raggedright
到最后一项文本只是为了防止在狭窄的空间中出现不好的单词间距):
\documentclass[12pt]{article}
\usepackage{amsmath,amssymb,amsthm,enumitem}
\usepackage{setspace}
\usepackage{varwidth}
\usepackage{letltxmacro}
\usepackage{linegoal}
\usepackage{etoolbox}
\LetLtxMacro\olditem\item
\AtBeginEnvironment{description}{
\renewcommand\item[2][]{
\olditem[%
{\begin{varwidth}[t]{\textwidth}#1\end{varwidth}}]%
\begin{varwidth}[t]{\linegoal}#2\end{varwidth}%
}
}
\begin{document}
\begin{description}[leftmargin=0pt]
\item[Short head]{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\item[Head]{Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis.}
\begin{spacing}{2}
\item[Long long long long head]{\raggedright Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabiturdictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.}
\end{spacing}
\end{description}
\end{document}
我不太喜欢这个解决方案,原因有二:由于描述放在论点中,逐字逐句的材料会有问题,最重要的是,由于描述在框内,它们不允许分页