![如何使在新的枚举环境中使用方程式统一枚举的文本左对齐?](https://linux22.com/image/447767/%E5%A6%82%E4%BD%95%E4%BD%BF%E5%9C%A8%E6%96%B0%E7%9A%84%E6%9E%9A%E4%B8%BE%E7%8E%AF%E5%A2%83%E4%B8%AD%E4%BD%BF%E7%94%A8%E6%96%B9%E7%A8%8B%E5%BC%8F%E7%BB%9F%E4%B8%80%E6%9E%9A%E4%B8%BE%E7%9A%84%E6%96%87%E6%9C%AC%E5%B7%A6%E5%AF%B9%E9%BD%90%EF%BC%9F.png)
首先,MWE 如下。
\documentclass[12pt,leqno]{article}
\usepackage{amsmath}
\numberwithin{equation}{section}%
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}%
\newcounter{keepeqno}
\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}}
\begin{document}
\section{Test}
The equation is
\begin{equation}
f(x)=x^2+3x+9.
\end{equation}
It satisfies the following conditions.
\begin{myenumerate}
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\end{myenumerate}
\end{document}
编译后的PDF如下所示。
如你所见,我定义了一个新的枚举环境,其中项目与方程式一起列在本节中(请参见链接因为要定义这样一个新的枚举环境),并且项目 (1.2) 中的文本是左对齐的,而项目 (1.10) 中的文本则不是。那么如何使项目(1.10)中的文本也左对齐?
答案1
尝试这个。
\documentclass[12pt,leqno]{article}
\usepackage{amsmath}
\numberwithin{equation}{section}%
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}%
\newcounter{keepeqno}
\usepackage{enumitem,calc}
\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate]{label={(\theequation)},
align=left,labelwidth=\widthof{(9.99)},leftmargin=!,
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}}}}
\begin{document}
\section{Test}
The equation is
\begin{equation}
f(x)=x^2+3x+9.
\end{equation}
It satisfies the following conditions.
\begin{myenumerate}
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\end{myenumerate}
The equation is
\begin{equation}
f(x)=x^2+3x+9.
\end{equation}
It satisfies the following conditions.
\begin{myenumerate}
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\end{myenumerate}
\end{document}
答案2
我想建议你不是从头开始创建一个类似列表的环境。相反,我建议您加载包并enumitem
使用其宏来创建一个定制的类似枚举的列表。\newlist
\setlist
\documentclass[12pt]{article}
\usepackage{amsmath}
\numberwithin{equation}{section}%
\usepackage{enumitem} % see https://www.ctan.org/pkg/enumitem
\newlist{myenum}{enumerate}{1}
\setlist[myenum,1]{label=(\arabic{equation}.\arabic*),noitemsep}
\begin{document}
\stepcounter{equation}
\begin{myenum}
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\end{myenum}
\end{document}
答案3
我建议用enumitem
;
\documentclass[12pt]{article}
\usepackage{amsmath}
\numberwithin{equation}{section}%
\usepackage{enumitem}
\newlist{myenumerate}{enumerate}{1}
\setlist[myenumerate]{label =(\thesection.\arabic*), wide=0pt, labelsep=3pt, widest=11, leftmargin=*}
\begin{document}
\section{Test}
\begin{myenumerate}
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Some texts.
\item Belonging to a hereditary class with high social or political status; aristocratic. Belonging to a hereditary class with high social or political status; aristocratic.
\end{myenumerate}
\end{document}