Gaurang Tandon
Gaurang Tandon

Reputation: 6753

How to align separated equations in MathJax?

As an example, consider this .md file, with the $$ signs processed as MathJax:

This is the first equation  
$$1 + 1 = 2$$
This is the second equation  
$$10 + 10 = 20$$
This is the third equation  
$$100 + 100 = 200$$

If all the three equations were within a single $$ pair, I would've used \begin{align}...\end{align} as I always do. But, I cannot do so here. I need all the three equations to be aligned along the = signs, but the textual descriptions interrupt the flow of the equations. The textual descriptions cannot be removed, and must be positioned where they are.

So, my question is, how to align all the three equations along the = signs?

Upvotes: 1

Views: 413

Answers (1)

Davide Cervone
Davide Cervone

Reputation: 12250

You can use \phantom to equalize the content in the three equations so that they line up, as in the following:

<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/latest.js?config=TeX-AMS_CHTML"></script>

This is the first equation  
$$\phantom{00}1 + 1 = 2$$
This is the second equation  
$$\phantom{0}10 + 10 = 20$$
This is the third equation  
$$100 + 100 = 200$$

but that takes careful analysis of the formulas, and for more complicated ones, it may not be a viable approach. But it works for these specific equations pretty easily.

As peter says, there is no general way to do this at the moment.

Upvotes: 1

Related Questions