如何使在新的枚举环境中使用方程式统一枚举的文本左对齐?

如何使在新的枚举环境中使用方程式统一枚举的文本左对齐?

首先,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} 

在此处输入图片描述

相关内容