![在彩色框中显示方程编号(无括号)](https://linux22.com/image/318690/%E5%9C%A8%E5%BD%A9%E8%89%B2%E6%A1%86%E4%B8%AD%E6%98%BE%E7%A4%BA%E6%96%B9%E7%A8%8B%E7%BC%96%E5%8F%B7%EF%BC%88%E6%97%A0%E6%8B%AC%E5%8F%B7%EF%BC%89.png)
而不是通常的括号“()”。
这是我的 MWE:
\documentclass[11pt,fleqn]{book}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[most]{tcolorbox}
\definecolor{ocre}{RGB}{243,102,25}
\definecolor{mygray}{RGB}{243,243,244}
\tcbset{myformula/.style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=ocre,
boxrule=0.8pt,
left=2pt,
right=2pt,
highlight math style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=red.
}
}
}
\newenvironment{spread}[1]{%
\advance\jot#1% indeed
}{%
\ignorespacesafterend
}
\begin{document}
\chapter{This is how it all began}
\section{Introduction}
\begin{tcolorbox}[ams align,myformula]
LT~&\approx~\frac{400}{F_{c}}(1-log_{10}|\Delta F|)\\
\Delta F~&=~\frac{Frequency~Tolerance}{Frequency~Jump}\nonumber
\end{tcolorbox}
\end{document}
答案1
您可以重新定义内部\tagform@
;原始定义是
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip\@@italiccorr)}}
我用的是\fcolorbox
:
\makeatletter
\def\tagform@#1{\fcolorbox{ocre}{mygray}{\maketag@@@{\ignorespaces\textcolor{ocre}{#1}\unskip\@@italiccorr}}}
\makeatother
完整代码:
\documentclass[11pt,fleqn]{book}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage[most]{tcolorbox}
\definecolor{ocre}{RGB}{243,102,25}
\definecolor{mygray}{RGB}{243,243,244}
\tcbset{myformula/.style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=ocre,
boxrule=0.8pt,
left=2pt,
right=2pt,
highlight math style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=red.
}
},
}
\newenvironment{spread}[1]{%
\advance\jot#1% indeed
}{%
\ignorespacesafterend
}
\makeatletter
\def\tagform@#1{\fcolorbox{ocre}{mygray}{\maketag@@@{\ignorespaces\textcolor{ocre}{#1}\unskip\@@italiccorr}}}
\makeatother
\begin{document}
\chapter{This is how it all began}
\section{Introduction}
A cross-reference using \verb!\ref!: \ref{equ:test}\par\noindent
A cross-reference using \verb!\eqref!: \eqref{equ:test}
\begin{tcolorbox}[ams align,myformula]
LT~&\approx~\frac{400}{F_{c}}(1-log_{10}|\Delta F|) \label{equ:test}\\
\Delta F~&=~\frac{Frequency~Tolerance}{Frequency~Jump}\nonumber
\end{tcolorbox}
\end{document}
答案2
这是一个简单的解决方案mathtools
及其\newtagform
命令:
\documentclass[11pt,fleqn]{book}
\usepackage[english]{babel}
\usepackage{xcolor}
\usepackage{mathtools,amsfonts,amssymb,amsthm}
\newtagform{boxed}[\fboxrule=0.6pt\fcolorbox{ocre}{ocre!15!}]{\color{ocre}}{}
\usepackage[most]{tcolorbox}
\definecolor{ocre}{RGB}{243,102,25}
\definecolor{mygray}{RGB}{243,243,244}
\tcbset{myformula/.style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=ocre,
boxrule=0.8pt,
left=2pt,
right=2pt,
highlight math style={
arc=0pt,
outer arc=0pt,
colback=mygray,
colframe=red.
}
}
}
\newenvironment{spread}[1]{%
\advance\jot#1% indeed
}{%
\ignorespacesafterend
}
\begin{document}
\chapter{This is how it all began}
\section{Introduction}
\usetagform{boxed}
\begin{tcolorbox}[ams align,myformula]
LT~&\approx~\frac{400}{F_{c}}(1-log_{10}|\Delta F|)\label{coloureq}\\
\Delta F~&=~\frac{Frequency~Tolerance}{Frequency~Jump}\nonumber
\end{tcolorbox}
\ref{coloureq}
\eqref{coloureq}
\end{document}