2

Regarding the dcases environment, I noticed that, even if now I have all the math symbols extended (for example frac), when using derivatives the bracket doesn't actually cover completely the space needed from the math symbols.

Let's take the following example

enter image description here

given by the code

\[
    \begin{dcases}
        \frac{\partial U}{\partial l}\mathrm{d} l = 
        (\mathrm{d} U)_{\theta=\text{cost}} = \nabla U \cdot\mathrm{d}\boldsymbol{l} = 
        -\nabla(\boldsymbol{E}_0 \cdot\boldsymbol{p})\cdot\mathrm{d}\boldsymbol{l}\\
        \\
        \frac{\partial U}{\partial \theta}\mathrm{d}\theta = 
        \frac{\partial}{\partial\theta}(-E_0p\cos\theta)\mathrm{d}\theta = 
        E_0p\sin\theta\mathrm{d}\theta =
        \boldsymbol{E}_0\times\boldsymbol{p}\cdot\mathrm{d}\boldsymbol{\theta}
    \end{dcases}
\]

As you can notice - if you don't, look at the next image - the derivatives escape the brace, even if for a microscopic portion.

enter image description here

Now, I understand it sounds like I'm a maniac, but this thing break the harmony of my LaTeX, so I'm desperately looking for a solution. I thought that it would be very nice if there were some options to the dcases environment to stretch a little bit more the cases, but if there're not such "facilities" how could it be solved?

  • 1
    That's normal and nothing to worry about. – egreg Jul 19 '17 at 17:40
1

I agree with egreg that it is nothing to worry about, but one could (and I did below) add a "strut" to the \partial U in the top equation and to the \partial \theta in the bottom equation. As barbara notes, if the strut is a mere \strut, it may introduce a little unwanted vertical spacing, and so I define \htstrut to mask the depth and use it or \strut accordingly.

\documentclass{article}
\usepackage{mathtools,tabstackengine}
\newcommand\htstrut{\setbox0=\hbox{\strut}\dp0=0pt}
\begin{document}
\[
    \begin{dcases}
        \frac{\partial U\htstrut}{\partial l}\mathrm{d} l = 
        (\mathrm{d} U)_{\theta=\text{cost}} = \nabla U \cdot\mathrm{d}\boldsymbol{l} = 
        -\nabla(\boldsymbol{E}_0 \cdot\boldsymbol{p})\cdot\mathrm{d}\boldsymbol{l}\\
        \\
        \frac{\partial U}{\partial \theta\strut}\mathrm{d}\theta = 
        \frac{\partial}{\partial\theta}(-E_0p\cos\theta)\mathrm{d}\theta = 
        E_0p\sin\theta\mathrm{d}\theta =
        \boldsymbol{E}_0\times\boldsymbol{p}\cdot\mathrm{d}\boldsymbol{\theta}
    \end{dcases}
\]
\end{document}

enter image description here

Alternately, one could change the dcases to an aligned, place the data in the 2nd field of the aligned, then \addstackgap[<length>] to the aligned, and apply a \left\{. In this case, no \strut is required.

\documentclass{article}
\usepackage{mathtools,stackengine}
\stackMath
\begin{document}
\[
    \left\{\addstackgap[4pt]{\begin{aligned}
        &\frac{\partial U}{\partial l}\mathrm{d} l = 
        (\mathrm{d} U)_{\theta=\text{cost}} = \nabla U \cdot\mathrm{d}\boldsymbol{l} = 
        -\nabla(\boldsymbol{E}_0 \cdot\boldsymbol{p})\cdot\mathrm{d}\boldsymbol{l}\\
        \\
        &\frac{\partial U}{\partial \theta}\mathrm{d}\theta = 
        \frac{\partial}{\partial\theta}(-E_0p\cos\theta)\mathrm{d}\theta = 
        E_0p\sin\theta\mathrm{d}\theta =
        \boldsymbol{E}_0\times\boldsymbol{p}\cdot\mathrm{d}\boldsymbol{\theta}
    \end{aligned}}\right.
\]
\end{document}

enter image description here

Above, I added a 4pt gap above and below the aligned environment. If I had chosen 8pt, for example, it would have looked like this:

enter image description here

| improve this answer | |
  • What's that \strut? What is for, and how did it fix the problem? – GiuTeX Jul 19 '17 at 17:48
  • 1
    @opisthofulax A \strut is a zero-width thingie of finite total height equal to \baselineskip. The height and depth of the \strut (above and below the baseline) is determined by the font itself, such that all glyphs of the font will always fall within the vertical footprint of the \strut. Thus, the \strut will protrude higher than the U and lower than the \theta. p.s. I added a 2nd solution. – Steven B. Segletes Jul 19 '17 at 17:52
  • 1
    in your first paragraph, you really meant that, at the bottom, you added a \strut to \partial\theta instead of to \partial U. however, do check the distance between the numerators of the initial fractions to make sure the distance between numerator and fraction line is exactly the same in both lines; i think there may be a slight increase in that space in the first line. – barbara beeton Jul 19 '17 at 21:19
  • @barbarabeeton Thank you for noting that. I have edited to use \htstrut if needed. – Steven B. Segletes Jul 20 '17 at 9:43
3

You simply can use the empheq environment to do that. Needless to load amsmath since the former loads mathtools, which loads amsmath.

I also improved the spacing of you differentail symbol, defining a \dd command; and simplified the typing of partial differentials with the esdiff package.

\documentclass{article}
\usepackage{empheq, esdiff}

\newcommand*{\dd}{\mathop{\kern0pt\mathrm{d}}\mkern-2mu{}}


\begin{document}

\begin{empheq}[left=\empheqlbrace]{align*}
     & \diffp{U}{l}\dd l =
    (\dd U)_{\theta=\text{cost}} = \nabla U \cdot\dd \boldsymbol{l} =
    -\nabla(\boldsymbol{E}_0 \cdot\boldsymbol{p})\cdot\dd\boldsymbol{l}\\
    \\
    & \diffp{U}{\theta}\dd\theta =
    \diffp{}{\theta}(-E_0p\cos\theta)\dd\theta =
    E_0p\sin\theta\dd\theta =
    \boldsymbol{E}_0\times\boldsymbol{p}\cdot\dd\boldsymbol{\theta}
\end{empheq}

\end{document} 

enter image description here

| improve this answer | |
  • in your second sentence, you probably want to change "it" to "empheq" since "it" makes it sound like amsmath loads mathtools, which loads ... – barbara beeton Jul 20 '17 at 13:44
  • @barbarabeeton. You're right, it's ambiguous. I guess I wrote it this way because I don't like too many repetitions. – Bernard Jul 20 '17 at 13:53

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.