1

The language I use for certain files look much better if there is a small space \, after each inline equation, like this:

\(...\)   % BAD  spacing
\(...\,\) % GOOD spacing

But it's not quite productive to add the \, to every inline math equation. So is there a way to make this a default setting, in the preamble maybe?

0
5

I'm not sure what benefit you get from adding space after each formula.

Anyway, the space should be indeed added after the formula, not before it ends.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\let\)\relax % undefine \)
\DeclareRobustCommand\){%
  \relax
  \ifmmode
    \ifinner
      $\thinspace % add a kern after the formula
    \else
      \@badmath
    \fi
  \else
    \@badmath
  \fi
}
\makeatother

\begin{document}

$a+b$ xyz % for comparison

\(a+b\) xyz

\bigskip

\setlength{\fboxsep}{0pt}% tight to the box

% for comparison
\fbox{\parbox{4.8cm}{This line ends with math $a+b\,$ and text follows}}

\medskip

\fbox{\parbox{4.8cm}{This line ends with math \(a+b\) and text follows}}

\end{document}

The first two lines show that the space is actually added when the \(...\) syntax is added. The two boxes show that if one adds it before closing the formula, the space is not removed at line breaks.

enter image description here

1
  • I'm not a master, but for safety concerns I'm going to go with this method. Thanks!
    – Paul Kim
    Nov 29 '18 at 13:45
1

I cannot see the advantage of such setting. However, maybe this helps

\documentclass{scrartcl}
\renewcommand\){\,$}
\begin{document}

\noindent
$ y=f(x) $x \\
$ y=f(x) $ x \\
\( y=f(x) \)x

\end{document}

enter image description here

2
  • 2
    \) does much more than $.
    – egreg
    Nov 29 '18 at 10:09
  • 1
    sure, which is not important if he/she uses it only for something like above. If not, then he/she can simply overwrite the original definition: \DeclareRobustCommand\){\relax\ifmmode\ifinner\,$\else\@badmath\fi\else \@badmath\fi}
    – user2478
    Nov 29 '18 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.