this is my first question in this website. I have to say that it is being very useful for me to visit this site to learn how LaTeX works, so congratulations.

So, the question is, how can I do this? I would like the solution not in tikz because I have never used it. I'm looking for something like a macro or similar. This has to be in equation environment. joining underbrace



3 Answers 3


Based on my answer at How to link two terms in math mode, use


where each term is taken in math mode, including the undertext. The parameters \rldp, \rlht, \rlwd, and \rlbr can be altered to affect the appearance.

\rldp is the depth of the primary horizontal underbar

\rlht is the height of the vertical struts, both above and below the primary horizontal underbar.

\rlwd is the width (thickness) of the rule

\rlbr is the height of the secondary vertical rules, which gird the actual math terms.

\newcommand\ubar[4]{\uvbarR{#1} \uvbar{#2}{#4} \uvbarL{#3}}
$\ubar{ax}{+ by +}{cz}{h} =d$

enter image description here

As egreg suggests, thinning out the lines through the use of \rlwd may be desirable. Here it is with \rlwd set to 0.4pt.

enter image description here

  • Nice, but the lines are definitely too thick.
    – egreg
    Commented Apr 24, 2015 at 16:27
  • @egreg That's why \rlwd is a settable parameter. Perhaps I'll change it. Commented Apr 24, 2015 at 21:15

Here is an option using \underbrace:

enter image description here

  \underbrace{\mathstrut zabc}{} + defg + \underbrace{\mathstrut hijklm} &= n \\[-4\jot]
  \settowidth{\lwidth}{zabc}% Left \underbrace width
  \settowidth{\rwidth}{hijklm}% Right \underbrace width
  \underbrace{\hspace{.6\lwidth} \phantom{{} + defg + {}}\hspace{.6\rwidth}}_{opqr}
  \hspace{.4\rwidth}% Due to right-alignment in align
  \mkern 6mu% Adjustment for missing =

The left and right underbrace content length is stored in \lwidth and \rwidth and used for spacing purposes within the lower \underbrace. Minor adjustments are required here and there to position things.

\mathstrut forces math content without descenders to have the same depth.


Not perfectly but close to:



            &\underbracket{ax} +  by + \underbracket{cz} = d \\[-14pt]
            \underbracket{\hphantom{a+ by+ c}}


Good luck

enter image description here

You must log in to answer this question.

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