我正在尝试修改以下标签,使字母变为大写字母。我还需要交叉引用(使用 cleverref)来匹配新定义的样式。有几个相关的问题,但我无法将所有知识混在一起来提出我需要的东西。MWE 来了:
\documentclass{article}
\usepackage{mathtools, amsthm, amssymb} % MATH PACKAGES
\usepackage{cleveref} % FOR FANCY REFERENCES
\begin{document}
Look what a fancy optimisation problem in \cref{p} subject to \cref{c1,c2}, folks!
\begin{subequations}
\begin{alignat}{2}\label{p}
& \max_{L,\mathbf{x}} & & v(L) - \sum_{i \in L} \delta \cdot x_i\\\label{c1}
& \text{subject to} &\quad & \mathbf{x} \in \mathfrak{C}(\mathfrak{L},v)\\\label{c2}
& & & x_i \geqslant \delta \cdot x_i^{*} \forall \text{ Players }i\in N \text{ such that } \omega_i < \omega_j
\end{alignat}
\end{subequations}
\end{document}
当前输出如下:
我需要的是所有地方都使用大写字母 A、B 和 C。
提前感谢大家的时间!
答案1
我认为这就是你想要的。{subequations}
环境对行为进行了硬编码,即子方程式应写为小写字母\alph{equation}
。这将使用包\patchcmd
中的句柄etoolbox
替换您可以根据需要定义的句柄。\alph{equation}
\thechildequation
这个修补必须在加载包之前完成,cleverref
因为cleverref
它在原始环境周围定义了自己的包装器{subequations}
,因此它可以添加自己的处理(它将原始内容移动\subequations
到\cref@old@subequations
)。
\documentclass{article}
\usepackage{mathtools, amsthm, amssymb} % MATH PACKAGES
\usepackage{etoolbox}
\patchcmd\subequations{\theparentequation\alph{equation}}{\theparentequation\thechildequation}{}{\error} % Must come before loading cleverref
\usepackage{cleveref} % FOR FANCY REFERENCES
\newcommand*{\thechildequation}{\Alph{equation}}
\begin{document}
Look what a fancy optimisation problem in \cref{p} subject to \cref{c1,c2}, folks!
\begin{subequations}
\begin{alignat}{2}\label{p}
& \max_{L,\mathbf{x}} & & v(L) - \sum_{i \in L} \delta \cdot x_i\\\label{c1}
& \text{subject to} &\quad & \mathbf{x} \in \mathfrak{C}(\mathfrak{L},v)\\\label{c2}
& & & x_i \geqslant \delta \cdot x_i^{*} \forall \text{ Players }i\in N \text{ such that } \omega_i < \omega_j
\end{alignat}
\end{subequations}
\end{document}
答案2
您可以重新定义环境。只需将其放在加载之后和之前的subequations
序言中即可:amsmath
cleverref
\makeatletter
\renewenvironment{subequations}{%
\refstepcounter{equation}%
\protected@edef\theparentequation{\theequation}%
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}% VVVV - Changed to "Alph"
\def\theequation{\theparentequation\Alph{equation}}%
\ignorespaces
}{%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}
\makeatother
重新定义是必要的,因为\theequation
每次调用环境时都会定义,所以不可能(据我所知)仅定义标签。
答案3
这是一个解决方案:定义一个Subequations
环境(\renewwenvironment{subequations}
也可以)。我纠正了一些间距问题,并提出了另一种对齐方式,在我看来,它看起来更好:
\documentclass{article}
\usepackage{mathtools, amsthm, amssymb} % MATH PACKAGES
\usepackage{cleveref} % FOR FANCY REFERENCES
\makeatletter
\newenvironment{Subequations}{%
\refstepcounter{equation}%
\protected@edef\theparentequation{\theequation}%
\setcounter{parentequation}{\value{equation}}%
\setcounter{equation}{0}%
\def\theequation{\theparentequation\Alph{equation}}%
\ignorespaces
}{%
\setcounter{equation}{\value{parentequation}}%
\ignorespacesafterend
}
\makeatother
\begin{document}
Look what a fancy optimisation problem in \cref{p} subject to \cref{c1,c2}, folks!
\begin{Subequations}
\begin{alignat}{2}\label{p}
& \max_{L,\mathbf{x}} & & v(L) - \sum_{i \in L} \delta \cdot x_i\\\label{c1}
& \text{subject to} &\quad & \mathbf{x} \in \mathfrak{C}(\mathfrak{L},v)\\\label{c2}
& & & x_i \geqslant \delta \cdot x_i^{*}\quad \forall \text{ Players }i\in N \text{ such that } \omega_i < \omega_j
\end{alignat}
\end{Subequations}
\begin{Subequations}
\begin{alignat}{2}\label{q}
\max_{L,\mathbf{x}} & & & v(L) - \sum_{i \in L} \delta \cdot x_i\\\label{d1}
\text{subject to} & &\quad & \mathbf{x} \in \mathfrak{C}(\mathfrak{L},v)\\\label{d2}
& & & x_i \geqslant \delta \cdot x_i^{*} \quad \forall \text{ Players }i\in N \text{ such that } \omega_i < \omega_j
\end{alignat}
\end{Subequations}
\begin{Subequations}
\begin{alignat}{2} %\label{r}
& \max_{L,\mathbf{x}} \quad \mathrlap{v(L) - \sum_{i \in L} \delta \cdot x_i} \\[0.5ex] \label{e1}
& \text{subject to} & \quad \smash{\rule[-4.5ex]{0.5pt}{6.5ex}\;}& \mathbf{x} \in \mathfrak{C}(\mathfrak{L},v) \\\label{e2}
& & & x_i \geqslant \delta \cdot x_i^{*} \quad \forall \text{ Players }i\in N \text{ such that } \omega_i < \omega_j
\end{alignat}
\end{Subequations}
\end{document}