목록과 방정식에 상충되는 라벨 지정

목록과 방정식에 상충되는 라벨 지정

다음과 같이 목록을 설명하는 섹션이 있습니다.

\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}

여기에 이미지 설명을 입력하세요

관련 정보