標記不一致的列表和方程

標記不一致的列表和方程

我有一個部分用以下內容描述清單:

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

在此輸入影像描述

相關內容