Math & ScienceFill \Aboxed With Color

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

Fill \Aboxed With Color

Post by Kareem »

Is there a simple way to fill \Aboxed with color inside an align environment? Below is my code

Code: Select all

\begin{align}
\Aboxed{f(x) &= \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty  {\left[a_n \cos{\left( {{\displaystyle{\frac{2n\pi x}{p}}}} \right) + {b_n}\sin \left( {{\displaystyle{\frac{2n\pi x}{p}}}} \right)} \right]},}\\
\vdots
\end{align}
I want to highlight the first equation.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

Fill \Aboxed With Color

Post by Bartman »

If you had given a complete Infominimal working example, then the reader would know how to make the \Aboxed command available.

You could redefine the definition of the command by

Code: Select all

\makeatletter
\def\@Aboxed#1&#2&#3\ENDDNE{%
  \ifnum0=`{}\fi \setbox \z@
    \hbox{$\displaystyle#1{}\m@th$\kern\fboxsep \kern\fboxrule }%
    \edef\@tempa {\kern  \wd\z@ &\kern -\the\wd\z@ \fboxsep
        \the\fboxsep \fboxrule \the\fboxrule }\@tempa 
        \fcolorbox{black}{yellow}{$\displaystyle #1#2$}% changed
}
\makeatother
In addition to mathtools, this source code also needs something like xcolor.

The hf-tikz package would be another way to color the equation.

Finally, a remark on the content of the equation: I don't understand why you use \displaystyle in the align environment.
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

Fill \Aboxed With Color

Post by Kareem »

Great answer. It works like a charm!
Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

Fill \Aboxed With Color

Post by Kareem »

Is there a way to define another environment like Aboxed but with a different colour other than yellow?
Post Reply