LaTeX forum ⇒ Math & ScienceFill \Aboxed With Color Topic is solved

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

Fill \Aboxed With Color

Postby Kareem » Fri Aug 14, 2020 3:31 pm

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

\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 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
Bartman
Posts: 256
Joined: Fri Jan 03, 2020 2:39 pm

Fill \Aboxed With Color  Topic is solved

Postby Bartman » Fri Aug 14, 2020 5:35 pm

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

\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

Postby Kareem » Fri Aug 14, 2020 7:19 pm

Great answer. It works like a charm!

Kareem
Posts: 9
Joined: Sat Aug 04, 2012 2:28 pm

Fill \Aboxed With Color

Postby Kareem » Tue Dec 14, 2021 11:52 am

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


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 5 guests