ラベル付けリストと方程式の矛盾

ラベル付けリストと方程式の矛盾

リストについて説明するセクションがあります:

\renewcommand{\labelenumi}{\arabic*{enumi}.}

そして次の方程式:

\renewcommand{\theequation}{\labelenumi-\arabic{equation}}

したがって、当然、方程式の番号付けは次のようになります。

1.-1

しかし、リストに 1.、2.、3. とラベルを付け、方程式に 1-1、1-2、1-3 とラベルを付けたいのですが、これを行う方法はありますか?

私たち:

\documentclass[fleqn]{book}
\usepackage{enumitem}

\begin{document}

\textbf{PROBLEMS}
\renewcommand{\labelenumi}{\arabic*{enumi}.}
\renewcommand{\theequation}{\labelenumi-\arabic{equation}}

\begin{enumerate}[label=\arabic*.]
\setcounter{equation}{0}
%%1%%
\item Consider:

\begin{equation}\label{eq: 5.1.1}
a \times b = c
\end{equation}

\begin{equation}\label{eq: 5.1.2}
a = \sqrt{bc}
\end{equation}

\setcounter{equation}{0}
%%2%%
\item  Another problem.
\end{enumerate}
\end{document}

答え1

の代わりに

\renewcommand{\theequation}{\labelenumi-\arabic{equation}}

使用できます

\renewcommand{\theequation}{\arabic{enumi}-\arabic{equation}}

コード:

\documentclass[fleqn]{book}
\usepackage{enumitem}

\begin{document}

\textbf{PROBLEMS}
\renewcommand{\labelenumi}{\arabic{enumi}.}
\renewcommand{\theequation}{\arabic{enumi}-\arabic{equation}}

\begin{enumerate}[label=\arabic*.]
\setcounter{equation}{0}
%%1%%
\item Consider:

\begin{equation}\label{eq: 5.1.1}
a \times b = c
\end{equation}

\begin{equation}\label{eq: 5.1.2}
a = \sqrt{bc}
\end{equation}

\setcounter{equation}{0}
%%2%%
\item  Another problem.
\end{enumerate}
\end{document}

ここに画像の説明を入力してください

答え2

amsmathまず、を使用する必要があります。その後、enumitemの機能を活用できます。

\documentclass[fleqn]{book}
\usepackage{amsmath}
\usepackage{enumitem}

\newenvironment{enumeq}
 {\renewcommand{\theequation}{\arabic{enumi}-\arabic{equation}}%
  \begin{enumerate}[label=\arabic*.,before=\changeitem]}
 {\end{enumerate}}

\newcommand{\changeitem}{%
  \let\ORIitem\item
  \renewcommand\item{%
    \setcounter{equation}{0}%
    \ORIitem
  }%
}


\begin{document}

\textbf{PROBLEMS}

\begin{enumeq}
\item Consider:
\begin{gather}
a \times b = c
\label{eq: 5.1.1}
\\
a = \sqrt{bc}
\label{eq: 5.1.2}
\end{gather}

\item  Another problem
\begin{equation}
 a=b
\end{equation}
\end{enumeq}

Here are the references: \eqref{eq: 5.1.1} and \eqref{eq: 5.1.2}

\end{document}

ここに画像の説明を入力してください

関連情報