Hi Stefan.

AFAIK, this is not possible with Sphinx's :label: option, because this
always applies to the whole equation, even if it has multiple lines.

You might be able to split your multiple lines into separate "math"
directives, but I guess then it'll be hard to get the vertical
alignment right.

But if you are willing to use MathJax's labelling mechanism, it should
work like this:

.. math::
      :nowrap:

      \begin{align}
         2x^2 + 3(x-1)(x-2)   & = 2x^2 + 3(x^2-3x+2) \\ \nonumber
                              & = 2x^2 + 3x^2 - 9x + 6 \\
                              & = 5x^2 - 9x + 6
        \label{testpdf}
      \end{align}


In addition, you'll need to activate the MathJax labelling:

mathjax_config = {
    'TeX': {'equationNumbers': {'autoNumber': 'AMS', 'useLabelIds': True}},
}

Also, the referencing with :eq: will not work anymore, instead you'll
have to use :math:`\ref{testpdf}`.

The big disadvantage of the whole thing is that MathJax references
only work within the same page.
And they don't take the section number into account. At least by
default, there might be a setting to fix this ...?

cheers,
Matthias

On Fri, Apr 24, 2020 at 4:50 PM sbiser <stefan.sb.bi...@gmail.com> wrote:
>
> Hey together,
>
> I'm working on some code documentation which I need both as HTML as well as 
> PDF. Is there any way to achieve the following graphical output not
> only as PDF but as HTML as well?
>
> For latex output I've used the following code:
>
> .. math::
>       :label: testpdf
>       :nowrap:
>
>       \begin{align}
>          2x^2 + 3(x-1)(x-2)   & = 2x^2 + 3(x^2-3x+2) \\ \nonumber
>                               & = 2x^2 + 3x^2 - 9x + 6 \\
>                               & = 5x^2 - 9x + 6
>       \end{align}
>
> But I couldn't manage to get the same rendering in HTML (either only one 
> label number, or no at all...)
>
> Thanks for any suggestions.
>
> Stefan
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sphinx-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sphinx-users/e1f8f0ac-0d30-4e45-a342-d332499a4370%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sphinx-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sphinx-users/CAFesC-d%3D%3Dqr2RQAwxd%2Ba43BriKvCrLLB9QnD1AaZoeqQuZTEgA%40mail.gmail.com.

Reply via email to