3

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.

Jorge Leitao
  • 19,085
  • 19
  • 85
  • 121
eudoxos
  • 18,545
  • 10
  • 61
  • 110

3 Answers3

2

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

Peter Krautzberger
  • 5,145
  • 19
  • 31
  • I need to refer to the equation number via `:ref:` in the main text, and sphinx knows nothing about `\label` inside mathjax. I edited the question to clarify this. – eudoxos Jul 21 '14 at 20:52
  • Ah, ok. I'm not a sphinx expert. FWIW, TeX and MathJax expect similar things, i.e. `\ref` to generate references. – Peter Krautzberger Jul 21 '14 at 20:57
2

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.

equaeghe
  • 1,644
  • 18
  • 37
1

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.

bp91
  • 31
  • 2