我正在尽一切努力寻找所有可能性,以便将第一个方程式最好地置于环境中的中心subequations
。我无法使用该选项,alignat
因为彩色枚举(这里有@Werner 的完整代码列举书中方程式的一个优雅方面)
\documentclass{book}
\usepackage{mathtools}
\usepackage[svgnames, dvipsnames, table, x11names]{xcolor}
\usepackage{pifont}
\definecolor{ocre}{RGB}{243,102,25}
%----------------------------------------------------------------------------------
% Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}
\makeatletter
\newtagform{bbrackets}% <name>
[\textbf]% Internal style
{(}% Left bracket
{\ifnum\pdfstrcmp{\@currenvir}{equation}=0
\eqnnumsymbol%
\else
\ifnum\pdfstrcmp{\@currenvir}{align}=0
\eqnnumsymbol%
\fi
\fi
)}% Right bracket
\makeatother
\usetagform{bbrackets}
\begin{document}
See both~\eqref{eq:eqn1} and~\eqref{eq:eqn2}. Also see~\eqref{eq:eqn3}.
\begin{equation}
\oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, \mathrm{d}v \label{eq:eqn1}
\end{equation}
\begin{equation}
\oint \mathbf{B} \cdot d \mathbf{a} = \mathbf{0} \label{eq:eqn2}
\end{equation}
\begin{align}
abc \label{eq:eqn3}
\end{align}
\end{document}
消失在我的书中。
我尝试反转符号&
或添加它,但无济于事。你有什么建议吗?谢谢大家。
我正在添加 MWE 和屏幕截图。
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{subequations}
\begin{align}
\overline {F} &=-\overline{\nabla}U(\bar{r})+ \overline{\nabla} \times \overline{W}(\bar{r}) \label{Undec}\\
U(\bar{r})&=\frac1{4\pi}\int_{\mathcal{V}}\frac{D(\bar{r}')}{R}dV', \quad \overline{W}(\bar{r})=\frac1{4\pi}\int_{\mathcal{V}}\frac{\overline{C}(\bar{r}')}{R}dV' \label{Undec1}
\end{align}
\end{subequations}
\end{document}
附录
通过gather
选择我得到了这个:
答案1
如果您不需要等式在等号处对齐,那么我相信gather
环境会满足您的要求:
\documentclass{article}
\usepackage{amsmath}
% From egreg: <https://tex.stackexchange.com/a/501075/73317>
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
\begin{subequations}
\begin{gather}
\overline{F} = - \overline{\nabla}U(\bar{r}) +
\overline{\nabla} \times \overline{W}(\bar{r}) \label{Undec}\\
U(\bar{r}) = \frac{1}{4\pi} \int_{\mathcal{V}} \frac{D(\bar{r}')}{R} \diff V',
\quad
\overline{W}(\bar{r}) =
\frac{1}{4\pi} \int_{\mathcal{V}} \frac{\overline{C}(\bar{r}')}{R} \diff V'
\label{Undec1}
\end{gather}
\end{subequations}
\end{document}
请注意,我删除了&
等号前的 ( 中没有对齐制表符gather
)。我还使用了\diff
命令来自 egreg为差分。
这与方程标签中的红色箭头相同。首先使用相同的技术检查环境名称(存在大量冗余,我们将在下面将其删除):
\documentclass{article}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pifont}
% From egreg: <https://tex.stackexchange.com/a/501075/73317>
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\definecolor{ocre}{RGB}{243,102,25}
\counterwithin{equation}{section}
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}
\makeatletter
\newtagform{bbrackets}% <name>
[\textbf]% Internal style
{(}% Before
{\ifnum\pdfstrcmp{\@currenvir}{equation}=0
\eqnnumsymbol
\else
\ifnum\pdfstrcmp{\@currenvir}{align}=0
\eqnnumsymbol
\else
\ifnum\pdfstrcmp{\@currenvir}{gather}=0
\eqnnumsymbol
\fi
\fi
\fi
)}% After
\makeatother
\usetagform{bbrackets}
\begin{document}
\section{First section}
\begin{subequations}
\begin{gather}
\overline{F} = - \overline{\nabla}U(\bar{r}) +
\overline{\nabla} \times \overline{W}(\bar{r}) \label{Undec}\\
U(\bar{r}) = \frac{1}{4\pi} \int_{\mathcal{V}} \frac{D(\bar{r}')}{R} \diff V',
\quad
\overline{W}(\bar{r}) =
\frac{1}{4\pi} \int_{\mathcal{V}} \frac{\overline{C}(\bar{r}')}{R} \diff V'
\label{Undec1}
\end{gather}
\end{subequations}
\end{document}
现在,以更优雅的方式在内部进行环境名称检查\newtagform{bbrackets}[...]{...}{...}
,这样您只需将希望方程标签具有红色箭头的环境添加到逗号列表中(参见\forcsvlist{...}{equation, align, gather}
下面的行)。
\documentclass{article}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{pifont}
\usepackage{etoolbox}
% From egreg: <https://tex.stackexchange.com/a/501075/73317>
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\definecolor{ocre}{RGB}{243,102,25}
\counterwithin{equation}{section}
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}
\makeatletter
% Helper macro used to insert the arrow symbol from pifont if the current
% environment (\@currenvir) is in the list passed to \forcsvlist.
\newcommand*{\@usearrowifsame}[2]{%
\ifstrequal{#1}{#2}{\eqnnumsymbol\listbreak}{}%
}
\newtagform{bbrackets}% <name>
[\textbf]% Internal style
{(}% Before
{% Insert the red arrow from pifont in the equation tag when we are inside
% one of the environments listed in the second argument.
\forcsvlist{\expandafter\@usearrowifsame\expandafter{\@currenvir}}%
{equation, align, gather}%
)}% After
\makeatother
\usetagform{bbrackets}
\begin{document}
\section{First section}
\begin{subequations}
\begin{gather}
\overline{F} = - \overline{\nabla}U(\bar{r}) +
\overline{\nabla} \times \overline{W}(\bar{r}) \label{Undec}\\
U(\bar{r}) = \frac{1}{4\pi} \int_{\mathcal{V}} \frac{D(\bar{r}')}{R} \diff V',
\quad
\overline{W}(\bar{r}) =
\frac{1}{4\pi} \int_{\mathcal{V}} \frac{\overline{C}(\bar{r}')}{R} \diff V'
\label{Undec1}
\end{gather}
\end{subequations}
\end{document}