我有一个部分用来描述列表:
\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}