# Change border color of a \boxed equation?

I recently asked this question. The solution worked for me but I have a problem. cropped images are as small as possible. I would like to have a gif that bounds to borders of box of the equation. so I add \boxed to all my equations. Now sizes are good but I don't know how do I remove black borders around equation. Probably changing its color to white will help. [?]

-

You could redefine the \boxed command. For example:

\renewcommand{\boxed}[1]{\textcolor{\boxedcolor}{%
\fbox{\normalcolor\m@th$\displaystyle#1$}}}


It's originally defined in amsmath.sty:

\newcommand{\boxed}[1]{\fbox{\m@th$\displaystyle#1$}}


Here's a complete minimal example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xcolor}
\newcommand*{\boxedcolor}{red}
\makeatletter
\renewcommand{\boxed}[1]{\textcolor{\boxedcolor}{%
\fbox{\normalcolor\m@th$\displaystyle#1$}}}
\makeatother
\begin{document}
text
$$\boxed{1+1=2}$$
text
\end{document}

-
Is it possible to add a background??? –  71GA Oct 3 '12 at 8:31

Another idea of Herbert in mathmode.pdf for coloured boxes is to use package empheq (now in the mh bundle)

\documentclass{article}
\usepackage{amsmath,empheq}
\usepackage{xcolor}

\begin{document}

$f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1$
\begin{empheq}[box={\color{white}\fboxsep=10pt\fbox}]{align}
\color{red}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}

\begin{empheq}[box={\fboxsep=10pt\fbox}]{align}
\color{red}
f(x)=\int_1^{\infty}\frac{1}{x^2}\,\mathrm{d}x=1
\end{empheq}
\end{document}


-

Set a border for the preview.

\documentclass{scrartcl}
\usepackage{amsmath}
\usepackage[active,displaymath,tightpage]{preview}
\setlength\PreviewBorder{10pt}
\begin{document}

$y=x$
\begin{align} g(x)=x^2 \end{align}

\end{document}

-