我想将(现在错误的)环境缩进设置为与(已经正确的)环境缩进description
相同。enumerate
请注意我已经使用\usepackage{enumitem}
。
如何?
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}
\item a.
\item b.
\end{enumerate}
\begin{description}
\item[1.] a.
\item[2.] b.
\end{description}
\end{document}
两个列表的缩进量不同,我想把description
缩进量改成和缩进量一样enumerate
。
附录
我尝试了下面的amsbook
LaTeX 文件。不知何故,和 的缩进enumerate
并description
没有达到我想要的效果。请帮我找出我的错误。
\documentclass{amsbook}
\usepackage{enumitem}
\setlist[enumerate,1]{leftmargin=1.7em,labelindent=*}
\setlist[description,1]{leftmargin=1.7em,labelindent=*}
\begin{document}
\begin{enumerate}
\item a.
\item b.
\end{enumerate}
\begin{description}
\item[1.] a.
\item[2.] b.
\end{description}
\end{document}
附录 2
根据@Harish Kumar 的建议,我也尝试了以下方法。结果并不理想,左边距enumerate
也description
不一致。
\documentclass{amsbook}
\usepackage{enumitem}
\renewcommand{\descriptionlabel}[1]{%
% \hspace\labelsep \upshape #1.%
\upshape #1.%
}
\setlist[enumerate,1]{leftmargin=2em,labelindent=*,label=\arabic*$^\circ$.,
ref=\arabic*$^\circ$}
\setlist[description,1]{leftmargin=1em,labelindent=*}
\begin{document}
\begin{enumerate}
\item \label{a} a.
\item \label{b} b.
\end{enumerate}
\begin{description}
\item[\ref{a}] a.
\item[\ref{b}] b.
\end{description}
\end{document}
答案1
所提出的要求一点也不明确:如果人们只是想将description
环境的标签排版为环境的一部分enumerate
,那么为什么要使用description
?显然,这个问题缺少一些基本信息。一种可能的解释是,这里真正想要的是排版一个常规的description
样式标签,并在边距中粘贴一个数字,其对齐方式与 的标签类似enumerate
。以下示例阐明了我的意思。
\documentclass[a4paper]{amsbook}
\usepackage[T1]{fontenc}
\usepackage{enumitem} % actually redundant, in this example
\newenvironment*{descriptionThatMimicksItemize}{%
\list{}{\let\makelabel\descriptionTMIlabel}%
}{\endlist}
\newcommand*{\descriptionTMIlabel}[1]{\hss\llap{\upshape #1}}
\makeatletter
\@ifdefinable\origLabelWidth{\newdimen\origLabelWidth}
\@ifdefinable\origLabelSep {\newdimen\origLabelSep}
\makeatother
\newcommand*{\myNumericLabel}[1]{%
\makebox[\origLabelWidth][r]{#1}\hspace{\origLabelSep}%
}
\begin{document}
\origLabelWidth = \labelwidth
\origLabelSep = \labelsep
% This is an over-simplification, but for now we can accept it.
The \texttt{enumerate} environment:
\begin{enumerate}
\item \label{a}
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\item \label{b}
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\end{enumerate}
The first solution:
\begin{descriptionThatMimicksItemize}
\item[(\ref{a}) Is it this what you want?]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\item[(\ref{b}) I wouldn't say so.]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\end{descriptionThatMimicksItemize}
The second one:
\begin{description}
\item[\myNumericLabel{(\ref{a})}I'd rather say it's this]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\item[\myNumericLabel{(\ref{b})}A label is needed, though]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\end{description}
\end{document}
输出:
如果这是真正的问题,则它涉及将提供的标签分成两个部分,因此超出了设置边距和标签宽度的简单问题。
总之,我认为,在明确具体的要求之前,不可能完全回答这个问题。
添加
我开始怀疑这是否只是我们真正想要的:
\documentclass[a4paper]{amsbook} % or whatever
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\begin{document}
Let \( f\colon A\to B \) be a function. The following are equivalent:
\begin{enumerate}
\item\label{a} $f$ is both injective and surjective;
\item\label{b} $f$ is invertible.
\end{enumerate}
Proof:
\begin{enumerate}
\item[$\ref{a}\Rightarrow\ref{b}$:]
Pick an element \( b\in B \), and let \( a\in A \) be the unique element
that is sent into~$b$ by~$f$\ldots
\item[$\ref{b}\Rightarrow\ref{a}$:]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\end{enumerate}
\end{document}
输出:
当然,超链接按预期工作。
但事实上,这不值得悬赏……
第二次添加
还有一种可能性:
\documentclass[a4paper]{amsbook} % or whatever
\usepackage[T1]{fontenc}
\usepackage{enumitem}
\usepackage{hyperref}
\setlist[enumerate,1]
{align=left, labelindent=.5em, labelwidth=1.5em}
\begin{document}
Let \( f\colon A\to B \) be a function. The following are equivalent:
\begin{enumerate}
\item\label{a} $f$ is both injective and surjective;
\item\label{b} $f$ is invertible.
\end{enumerate}
Proof:
\begin{enumerate}
\item[$\mbox{(\ref{a})}\Rightarrow\mbox{(\ref{b})}$:]
Pick an element \( b\in B \), and let \( a\in A \) be the unique element
that is sent into~$b$ by~$f$\ldots
\item[$\mbox{(\ref{a})}\Rightarrow\mbox{(\ref{b})}$:]
Lorem ipsum dolor sit amet consectetur adipisci elit iam
fugiaet enim duscula. Reprivit ursula tum donec.
\end{enumerate}
\end{document}
这是输出 #3:
答案2
\documentclass{article}
\usepackage{enumitem,showframe}
\begin{document}
\begin{enumerate}
\item a.
\item b.
\end{enumerate}
\begin{description}[leftmargin=1.7em,labelindent=*,before={\renewcommand\makelabel[1]{##1}}]
\item[1.] a.
\item[2.] b.
\end{description}
\end{document}