答案1
\documentclass{article}
\usepackage{amsmath}
\usepackage[customcolors]{hf-tikz}
\begin{document}
\hfsetfillcolor{blue!10}
\hfsetbordercolor{blue}
\begin{equation}\label{e:barwq2}
\tikzmarkin{b} f(x)=ax+b\tikzmarkend{b}\\
\end{equation}
\end{document}
用于白色边框
\documentclass{article}
\usepackage{amsmath}
\usepackage[customcolors]{hf-tikz}
\begin{document}
\hfsetfillcolor{blue!20}
\hfsetbordercolor{white}
\begin{equation}\label{e:barwq2}
\tikzmarkin{b} f(x)=ax+b\tikzmarkend{b}\\
\end{equation}
\end{document}
答案2
您想使用 tcolorbox:
\documentclass{article}
\usepackage{amssymb}
\usepackage{tcolorbox}
\begin{document}
\begin{tcolorbox}[colback=blue!10,text width=5cm]
\begin{equation}
\centering f(x)=ax+b
\end{equation}
\end{tcolorbox}
\end{document}
和\tcbset{colframe=white}
:
在 tikz 中(但我认为 tcolorobx 是更好的一个):
\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node [fill=cyan!20,text width=4cm] at (0,0) {\begin{equation}f(x)=ax+b\end{equation}};
\end{tikzpicture}
\end{document}