From: Matthew Leingang <leingang@ci...> - 2008-08-05 14:39:06
I'm a long time user of restructured text but newbie to the list. Let
me first say I love RST!
I author web pages in RST and then convert them to HTML. It lets me
stick to writing and keeps me from fiddling with HTML indentation and
CSS until I'm finished with the content. Since I'm a mathematician I
have to write some formulas in the pages as well.
I often use the latex directive and role plugin that's in the sandbox,
and that works fine on complicated formulas. Other times if the
formula is just an "x" that I want in a math font, I'll just use
emphasis: *x*. But what if it's something less simple, like x^n? I
know that x\ :sup:`n` gives an x with an n superscript, and *x* an
emphasized x, but how can I get an emphasized power expression?
Basically I want :emphasis:`x\ :sup:`n``, but that doesn't parse. Is
there a workaround to "nest" roles like this?
Thanks for your help.
PS I know I should probably create a new role for math instead of
using :emphasis:. I know how to do that but I'll wait until I can get
this to work.
From: David Goodger <goodger@py...> - 2008-08-05 14:58:13
On Tue, Aug 5, 2008 at 10:06, Matthew Leingang <leingang@...> wrote:
> Basically I want :emphasis:`x\ :sup:`n``, but that doesn't parse. Is
> there a workaround to "nest" roles like this?
You can define custom roles, either standalone:
.. role:: msup
Or based on another role:
.. role:: esup(sup)
Then use them like this:
*y*\ :msup:`3`, *x*\ :esup:`2`
The resulting classes must be defined in your stylesheet. Here, "msup"
should be defined as italic superscript, and esup only as italic
(since the superscript will be generated because of the base role).
David Goodger <http://python.net/~goodger>