On 20131027, Ксения Лукашевичус wrote:
> I have some questions about equatuons:
> 1) I want to get from rst source latex code like this: How can I do this?
> Would it be ok just to use two math:: directives each with :label: option?
The answer depends on whether you are using Sphinx with a "math"
extension or the "math" directive provided by Docutils.
The follwing all holds for Docutils (and Sphinx without using any math extension, i.e. using the
Docutils math directive).
There is no :label: option. You can specify a label with :name:, but
currently equation numbering is not supported.
http://docutils.sourceforge.net/docs/ref/rst/directives.html#math
> The question is on alignment.
There is no alignment between separate "math" directives.
Empty lines in the content of a "math" directive start a new "equation*"
environment. For aligned equations, Docutils uses align* if a linebreak
(\\) is detected outside of an envinronment (like "matrix").
I.e.
.. math::
m_1\ddot{x}_1+(k_1+k_2)x_1k_2x_2 & = & u_1, \label{spmass1}\\
m_2\ddot{x}_2k_2x_1+(k_1+k_2)x_2 & = & u_2 . \label{spmass2}
becomes
\begin{align*}
m_1\ddot{x}_1+(k_1+k_2)x_1k_2x_2 & = & u_1, \label{spmass1}\\
m_2\ddot{x}_2k_2x_1+(k_1+k_2)x_2 & = & u_2 . \label{spmass2}
\end{align*}
This works in LaTeX if you remove the stars and fails in HTML because of the
\label.
> 2) Is it possible to get labels for equations like these:
You can try
.. math::
:name: ctds1
\dot{x}(t) = f(t, x, u),
.. math::
x(t+1) = f(t, x, u),
\tag*{(\ref{ctds1}d)}
\label{dtds1}
> I mean I want labels to look like (1) and (1d), for example.
Again, you need to remove the *s in the environment names in the latex
output.
> 3) What about referencing equation from another file (chapter)? Is it
> possible?
In docutils, referencing by number is not supported (how could it when
equation numbering is usupported). You can use (at your own risk) raw LaTeX
or a derived role. As raw is not controlled by Docutils, there is no limit
regarding the file but also no support whatsoever. You need to make sure
that LaTeX finds the reference.
Günter
