How can we use tikz package to draw a rectangle and fill it with a color for the equations? like the following
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(x)=ax+b
\end{equation}
\end{document}
How can we use tikz package to draw a rectangle and fill it with a color for the equations? like the following
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
\begin{equation}
f(x)=ax+b
\end{equation}
\end{document}
\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}
for white borders
\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}
You want to use 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}
with \tcbset{colframe=white}:
in tikz(but tcolorobx i think is the better one):
\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}
\begin{tcolorbox}[enhanced,colback=blue!10,text width=5cm, frame hidden] with \tcbuselibrary{skins} in the prehambule
– flav
Feb 09 '21 at 06:05
\begin{equation*} and \end{equation*} in order to remove the numbering, but you needto load \usepackage{amsmath}.
– Roland
Feb 09 '21 at 06:35