I tried all answers in Spacing around \left and \right and none of them work.
I use code generate by computer CAS. And all the code generates \left(...\right). So not possible to do any manual editing of latex code generated.
Only issue is that something like f\left(x\right) adds extra space between function name f and the parentheses. I am not talking about any space inside parentheses, but the space outside between function name and starting (.
I only want this space to be the same as if code was written using f(x). Nothing else change.
First, here is MWE showing the issue
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Compiled with lualatex gives
Notice how the space after function name is larger when using \left(...\right) which is the second equation.
I'd like the space after function names and starting ( in the second equation to be same as first equation as it looks better.
Below are all my tries. Some of them fix the space after g and not after f and some solution fix the space after f but not after g.
But there is no solution which produce same exact output for second equation as the first one.
Try 1 (accepted answer in the above link)
\documentclass[12pt]{article}
\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
Notice the space after g in second equation have become too small.
Try 2
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\usepackage{mathtools}
\DeclarePairedDelimiter\pars{\lparen}{\rparen}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
No effect. Larger space after function names still exist.
Try 3
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\let\originalleft\left
\let\originalright\right
\def\left#1{\mathopen{}\originalleft#1}
\def\right#1{\originalright#1\mathclose{}}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
Again, now space after g is too small.
Try 4
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\Umathopinnerspacing\displaystyle=0mu
\Umathopinnerspacing\textstyle=0mu
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
Still, the space between function names and ( is not same in second equation as first equation.
try 5
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\def\delim#1#2#3{
\mathopen{\left#1 \vphantom{#2} \right.}
\kern-\nulldelimiterspace #2 \kern-\nulldelimiterspace
\mathclose{ \left. \vphantom{#2} \right#3 }
}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
Still, the space between function names and ( is not same in second equation as first equation.
Try 6
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{kpfonts,baskervald}
\usepackage{amsmath}
\usepackage{mleftright}
\renewcommand{\left}{\mleft}
\renewcommand{\right}{\mright}
\begin{document}
\begin{align*}
\int \frac{dy}{g(y)} &= \int f(x) \, dx\\
\int \frac{dy}{g\left(y\right)} &= \int f\left(x\right) \, dx
\end{align*}
\end{document}
Gives
The space after f looks same as in equation 1, but the space after g in second equation is now too small.








\left(x\right)? Put differently, why aren't you writing(x)?