2

I'm trying to write an equation and I used left and right to adjust parentheses. Unfortunately, there is too much white space in the top of parentheses.

Is there any way to reduce the white space?

my equation is:

$$ a_n=\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\left[\frac{1}{4}\cos(3x)+\frac{3}{4}\cos(x)\right]\cos(nx)\text{d}x=\frac{1}{4}\left[\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(3x)\cos(nx)\text{d}x}_{\text{By lemma: }=\begin{cases}0,& \ n\ne 3 \\ 1,& n=3 \end{cases}}+3\cdot{\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(x)\cos(nx)\text{d}x}_{\text{By lemma: }=\begin{cases}0,& n \ne 1 \\ 1,& n=1 \end{cases}}}\right]$$

and the output is: enter image description here

Please help, thank you!

2
  • Off-topic; Don't use $$...$$. Use \[...\]
    – user31729
    Oct 26, 2015 at 9:22
  • 2
    there are three ways: you could raise the expression so it is vertically centred or lower the brackets so they are not vertically centred. But probably better you could just bracket the terms above the underbraces, not the whole term including the brace comments. If you said which you wanted, someone would say how to do it:-) Oct 26, 2015 at 9:24

2 Answers 2

2

One possibility is to add \vcenter{\hbox{$\displaystyle $}}:

$$ a_n=\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\left[\frac{1}{4}\cos(3x)+\frac{3}{4}\cos(x)\right]\cos(nx)\text{d}x=%
\frac{1}{4}\left[\vcenter{\hbox{$\displaystyle\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(3x)\cos(nx)\text{d}x}_{\text{By lemma: }=%
    \begin{cases}0,& \ n\ne 3 \\ 1,& n=3 \end{cases}}+3\cdot{\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(x)\cos(nx)\text{d}x}_{\text{By lemma: }=\begin{cases}0,& n \ne 1 \\ 1,& n=1 \end{cases}}}$}}\right]$$

Perhaps not a pretty answer, but I've found it works whenever I need it.

1
  • @Galc127 perhaps prettier if you use the code '$$ a_n=\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\left[\frac{1}{4}\cos(3x)+\frac{3}{4}\cos(x)\right]\cos(nx)\text{d}x=% \frac{1}{4}\underbrace{\left[\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(3x)\cos(nx)\text{d}x \right. }_{\text{By lemma: }=% \begin{cases}0,& \ n\ne 3 \\ 1,& n=3 \end{cases}}+3\cdot{\underbrace{\left.\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(x)\cos(nx)\text{d}x\right]}_{\text{By lemma: }=\begin{cases}0,& n \ne 1 \\ 1,& n=1 \end{cases}}}$$' Oct 26, 2015 at 9:43
5

May be it looks better like this and perhaps this can be broken in to two lines.

\documentclass{article}
\usepackage{amsmath}
\newcommand*{\myd}{\mathrm{d}}
\begin{document}
  \[
a_n =\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\biggl[\frac{1}{4}\cos(3x)+\frac{3}{4}\cos(x)\biggr]
                                \cos(nx)\myd x 
=\frac{1}{4}\Biggl[\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(3x)\cos(nx)\myd x}_{\text{By lemma: }=\begin{cases}0,&  n\ne 3 \\ 1,& n=3 \end{cases}}+3\cdot{\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(x)\cos(nx)\myd x}_{\text{By lemma: }=\begin{cases}0,& n \ne 1 \\ 1,& n=1 \end{cases}}}\Biggr]
\]
%
  \[ \begin{aligned}
a_n &=\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\biggl[\frac{1}{4}\cos(3x)+\frac{3}{4}\cos(x)\biggr]
                                \cos(nx)\myd x \\
&=\frac{1}{4}\Biggl[\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(3x)\cos(nx)\myd x}_{\text{By lemma: }=\begin{cases}0,& n\ne 3 \\ 1,& n=3 \end{cases}}+3\cdot{\underbrace{\frac{1}{\pi}\int\limits_{-\pi}^{\pi}\cos(x)\cos(nx)\myd x}_{\text{By lemma: }=\begin{cases}0,& n \ne 1 \\ 1,& n=1 \end{cases}}}\Biggr]
\end{aligned}
\]

\end{document}

enter image description here Note the use of \Biggl etc from amsmath instead of dynamic \left and \right. Also the d in dx should by \mathrm not \text.

1
  • dx should probably have a \, in front of it. Looks better
    – daleif
    Oct 26, 2015 at 12:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .