我为一位物理学教授工作,使用revtex4
(仅 4,而不是 4-1 或 4-2)。我正在使用该amsmath
软件包。我一直在使用
\renewcommand{\thesection}{\arabic{section}}
\numberwithin{equation}{section}
\renewcommand{\theequation}{\arabic{section}.\arabic{equation}}
非常成功地得到了具有以下形式的方程数安全值.eqnum例如 1.1、1.2、1.3、2.1、2.2、2.3 等。现在我的教授想要创建这样的文本:
Here are three elements:
(1) some text
(2) some more text
(3) even more text, which now must meet the following criteria:
(i) Descriptor
a+b=c (sample equation, which he wants numbered like this:) (5.1a)
(ii) Second descriptor
d+e=f (second equation, which he wants numbered like this:) (5.1b)
(iii) Third descriptor
g+h=i (5.1c)
(iv) Fourth descriptor. Followed by lots more text and then the final equation:
j+k=l (5.1d)
This appears to be the end of what I would have created in a nested enumerate environment.
His paragraph then continues, with the next equation numbered like so:
m+n=o (5.2)
因此,我有两个问题:
- 正确的做法是:
Here are three elements:
\begin{enumerate}
\item some text
\item some more text
\item even more text, which now must meet the following criteria:
\begin{enumerate}
\item Descriptor
(some magical code here that will produce the equation I need numbered 5.1a)
\item Second descriptor
(some more magical code that will produce the second equation numbered 5.1b)
\item Third descriptor
(yet even more magical code that will produce the third equation numbered 5.1c)
\item Fourth descriptor. Followed by lots more text and then the final equation:
(which will have more magical code that will produce a number of 5.1d)
\end{enumerate}
\end{enumerate}
Continue with text until he wants his next equation
\begin{equation}
m+n=0 \label{eq:5.2}
\end{equation}
...或者我已经完全偏离主题了?
我的第二个问题是:
- 我需要什么神奇的编码来实现这一目标?
答案1
输出结果并没有什么神奇之处。以下是一些线索:
使用
enumitem
它允许您向环境中添加一个可选参数,enumerate
在其中指定label={(\arabic*)}
第一级别和label={(\roman*)}
第二级别;使用
subequations
内部/嵌套周围的环境enumerate
来确保方程式具有子编号样式。注意:将方程编号声明为包含
\thesection
而不是显式的\arabic{section}
,因为这会分层定义它。如果\thesection
发生更改,它也会自动更改\theequation
,而不必在两个地方进行更改。
\documentclass{revtex4}
\usepackage{amsmath}
\usepackage{enumitem}
\renewcommand{\thesection}{\arabic{section}}
\numberwithin{equation}{section}
\renewcommand{\theequation}{\thesection.\arabic{equation}}
\begin{document}
\setcounter{section}{4}
\section{A section}
Here are three elements:
\begin{enumerate}[label={(\arabic*)}]
\item some text
\item some more text
\item even more text, which now must meet the following criteria:
\begin{subequations}
\begin{enumerate}[label=(\roman*)]
\item Descriptor
\begin{equation}
f(x) = ax^2 + bx + c
\end{equation}
\item Second descriptor
\begin{equation}
g(x) = ax^2 + bx + c
\end{equation}
\item Third descriptor
\begin{equation}
h(x) = ax^2 + bx + c
\end{equation}
\item Fourth descriptor. Followed by lots more text and then the final equation:
\begin{equation}
i(x) = ax^2 + bx + c
\end{equation}
\end{enumerate}
\end{subequations}
\end{enumerate}
Continue with text until he wants his next equation
\begin{equation}
f(x) = ax^2 + bx + c
\end{equation}
\end{document}