我有以下 mwe。我想只为方程式着色并加框,除了方程式编号。我尝试使用{\颜色{} }和\我的盒子{}但它们不起作用。任何帮助都非常感谢。
\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}
答案1
像这样?
\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}
或者您喜欢有框架和彩色的文本?
\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}
注意:由于方程太宽,其数字无法与方程对齐,我使用multlined
环境 from mathtools
(由包加载)将其分成三行。如果您喜欢这种格式的方程,您可以像在环境empheq
中一样插入方程。split
如果您想更改框线颜色和线条粗细,请使用fcolorbox
(从包中cxolor
)。例如:
\newcommand*\widefbox[1]%
{
\setlength{\fboxrule}{2pt}% if you like to change box lines thicnes
\fcolorbox{blue}{white}{\qquad#1\qquad}%
}
您将获得:
(嗯,对我的口味来说,这太花哨了:-()。)
答案2
以下是基于的提议这个答案。
\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}
解释:在一些“极端”位置定义了四个节点,(1)
、(2)
和。这样就可以制作自定义框而无需改变布局(3)
。(4)