我正在尝试为我的书中的各种方程式创建这种枚举,类似于此图:
我的 MWE 是:
\documentclass{book}
\usepackage{mathtools}
\usepackage{newtxtext}
\usepackage{newtxmath}
\PassOptionsToPackage{svgnames, dvipsnames, table, x11names}{xcolor}
\usepackage{tikz}
\usepackage{classico}
\usepackage{pifont}
\definecolor{ocre}{RGB}{243,102,25}
%----------------------------------------------------------------------------------
% Change number equations with sections
%----------------------------------------------------------------------------------
\usepackage{chngcntr}
\counterwithin{equation}{section}
\renewcommand{\theequation}{\bfseries{\sffamily{\thesection-\arabic{equation}}}\textcolor{ocre}{\ding{228}}}
\begin{document}
\begin{equation}
\oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, dv
\end{equation}
\begin{equation}
\oint \mathbf{B} \cdot d \mathbf{a} = \mathbf{0}
\end{equation}
\end{document}
输出如下:
我遇到了以下问题(见下图):
- 我不知道如何消除圆括号;
- 如果我们假设不删除圆括号,左边的那个就不会是粗体,而右边的那个就会是粗体。
- 使用
pifont
包时,我试图使用包将箭头的方向反转到左边\rotatebox{...}{...}
,graphicx
但我可能不会将箭头的方向旋转到左边。
答案1
下面的结果就是你想要的结果:
\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}
它用
mathtools
'为s 和相关环境\newtagform
建立一种新的标签形式。equation
设置符号的条件。如果在 或 内
equation
,align
则添加符号,否则省略。这允许您使用\eqref
。它没有经过广泛测试,但在提供的示例中有效。
如果你想删除大胆的根据您的参考编号,您可以使用以下内容:
\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}
\makeatletter
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newcommand{\eqnumfmt}{%
\ifnum\pdfstrcmp{\@currenvir}{equation}=0
\bfseries
\else
\ifnum\pdfstrcmp{\@currenvir}{align}=0
\bfseries
\fi
\fi}
\newcommand{\eqnnumsymbol}{\textcolor{ocre}{\reflectbox{\ding{228}}}}
\newtagform{bbrackets}% <name>
[\eqnumfmt]% Internal style
{(\bgroup}% Left bracket
{\ifnum\pdfstrcmp{\@currenvir}{equation}=0
\eqnnumsymbol%
\else
\ifnum\pdfstrcmp{\@currenvir}{align}=0
\eqnnumsymbol%
\fi
\fi
\egroup)}% 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}
答案2
我提出了另一种解决方案,没有括号,基于\newtagform
命令mathtools
和adforn
装饰包,它有一个向左的箭头。我擅自更改了它的颜色,使其更适合黑色字符(谢谢你…)。当然,如果您喜欢的话,可以自由选择自己的颜色:
\documentclass{book}
\usepackage{mathtools}
\usepackage{newtxtext}
\usepackage{newtxmath}
\PassOptionsToPackage{svgnames, dvipsnames, table, x11names}{xcolor}
\usepackage{tikz}
\usepackage{classico}
\usepackage{adforn}
\definecolor{ocre}{RGB}{243,102,25}
%----------------------------------------------------------------------------------
% Change number equations with sections
%----------------------------------------------------------------------------------
\counterwithin{equation}{section}%
\renewcommand{\theequation}{\thesection-\arabic{equation}}
\newtagform{arrowtip}[\bfseries\sffamily]{}{\,\textcolor{IndianRed3}{\Large\adforn{42}}}
\usetagform{arrowtip}
\begin{document}
\setcounter{chapter}{2}
\setcounter{section}{5}
\begin{equation}
\oint \mathbf{E} \cdot d \mathbf{a} = \int \rho \, dv
\end{equation}
\begin{equation}
\oint \mathbf{B} \cdot d \mathbf{a} = \mathbf{0}
\end{equation}
\end{document}