[Tex/LaTex] How to link two terms in math mode

math-mode

I am trying to get something like this:

enter image description here

which is different from \underbrace or \underbracket. It says that a.c=3. Is there already a command for that? I have not found it. Or should one define it? If yes, can someone help me how to define it?

Thanks.

Best Answer

Done here with stacks. I added a descender to the mix, to make sure that the under-strut did not interfere. The strut/rule parameters are adjustable. \rldp is the vertical underset of the horizontal bar, \rlht are the heights of the vertical struts, and \rlwd is the rule thickness.

Since the answer was accepted, I am EDITING it to provide a fuller explanation of what is done here. As to how the syntax of the stacking commands works, obviously reading the manual would be best. But short of that, in a nutshell, alignments are r right, c center, and l left (the default is c). An S or short stack places two items vertically with a specified gap between the items, whereas a L long stack places two items vertically with a specified distance between the baselines of the two items. The optional argument to \stackunder is that stacking gap (short or long, depending on type). When stacks are nested (\stackunder{...\stackunder{}{}...}{}), it is easiest to work from the inside out in trying to decipher it.

For example, in \uvbarR, which creates the left side of the object, the inner \stackunder places the centrally aligned vertical rule under the leading letter, the bottom of which is placed a distance \rldp below the baseline of that letter (a long stack). The outer \stackunder takes that stacked object, and places the right-aligned chunk of horizontal rule under it, the rule being only 1/2 the letter width. It places it with a negative vertical gap (overlap) of the rule width (short stack), so that finite rule-width lines lay flush.

The other, perhaps, non-obvious facet of the solution is \setbox0\hbox{${}#1{}$} which was used to typeset the central portion (2nd argument of \ubar) into a non-printed box. I did this only so that I could measure that box width (\wd0) so that I knew how long to make the horizontal underbar. The {} on either side of the argument (${}#1{}$) says to math mode to typeset the leading and trailing \cdots of the 2nd argument as if they have something else to their left and to their right (which of course, they do).

EDITED to allow for label content to be wider than spread of under-bracket.

\documentclass{article}
\usepackage{stackengine}
\stackMath
\def\rldp{1.3ex}
\def\rlht{.8ex}
\def\rlwd{.8pt}
\setstackgap{L}{\rldp}
\def\uvbarR#1{%
  \def\stackalignment{r}\def\stacktype{S}\stackunder[-\rlwd]{%
    \def\stackalignment{c}\def\stacktype{L}\stackunder{#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{#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}}%
}
\newcommand\ubar[4]{\uvbarR{#1} \uvbar{#2}{#4} \uvbarL{#3}}
\begin{document}
$\ubar{a}{\cdot b\cdot d\cdot e\cdot f\cdot}{g}{a\cdot g=3} \cdot h = 1$
\end{document}

enter image description here