I am drafting a document that has an important system of equations, which I would like to highlight by using Roman numerals to enumerate them. I thought about using the subequations environment, but I do not know how to actually change the enumeration and style for only a specific system of equations. Also, afterwards, I would like to derive a new system from the current one, and I would like to enumerate the new one with Roman numerals with stars (asterisks) to the right of the Roman numerals. I was unable to find the answer via web search. I thank all helpers for any assistance.
2 Answers
(I've updated the answer to handle the possibility -- not mentioned by the OP, but likely of some relevance to at least some readers -- that the hyperref package is loaded and that correct hyperlinking from cross-references to equations and the corresponding equations is required.)
In the following solution, I assume that the hyperref
package is loaded. If this assumption is incorrect, you should remove all instances of \renewcommand\theHequation{...}
.
The solution pursued here creates Roman-numeral and Roman-numeral-plus-star equation "numbers" by (a) resetting the equation counter to 0
(or whatever value is deemed appropriate), (b) redefining the \theequation
macro as needed, and (c) redefining the \theHequation
macro. The third step isn't needed if your document doesn't load the hyperref
package. In addition, the solution defines the utility macros \SaveEqCtr
and \RestoreEqCtr
to allow toggling back and forth between ordinary and special forms of the equation number.
\documentclass{article}
\usepackage{amsmath} % for gather environment
\usepackage[colorlinks,allcolors=blue]{hyperref} % optional
\usepackage{cleveref} % for \cref macro
% Create a new counter, to enable toggling back and forth
% between ordinary and special forms of equation counters
\newcounter{SaveEqnCntr}
\newcommand\SaveEqCtr{\setcounter{SaveEqnCntr}{\value{equation}}}
\newcommand\RestoreEqCtr{\setcounter{equation}{\value{SaveEqnCntr}}}
\begin{document}
\begin{equation}
0+0=0 \label{a}
\end{equation}
\SaveEqCtr % Store the current value of 'equation' counter (=1)
\begingroup % Limit the scope of the next few directives to the current TeX group
\setcounter{equation}{0}
%% Display equation counter using Roman numerals:
\renewcommand\theequation{\Roman{equation}}
%% If you use 'hyperref', choose a unique identifier, e.g.,
%% the string 'AA', to redefine the '\theHequation' macro
\renewcommand\theHequation{AA\arabic{equation}}
\begin{gather}
1+1=2 \label{b} \\
1+2=3 \label{c} \\
2+1=3 \label{d}
\end{gather}
\endgroup
\RestoreEqCtr % restore 'standard' form of equation counter
\begin{equation}
2+2=4 \label{e}
\end{equation}
\SaveEqCtr % Store the current value of 'equation' counter (=2)
\begingroup % Limit the scope of the next few directives to the current TeX group
\setcounter{equation}{0}
%% Display equation counter using Roman numerals plus a 'star'
\renewcommand\theequation{\Roman{equation}$^{\star}$}
%% If you use 'hyperref', choose a unique identifier, e.g.,
%% the string 'BB', to redefine the '\theHequation' macro
\renewcommand\theHequation{BB\arabic{equation}}
\begin{gather}
3+3=6 \label{f} \\
3+4=7 \label{g} \\
4+3=7 \label{h}
\end{gather}
\endgroup
\RestoreEqCtr % restore 'standard' form of equation counter
\begin{equation}
4+4=8 \label{i}
\end{equation}
\noindent
Cross-references to \cref{b,c,d}, \cref{f,g,h}, and \cref{a,,e,,i}.
\end{document}
-
thank you very much– user209867Jun 26, 2022 at 7:24
-
1@kroner - You're most welcome. Please note that I've augmented my answer to allow for the possibility that the document employs the
hyperref
package and hence that the hyperlinks between the cross-referencing call-outs and the associated equations have to "work" as expected.– MicoJun 26, 2022 at 9:51
I would use \tag
. After all, you just have one special group of equations and you'll need a label for each one of them.
Using (modified) Mico's code
\documentclass{article}
\usepackage{amsmath} % for gather environment
\usepackage{cleveref} % for \cref macro
\newcounter{maineq}
\renewcommand{\themaineq}{\Roman{maineq}}
\NewDocumentCommand{\maineq}{sm}{%
\IfBooleanTF{#1}{% call is \maineq*
\tag{\ref{#2}*}\label{#2*}%
}{% no *
\stepcounter{maineq}%
\tag{\themaineq}\label{#2}%
}%
}
\begin{document}
Cross-references to \cref{good,bad,ugly} and to
\cref{good*,bad*,ugly*}
\begin{equation} 0+0=0 \label{a} \end{equation}
\begin{gather}
1+1=2 \maineq{good} \\
1+2=3 \maineq{bad} \\
2+1=3 \maineq{ugly}
\end{gather}
\begin{equation} 2+2=4 \label{e} \end{equation}
\begin{gather}
3+3=6 \maineq*{good} \\
3+4=7 \maineq*{bad} \\
4+3=7 \maineq*{ugly}
\end{gather}
\begin{equation} 4+4=8 \label{i} \end{equation}
\end{document}
Using cleveref
is not mandatory and cross references with \ref
will works as well. Anyway, if you use hyperref
, you may want to change \ref
in the definition of \maineq
into \ref*
, precisely
\NewDocumentCommand{\maineq}{sm}{%
\IfBooleanTF{#1}{% call is \maineq*
\tag{\ref*{#2}*}\label{#2*}%
}{% no *
\stepcounter{maineq}%
\tag{\themaineq}\label{#2}%
}%
}
If you don't, the tags in the starred equations will be hyperlinks that point to the original equations.
As a bonus, if you use again \maineq*{good*}
, you will get two asterisks.