math add tag
CarLaTeX
Inline math formulae in a justified paragraph are stretched.

How to avoid it for any formula in the paragraph?

```
\documentclass{article}
\usepackage{ragged2e}

\begin{document}
\justifying
Some text with a justified formula
$a+b+c=d$. How don't\linebreak stretch it?

I thought to put it in a box
\makebox{$a+b+c=d$}, but it is not\linebreak
a general solution.
\end{document}
```

![image.png](/image?hash=0be35e1d289c5ac65a3128acab8f2cab8cea0cdc567e6945a0d50e560d965ddf)
Top Answer
Skillmon
The following changes the definitions of `\(` and `\)` to always put braces around the complete expression. Pay attention to [@barbara beeton's comment](https://topanswers.xyz/transcript?room=2048&id=138627#c138627), this might not always look good. Also line breaking of inline maths doesn't work this way.

You still get the default behaviour if you use `$...$` for inline maths.

```
\documentclass{article}
\usepackage{ragged2e}

\AddToHook{cmd/(/after}{\bgroup}
\AddToHook{cmd/)/before}{\egroup}

\begin{document}
\justifying
Some text with a justified formula
\(a+b+c=d\). How don't\linebreak stretch it?

Some text with a justified formula
$a+b+c=d$. How don't\linebreak stretch it?

I thought to put it in a box
\makebox{$a+b+c=d$}, but it is not\linebreak
a general solution.
\end{document}
```

![nomathstretch.png](/image?hash=fba76a0eac0edc8e42d92a40c96086091826cce8b8a5c02f00ff9f5168991344)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.