aligned equations with mathjax, and with equation numbers

2.8k Views Asked by At

I would like to write a series of numbered equations aligned at the equality sign. Like the usual .. math:: with multiple equations, but wrapped in \begin{align} ... \end{align} rather than \begin{equation} ... \end{equation}. Is there a way to do that with sphinx? Or perhaps an extension?

EDIT: I need equation numbers so that I can refer to those from the main text using the :ref: role.

3

There are 3 best solutions below

2
On

Use :nowrap: to allow you to provide your own wrapping and :label: to crerate a label, which you can reference using :eq:. For example:

So we arrive at the important equations

.. math::
   :label: important
   :nowrap:

   \begin{align}
     ...
   \end{align}

This set of equations :eq:`important` gives rise to...

For my source and more details, see the Sphinx documentation.

0
On

It is an old issue but the solution working for me is not described here and difficult to find on the web. It simply consists in line-break inside math instruction :

.. math::
   :label: important

   F_{x} &=\int_{S} \sigma_{x x} d S 
   & 
   M_{x} &=\int_{S}\left(y \sigma_{x z}-z \sigma_{x y}\right) d S  
   
   F_{y} &=\int_{S} \sigma_{x y} d S  
   &
   M_{y} &=\int_{S} z \sigma_{x x} d S  
   
   F_{z} &=\int_{S} \sigma_{x z} d S 
   & 
   M_{z} &=-\int_{S} y \sigma_{x x} d S 

With this line-break, Sphinx would use the align environment of Latex instead of equation+split. It works for both html and latex output.

2
On

You can use \label and \tag to manually add equation labels; this works in both MathJax and LaTeX (for pdf output).

E.g.,

\[ \bigcap \emptyset = \{ x : x = x\} \label{test} \tag{an equation} \]

For a live example, see http://codepen.io/pkra/pen/hyktl