7

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

Thanks!

kuvala
  • 73

3 Answers3

7

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

\ubar{left}{middle}{right}{undertext}

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.

\documentclass{article}
\usepackage{stackengine}
\stackMath
\def\rldp{1.4ex}
\def\rlht{.8ex}
\def\rlwd{.8pt}
\def\rlbr{2pt}
\setstackgap{L}{\rldp}
\def\uvbarR#1{%
  \def\stackalignment{r}\def\stacktype{S}\stackunder[-\rlwd]{%
    \def\stackalignment{c}\def\stacktype{L}\stackunder{\ubr{#1}}{\rule{\rlwd}{\rlht}}%
  }{\setbox0\hbox{$#1$}\rule{.5\wd0}{\rlwd}}%
}
\def\uvbarL#1{%
  \def\stackalignment{l}\def\stacktype{S}\stackunder[-\rlwd]{%
    \def\stackalignment{c}\def\stacktype{L}\stackunder{\ubr{#1}}{\rule{\rlwd}{\rlht}}%
  }{\setbox0\hbox{$#1$}\rule{.5\wd0}{\rlwd}}%
}
\def\uvbar#1#2{%
  \def\stacktype{S}\def\stackalignment{c}\def\useanchorwidth{T}\stackunder[0pt]{%
    \def\stacktype{L}\setbox0\hbox{${}#1{}$}%
    \stackunder[\rldp]{{}#1{}}{\rule{\wd0}{\rlwd}}%
  }{\def\stacktype{S}\stackunder[1pt]{\rule{\rlwd}{\rlht}}{\scriptscriptstyle#2}}%
}
\def\ubr#1{\setbox2=\hbox{$#1$}\stackunder[\dimexpr\rldp-\rlht\relax]{#1}{%
  \llap{\rule{\rlwd}{\rlbr}}\rule{\wd2}{\rlwd}\rlap{\rule{\rlwd}{\rlbr}}}}
\newcommand\ubar[4]{\uvbarR{#1} \uvbar{#2}{#4} \uvbarL{#3}}
\begin{document}
$\ubar{ax}{+ by +}{cz}{h} =d$
\end{document}

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

3

Here is an option using \underbrace:

enter image description here

\documentclass{article}
\usepackage{amsmath}
\newlength{\lwidth}
\newlength{\rwidth}
\begin{document}
\begin{align*}
  \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 =
\end{align*}
\end{document}

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.

Werner
  • 603,163
0

Not perfectly but close to:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

    \begin{equation*}
        \begin{aligned}
            &\underbracket{ax} +  by + \underbracket{cz} = d \\[-14pt]
            &\hphantom{a\!}%
            \underbracket{\hphantom{a+ by+ c}}
        \end{aligned} 
    \end{equation*}

\end{document}

Good luck

enter image description here

Jan-Bert
  • 525