# Add spacing at the end of inline mathmode $$...$$

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?

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. • I'm not a master, but for safety concerns I'm going to go with this method. Thanks! Nov 29 '18 at 13:45 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}


• \) does much more than $. Nov 29 '18 at 10:09 • 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