3

I have the following mwe. I want to color and box only the equation except the equation number. I tried using {\color{} } and \mybox{} but they didn't work. Any help is much appreciated.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\begin{document}
\begin{equation}
\begin{split}
&\sum_{k=-\infty}^{\infty} 
\frac{(-1)^k(\alpha+k+\frac12) \sin \sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}{(\beta^2+(2k+1)^2)\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}} \\
&=\frac{\pi(\alpha+\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}
-
\frac{\pi(\alpha-\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}.
\end{split}
\end{equation}
\end{document}
6

like this?

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{empheq,
            amssymb}
\usepackage[dvipsname]{xcolor}
\newcommand*\widefbox[1]{\colorbox{teal!30}{\qquad#1\qquad}}

\begin{document}
\begin{empheq}[box=\widefbox]{equation}
\begin{multlined}
\sum_{k=-\infty}^{\infty}
    \frac{(-1)^k(\alpha+k+\frac12) \sin \sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}
         {(\beta^2+(2k+1)^2)\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}   \\
    = \frac{\pi(\alpha+\frac12 i \beta)
                \sin\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}
         {4i\beta\cosh(\frac{\pi}{2}\beta)
                \sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}        \\
    - \frac{\pi(\alpha-\frac12 i \beta)
                \sin\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}
           {4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}.
\end{multlined}
\end{empheq}
\end{document}

or you like to have frame and colored text?

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{empheq,
            amssymb}
\usepackage[dvipsname]{xcolor}
\newcommand*\widefbox[1]{\fbox{\qquad#1\qquad}}

\begin{document}
\begin{empheq}[box=\widefbox]{equation}
\color{red}
\begin{multlined}
\sum_{k=-\infty}^{\infty}
    \frac{(-1)^k(\alpha+k+\frac12) \sin \sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}
         {(\beta^2+(2k+1)^2)\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}   \\
    = \frac{\pi(\alpha+\frac12 i \beta)
                \sin\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}
         {4i\beta\cosh(\frac{\pi}{2}\beta)
                \sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}        \\
    - \frac{\pi(\alpha-\frac12 i \beta)
                \sin\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}
           {4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}.
\end{multlined}
\end{empheq}
\end{document}

note: since the equation is to wide that its number can be placed in line with equation, i broke it into three lines using multlined environment from mathtools (which is loaded by the package empheq). if yout liked this format of equation, you can insert your equation as you have with split environment.

if you like to change box line color and lines thickness than use fcolorbox (from the package cxolor). for example:

\newcommand*\widefbox[1]%
    {
    \setlength{\fboxrule}{2pt}% if you like to change box lines thicnes
    \fcolorbox{blue}{white}{\qquad#1\qquad}%
    }

and you will obtain:

enter image description here

(well, to my taste, this is to fancy :-( ).

  • you were to fast with comment, i need some time to upload the second possibility :-). – Zarko Mar 26 '18 at 1:14
  • I thought you were hibernating. (+1) – user121799 Mar 26 '18 at 1:20
  • @marmot, yesterday we change time to summer (+ 1 hour). since i'm not yet accommodate to this, i'm still wake up :-(. thank you very much! – Zarko Mar 26 '18 at 1:27
  • These clashing with the set up I had for "\mybox{}". How can I resolve that. – Eureka Mar 26 '18 at 1:36
  • @Fib1123, what is clashing? elaborate please. – Zarko Mar 26 '18 at 1:49
2

Here is a proposal based on this answer.

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb}
\usepackage{tikz}
\usetikzlibrary{fit}
\newcommand{\tikznode}[2]{\tikz[remember picture,baseline=(#1.base)]{\node(#1)[inner sep=0pt]{#2};}}

\definecolor{myblue}{rgb}{.8, .8, 1}
\begin{document}
\begin{equation}
\begin{split}
&\tikznode{1}{\strut}\sum_{k=-\infty}^{\infty} 
\frac{(-1)^k(\alpha+k+\frac12) \sin
\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}\tikznode{2}{\strut}}{(\beta^2+(2k+1)^2)\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}
\\
&=\frac{\pi(\alpha+\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}
-
\frac{\pi(\alpha-\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}
\tikznode{3}{\strut}}.
\tikznode{4}{\strut}
\end{split}\tikz[remember picture,overlay]{
\node[fit=(1) (2) (3) (4),fill=blue,fill opacity=0.25]{};}
\end{equation}
or
\begin{equation}
{\leavevmode\color{red}
\begin{split}
&\tikznode{5}{\strut}\sum_{k=-\infty}^{\infty} 
\frac{(-1)^k(\alpha+k+\frac12) \sin
\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}\tikznode{6}{\strut}}{(\beta^2+(2k+1)^2)\sqrt{b^2+\pi^2(\alpha+k+\frac12)^2}}
\\
&=\frac{\pi(\alpha+\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha+\frac{i}{2}\beta)^2}}
-
\frac{\pi(\alpha-\frac12 i \beta)\sin\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}}{4i\beta\cosh(\frac{\pi}{2}\beta)\sqrt{b^2+\pi^2(\alpha-\frac{i}{2}\beta)^2}
\tikznode{7}{\strut}}.
\tikznode{8}{\strut}
\end{split}}\tikz[remember picture,overlay]{
\node[fit=(5) (6) (7) (8),draw=blue,fill opacity=0.25]{};}
\end{equation}
\dots and back to black
\end{document}

enter image description here

Explanation: There are four nodes defined, (1), (2), (3) and (4) at some "extreme" positions. This allows one to make custom boxes without shifting the layout.

  • Thank you for the answer. How to get rid of the background color ? – Eureka Mar 26 '18 at 1:13
  • 1
    @Fib1123 Just replace fill=blue by draw. – user121799 Mar 26 '18 at 1:14
  • in the latter you had the equation number colored as well. How to get rid of that ? Thank you. – Eureka Mar 26 '18 at 1:52
  • @Fib1123 Please see my update. – user121799 Mar 26 '18 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.