Re: implementing a ``mathmacro`` substitution directive?

Guenter Milde <[email protected]>
Newsgroups gmane.text.docutils.user
Message-ID <[email protected]>
Hi Pierre,

On 2014-09-09, Pierre wrote:

> I am struggling to write a documentation with a lot of math. It would be
> very convenient to implement a ``mathmacro`` substitution directive which
> should work like this:

> - Definition::

>   .. |bnabla| mathmacro:: \boldsymbol{\nabla}
>   .. |vv| mathmacro:: \textbf{v}

> - These math macros could be included directly in text as in::

>     |bnabla| is the nabla operator,

>   which should produce an inline equation like this 
>   ":math:`\boldsymbol{\nabla}` is the nabla operator".

> - These macros could also be included in inline equations like this::

>     This is an inline equation :math:`|vv| = |bnabla|f`, 

>   which should give :math:`\textbf{v} = \boldsymbol{\nabla}f`.

> - They could also be included in block equation::

>     .. math:: |vv| = |bnabla|f

>   which should give

>   .. math:: \textbf{v} = \boldsymbol{\nabla}f.

> Would it be possible to do that?

This would be a very big change, because the markup-language of the
math-directive/role content is LaTeX, the rst-parser sees it as raw text.

Parsing LaTeX for non-latex syntax is tricky, 
generally, I don't think it is a good idea to mix two markup languages in one
source-part.

How would you write :math:`|-x| = x` with your planned extension?

> I think it would be a lot nicer to use such mathmacro directive rather that
> latex macros since (i) it would leads to nicer code and (ii) the MathJax
> sphinx extension does not really supports macro definition.

Do you know, that you can use literal Unicode characters in your source?
These will be translated to LaTeX macros for LaTeX output. Mathjax also
understands Unicode. May be this suffices for your examples and some other
cases.


Günter


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Docutils-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-users

Please use "Reply All" to reply to the list.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.