对于个人使用,我新两种枚举环境:一种是默认的,我做了一些设置,如下所示;一种是新的枚举环境,它与方程共享计数器,使用@egreg 的方式。我也设置了enumerate item
空间,但是my enumerate item
空间没有变化。
那么如何改进下面的代码,使得空间变得像空间定义的my enumerate item
那么小呢?enumerate item
\documentclass[12pt,leqno]{article}
\usepackage{amsmath,amsfonts,amssymb}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelenumi}{(\alph{enumi})}
%set item space----------------------------------------------------
\usepackage{enumitem}
\setenumerate[1,2,3]{itemsep=0pt,partopsep=0.3\baselineskip plus 0.2ex minus 0.1ex,parsep=0pt,topsep=0pt}
\setitemize[1,2,3]{itemsep=0pt,partopsep=0.3\baselineskip plus 0.2ex minus 0.1ex,parsep=0pt,topsep=0pt}
\setdescription{itemsep=0pt,partopsep=0.3\baselineskip plus 0.2ex minus 0.1ex,parsep=0pt,topsep=0pt}
%set item indent----------------------------------------------------
\setlist[enumerate]{leftmargin=1.7em}
\setlist[itemize]{leftmargin=1.05em}
%define a new enumerate share counter with equation-----------------------
\newcounter{keepeqno}
\newenvironment{myenumerate}
{\setcounter{keepeqno}{\value{equation}}%
\begin{list}{(\theequation)}{\usecounter{equation}}%
\setcounter{equation}{\value{keepeqno}}}
{\end{list}}
%let equation enumerate with section------------------------------------
\numberwithin{equation}{section}%
%set equation number format------------------------------------------
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}%
%allow align linebreak------------------------------------------------
\allowdisplaybreaks
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Test}
\begin{enumerate}
\item Apple
\item Pear
\item Watermelon
\end{enumerate}
\begin{myenumerate}
\item Apple
\item Pear
\item Watermelon
\end{myenumerate}
\end{document}
答案1
编辑:添加了第二个解决方案。
添加
\setlength{\itemsep}{0pt}
\setlength{\partopsep}{0.3\baselineskip plus 0.2ex minus 0.1ex}
\setlength{\parsep}{0pt}
\setlength{\topsep}{0pt}
到列表环境:
\newenvironment{myenumerate}
{\setcounter{keepeqno}{\value{equation}}%
\begin{list}{(\theequation)}{\setlength{\itemsep}{0pt}\setlength{\partopsep}{0.3\baselineskip plus 0.2ex minus 0.1ex}\setlength{\parsep}{0pt}\setlength{\topsep}{0pt}\usecounter{equation}}%
\setcounter{equation}{\value{keepeqno}}}
{\end{list}}
下面是使用包\newlist
中的命令的另一种解决方案enumitem
:
\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate]{label={(\theequation)},align=left,labelwidth=*,
itemsep=0pt,partopsep=0.3\baselineskip plus 0.2ex minus 0.1ex,parsep=0pt,topsep=0pt,
before={\setcounter{keepeqno}{\value{equation}}\usecounter{equation}},
first={\setcounter{equation}{\value{keepeqno}}}}
不幸的是,长度参数似乎不是从环境中继承的enumerate
,所以我不得不复制/粘贴它们。
答案2
编辑此行
\setenumerate[1,2,3]{itemsep
=0pt,partopsep=0.3\baselineskip 加 0.2ex 减 0.1ex,parsep=0pt,topsep=0pt}
在:
\setenumerate[1,2,3]{itemsep=12pt,partopsep=0.3\baselineskip plus 0.2ex minus 0.1ex,parsep=0pt,topsep=0pt}
输出结果如下:
编辑:根据您的评论,更改第二个列表的代码:
\begin{myenumerate}
\vspace{-10pt}\item Apple
\vspace{-10pt}\item Pear
\vspace{-10pt}\item Watermelon
\end{myenumerate}