The following example uses package zref
to remember the size of the math formula in labels. Package mleftright
is used to reduce the additional horizontal spacing by \left
and \right
.
Inside a complex math block, the following macros can be used:
\mzleft{<label>}{<left delimiter>}{<math formula>}
\mzright{<label>}{<math formula>}{<right delimiter>}
The macros can be nested, The <label>
is needed to identify the pairs of delimiters. Inside the math block (math environment, ...) the <label>
names for the pairs must be unique. After the math block \mzreset
can be called. It frees the <label>
names and they can be reused.
Example file:
\documentclass{article}
\usepackage{amsmath}
\usepackage{mleftright}
\usepackage{zref-base}
\makeatletter
\zref@newprop{mzheight}[0pt]{\the\ht\z@}
\zref@newprop{mzdepth}[0pt]{\the\dp\z@}
\newcount\c@@mz
\newcommand*{\the@mz}{mz\the\c@@mz}
\newcommand*{\@mz@list}{}
\let\@mz@do\relax
\newcommand*{\mzreset}{%
\begingroup
\def\@mz@do##1{%
\global\expandafter\let\csname mz@##1\endcsname\relax
}%
\@mz@list
\global\let\@mz@list\@empty
\endgroup
}
\newcommand*{\mzleft}[3]{%
\@ifundefined{mz@#1}{%
\global\advance\c@@mz\@ne
\expandafter\xdef\csname mz@#1\endcsname{\the@mz}%
\xdef\@mz@list{\@mz@list\@mz@do{#1}}%
}{}%
\expandafter\let\expandafter\@mz\csname mz@#1\endcsname
\mleft#2%
\expandafter\mathpalette\expandafter{%
\expandafter\@mzleft\expandafter{\@mz}%
}{#3}%
\mright.\kern-\nulldelimiterspace
}
\newcommand*{\mzright}[3]{%
\kern-\nulldelimiterspace
\@ifundefined{mz@#1}{%
\@latex@warning{Missing \string\mzleft{#1}}%
\mleft.#2\mright#3%
}{%
\expandafter\let\expandafter\@mz\csname mz@#1\endcsname
\mleft.%
\expandafter\mathpalette\expandafter{%
\expandafter\@mzright\expandafter{\@mz}%
}{#2}%
\mright#3%
}%
}
\newcommand*{\@mzleft}{%
\@mzleftright lr%
}
\newcommand*{\@mzright}{%
\@mzleftright rl%
}
\newcommand*{\@mzleftright}[5]{%
\sbox0{$\m@th#4{}#5{}$}%
\ifmeasuring@
\else
\begingroup
\let\@auxout\@mainaux
\zref@labelbyprops{#3#1}{mzheight,mzdepth}%
\endgroup
\fi
\zifrefundefined{\@mz #2}{%
}{%
\dimen@=\zref@extract{#3#2}{mzheight}\relax
\ifdim\dimen@>\ht0 %
\ht0=\dimen@
\fi
\dimen@=\zref@extract{#3#2}{mzdepth}\relax
\ifdim\dimen@>\dp0 %
\dp0=\dimen@
\fi
}%
\copy0\relax
}
\makeatother
\begin{document}
\begin{align*}
\begin{split}
z = \mzleft{a}({ a + b + c +} \\
\mzright{a}{{}+ \frac{d}{e}})
\end{split}
\end{align*}
\mzreset
\begin{align*}
\begin{split}
z = \mzleft{a}{[}{%
a + b + \frac{c}{d} +
\mzleft{b}{(}{
\int_0^\infty \mathrm{d}x
}
} \\
\mzright{b}{
+ y}{)
}
\mzright{a}{
+ \frac{\displaystyle\sum_{i=0}^{100}i}{e}
}{]}
\end{split}
\end{align*}
\end{document}
![Result](https://i.stack.imgur.com/1lU8A.png)
Under the normal setting, the math code for comma is "613B
as it results from
\mathcode`\,="613B
in Plain TeX and
\DeclareMathSymbol{,}{\mathpunct}{letters}{"3B}
in LaTeX (precisely in fontmath.ltx
). This means that the comma is a punctuation symbol (class 6), and that it's taken from the font specialized for math letters (family 1, where the math italic letters are the main object).
The glyph's shape therefore depends on how the fonts are designed: there may be a difference, particularly if the text and math font don't match (which would be a typographical error anyway). Why is the symbol “different”? Let's look with the standard setting:
\documentclass{article}
\begin{document}
\fboxsep=0pt \fboxrule=0.1pt % no padding, hairline box
\fbox{,} \fbox{$,$}
\makebox[0pt][l]{\fbox{,}}\fbox{$,$}
\end{document}
![enter image description here](https://i.stack.imgur.com/qrMQ9.png)
Looking at the first line seems to hint that the result is identica, which is confirmed by the second line.
However, a difference can be seen if NewTX is loaded; the same input as before, with the addition of \usepackage{newtxtext,newtxmath}
produces
![enter image description here](https://i.stack.imgur.com/bpbdE.png)
where we see that the math comma has no left sidebearing. Design decision.
Best Answer
This is unrelated to tables. You are using inline textstyle math designed to fit in a normal height line. fractions use a smaller font just as superscripts do. The W is smaller just as the second 2 is smaller in 2+½ . You can use \dfrac instead of\frac to get display fractions.