Is it possible to avoid breaking a line of math over a linebreak?

For instance, with margins and font I’m using, this code produces the following.
#lorem(12) $forall a in (A sect B)$ #lorem(12)

But I want the $forall a in (A sect B)$ to appear on a single line. Is there a way to ensure this?

You can do this be putting the it inside a box, i.e.

#lorem(12) #box($forall a in (A sect B)$) #lorem(12)

If you want this behaviour for all inline equations, you can do the following:

#show math.equation.where(block: false): box

In this case all such equations would automatically be wrapped by a box.

2 Likes

Amazing!! Thank you!!!

Hi @Monkey,

I’m glad @ludwig’s solution was helpful to you :slightly_smiling_face:

For the benefit of other users of the forum, please consider moving the question to the Questions category (this can be done by editing the question) and marking @ludwig’s answer as the solution (there is ‘🗹 Solution’ button below every reply).

2 Likes

I would like to note that you should wrap code in `` (for inline code) or in code block fences to improve readability and add a button (for a code block only) to be able to quickly copy any code snippet.

A quote from How to post in the Questions category :

2 Likes

I have tried this solution, however it has an unexpected behaviour:

Before:

After (using the solution provided by @ludwig ):

So the box changes the alignement of the equation within text. Is this expected?