[Tex/LaTex] Universal Parentheses

brackets

I know it's a bit of an odd request but it is one to which the solution would save me a lot of time.

I write a lot of documents in LaTex (especially maths – no surprise) and I prefer the look of

$\left(\right)$

parentheses on a lot of things because they actually encompass the things inside. For example:

$\deg\left(m_{\alpha_{1}/K}\right)$

looks better than

$\deg(m_{\alpha_{1}/K})$

in my opinion.

Unfortunately, writing \left and \right every time is a bit tiresome.

Is there any way that I can make them all do it automatically? There is a solution here: automatic size adjustment for nested parentheses but it interferes with tikz (presumably because it affects the parentheses).

I tried a solution like

$\newcommand{\(}{\left(}$

but LaTeX didn't like that.

Best Answer

Making ( active is not really a solution because it is used in so many other ways, but here is how it would be done.

To help in this regard. I create \pactive to make ( active which, if used inside a group like an equation, can revert ( to its normal definition after the group is closed.

\documentclass{article}
\let\svlp(
\catcode`(=\active %
\def(#1){\left\svlp#1\right)}
\catcode`(=12 %
\newcommand\pactive{\catcode`(=\active }
\begin{document}
\[
\pactive
\deg(m_{\alpha_{1}/K}) + (\frac{a}{x+c})
\]
Normal use of ( or even \fbox{\makebox(20,30){test}}
\end{document}

enter image description here

The OP asks about automating the invocation of \pactive. Again, I don't recommend it, because there may be need in math mode to use the () set as an argument to some macro. But the use of

\everymath{\pactive}
\everydisplay{\pactive}

will accomplish it:

\documentclass{article}
\let\svlp(
\catcode`(=\active %
\def(#1){\left\svlp#1\right)}
\catcode`(=12 %
\newcommand\pactive{\catcode`(=\active }
\everymath{\pactive}
\everydisplay{\pactive}
\begin{document}
\[
%\pactive
\deg(m_{\alpha_{1}/K}) + (\frac{a}{x+c})
\]
Normal use of ( or even \fbox{\makebox(20,30){test}}

\(
%\pactive
\deg(m_{\alpha_{1}/K}) + (\frac{a}{x+c})
\)
Normal use of ( or even \fbox{\makebox(20,30){test}}
\end{document}

enter image description here

Thanks to Timm for reminding that, if one really wants to automate this, then one should have handy the override macro

\newcommand\pinactive{\catcode`(=12 }
Related Question