# How to link two terms in math mode

I am trying to get something like this:

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.

-
I think this might confuse the reader. Maybe writing a⋅b⋅c⋅d = \underbrace{a⋅c}_{=3}⋅b⋅d = 1 is an option. Balancing verbosity against comprehensibility is not easy ;-) – canaaerus Feb 20 '14 at 12:25
Honestly, if I read that in a paper, I wouldn't understand a.c = 3, I would understand a.b.c = 3. – Najib Idrissi Feb 21 '14 at 8:38
@nik, You are right. The answers are ok in that regard. – Vahid Feb 22 '14 at 8:50
I wouldn't use a square center dot as an operator. It's too subtle a difference. Except if it's just the look of the center dot in your font. Then it's still questionable in my mind but it becomes a matter of taste, not of readability ;) – Christian Feb 23 '14 at 12:47

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}


-
Thank you very much. I should read the manual of your package to see what's done here. – Vahid Feb 22 '14 at 8:59
@Vahid, Perhaps I'll edit my answer to incorporate my earlier comments, by way of explanation. – Steven B. Segletes Feb 22 '14 at 14:27
Thank you very much. – Vahid Feb 23 '14 at 19:37

With a little TikZ and xparse I defined the macro \linkterms which is used as follows

\linkterms[pin length]{left term}[middle term]{right term}{term underneath}


where the arguments enclosed in [] are optional and can be left out.

# Example

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{tikz,xparse}
\NewDocumentCommand{\linkterms}{ O{1ex} m O{} m m }{
\tikz[remember picture,baseline=(A.base)]{\node[inner xsep=0pt] (A) {$#2$};}
#3
\tikz[remember picture,baseline=(C.base)]{\node[inner xsep=0pt] (C) {$#4$};}
\tikz[remember picture,overlay]{
\draw (A.south) -- ([yshift=-#1]A.south) -- coordinate (Z) ([yshift=-#1]C.south) -- (C.south);
\draw (Z) -- +(0,-#1) node[below] {$#5$};
}
}
\begin{document}
\noindent
$\linkterms{a}[\cdot b \cdot]{c}{a \cdot c = 3} \cdot d = 1$ \\[1cm]
$\linkterms{a}{c}{a \cdot c = 3} \cdot d = 1$ \\[1cm]
$\linkterms[1mm]{a}[\cdot b \cdot]{c}{a \cdot c = 3} \cdot d = 1$
\end{document}


# Output

-
Thanks for your contribution :) But I am afraid that is not implemented as a command. That would be better. – Vahid Feb 22 '14 at 8:52

A low-weight method using the picture environment.

\documentclass{article}
\usepackage{picture}% great package to use dimensions in picture environment

\makeatletter

% #1=left term, #2=middle term, #3=right term
% #4=stuff to be put underneath
\sbox{\linkboxleft}{\m@th$#1$}%
\sbox{\linkboxright}{\m@th$#3$}%
\sbox{\linkboxall}{\m@th$#1#2#3$}%
\sbox{\linkboxunder}{$#4$}%
\raisebox{-\height}
\linethickness{.2ex}
\end{picture}}
}%

\makeatother

\begin{document}\thispagestyle{empty}

$\linktwoterms{a}{\cdot b \cdot}{c}{\scriptstyle (a\cdot c = 3)}\cdot d = 1$

% aahuiauhdaihda for testing depth above.

\end{document}


-
Thanks! It is also what I was looking for. – Vahid Feb 22 '14 at 9:02

The syntax is

\linkterms{left}[optional middle]{right}{underset}


Run it with xelatex:

\documentclass{article}
\usepackage{pst-node}
\parindent=0pt
\makeatletter
$\linkterms{a}[\cdot b \cdot]{c}{a \cdot c = 3} \cdot d = 1$ \\[1cm]
$\linkterms{a}{c}{a \cdot c = 3} \cdot d = 1$ \\[1cm]
$\linkterms{a}[\cdot b\cdot d\cdot e\cdot f\cdot]{g}{a\cdot g=3} \cdot h = 1$