Problems with embedded math

221 views
Skip to first unread message

Florian Lindner

unread,
Sep 11, 2009, 12:27:31 PM9/11/09
to sphin...@googlegroups.com
Hello,

I try to use math in my docstrings:

def fp_out(self):
"""
.. math::
M_2 = \frac{M^2 \cdot (\kappa-1)+2}{\kappa (2 M^2-1)+1}}

"""
k = self.f_prop.kappa

I've activated the pngmath extension and it works for easier examples
from the sphinx doc. But the code above gives using make html:

WARNING: inline latex u'M_2 = \x0crac{M^2 \\cdot (\\kappa-1)+2}{\
\kappa (2 M^2-1)+1}}\n\n': latex exited with error:

I got no idea where \x0 comes from, I've deleted the line and typed it
again from scratch but nothing changed. None of the editors I tried
displays it like that.
I'm using sphinx 0.6.2 from fink on Mac OS.

Any idea anyone?

Thanks,

Florian

Complete build run output:


florian@r098154 ~/dev/eclipse_workspace/TFD/doc: make clean && make html
rm -rf build/*
sphinx-build -b html -d build/doctrees source build/html
Making output directory...
Running Sphinx v0.6.2
loading pickled environment... not found
building [html]: targets for 2 source files that are out of date
updating environment: 2 added, 0 changed, 0 removed
reading sources... [100%] shock
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/florian/dev/eclipse_workspace/TFD/doc/
source/shock.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
WARNING: inline latex u'M_2 = \x0crac{M^2 \\cdot (\\kappa-1)+2}{\
\kappa (2 M^2-1)+1}}\n\n': latex exited with error:
[stderr]

[stdout]
This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4)
entering extended mode
(./math.tex
LaTeX2e <2008/12/01>
Babel <v3.8d> and hyphenation patterns for american, french, german,
ngerman, b
ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch,
esperanto, e
stonian, finnish, greek, icelandic, irish, italian, latin, magyar,
norsk, polis
h, portuges, romanian, russian, serbian, slovak, slovene, spanish,
swedish, tur
kish, ukrainian, nohyphenation, loaded.
(/sw/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2004/02/16 v1.4f Standard LaTeX document class
(/sw/share/texmf-dist/tex/latex/base/size12.clo))
(/sw/share/texmf-dist/tex/latex/base/inputenc.sty
(/sw/share/texmf-dist/tex/latex/base/utf8.def
(/sw/share/texmf-dist/tex/latex/base/t1enc.dfu)
(/sw/share/texmf-dist/tex/latex/base/ot1enc.dfu)
(/sw/share/texmf-dist/tex/latex/base/omsenc.dfu)))
(/sw/share/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/sw/share/texmf-dist/tex/latex/amsmath/amstext.sty
(/sw/share/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/sw/share/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/sw/share/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/sw/share/texmf-dist/tex/latex/amscls/amsthm.sty)
(/sw/share/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/sw/share/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/sw/share/texmf-dist/tex/latex/tools/bm.sty)
No file math.aux.
(/sw/share/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/sw/share/texmf-dist/tex/latex/amsfonts/umsb.fd)
Runaway argument?
\begin {split}M_2 =
! Forbidden control sequence found while scanning use of \gather.
<inserted text>
\par
l.13 \begin{split}M_2 = ^^L
rac{M^2 \cdot (\kappa-1)+2}{\kappa (2
M^2-1)+1}}\...

! Missing $ inserted.
<inserted text>
$
l.13 \begin{split}M_2 = ^^L
rac{M^2 \cdot (\kappa-1)+2}{\kappa (2
M^2-1)+1}}\...

! Missing \endgroup inserted.
<inserted text>
\endgroup
l.13 \begin{split}M_2 = ^^L
rac{M^2 \cdot (\kappa-1)+2}{\kappa (2
M^2-1)+1}}\...

! Display math should end with $$.
<to be read again>
\par
l.13 \begin{split}M_2 = ^^L
rac{M^2 \cdot (\kappa-1)+2}{\kappa (2
M^2-1)+1}}\...

! Missing $ inserted.
<inserted text>
$
l.13 \begin{split}M_2 = ^^Lrac{M^
2 \cdot (\kappa-1)+2}{\kappa (2
M^2-1)+1}}\...

! Extra }, or forgotten $.
l.13 ...split}M_2 = ^^Lrac{M^2 \cdot (\kappa-1)+2}
{\kappa (2
M^2-1)+1}}\end{...

! Extra }, or forgotten $.
l.13 ...2 \cdot (\kappa-1)+2}{\kappa (2 M^2-1)+1}}
\end{split}\notag\\
\begin{...

! Misplaced \crcr.
\endsplit ->\crcr
\egroup \egroup \iftagsleft@ \@xp \lendsplit@ \else
\@xp \...
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Extra }, or forgotten $.
\endsplit ->\crcr \egroup
\egroup \iftagsleft@ \@xp \lendsplit@ \else
\@xp \...
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Extra }, or forgotten $.
\endsplit ->\crcr \egroup \egroup
\iftagsleft@ \@xp \lendsplit@ \else
\@xp \...
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...


! LaTeX Error: \begin{gather} on input line 12 ended by \end{split}.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Missing $ inserted.
<inserted text>
$
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Missing $ inserted.
<inserted text>
$
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Missing $ inserted.
<inserted text>
$
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...

! Missing } inserted.
<inserted text>
}
l.13 ...appa-1)+2}{\kappa (2 M^2-1)+1}}\end{split}
\notag\\
\begin{split}\end{...


! Package amsmath Error: \begin{split} won't work here.

See the amsmath package documentation for explanation.
Type H <return> for immediate help.
...

l.13 ...end{split}\notag\\\begin{split}\end{split}
\notag
! Misplaced \cr.
\math@cr@@@ ->\cr

l.14 \end{gather}

! Misplaced \noalign.
\math@cr@@ ... \iffalse }\fi \math@cr@@@ \noalign
{\vskip #1\relax }
l.14 \end{gather}


Underfull \hbox (badness 10000) in paragraph at lines 13--14

! Misplaced \noalign.
\black@ #1->\noalign
{\ifdim #1>\displaywidth \dimen@ \prevdepth
\nointerlin...
l.14 \end{gather}

! Too many }'s.
\endgather ->\math@cr \black@ \totwidth@ \egroup
$$
\ignorespacesafterend
l.14 \end{gather}


! LaTeX Error: \begin{document} ended by \end{gather}.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.14 \end{gather}

! Missing $ inserted.
<inserted text>
$
l.14 \end{gather}

! Display math should end with $$.
<to be read again>
\endgroup
l.14 \end{gather}

! Extra \endgroup.
<recently read> \endgroup

l.14 \end{gather}

[1] (./math.aux) )
(see the transcript file for additional information)
Output written on math.dvi (1 page, 412 bytes).
Transcript written on math.log.


writing additional files... genindex modindex search
copying static files... done
dumping search index... done
dumping object inventory... done
build succeeded, 2 warnings.

Build finished. The HTML pages are in build/html.
florian@r098154 ~/dev/eclipse_workspace/TFD/doc:

Roberto Alsina

unread,
Sep 11, 2009, 12:48:14 PM9/11/09
to sphin...@googlegroups.com
On Friday 11 September 2009 13:27:31 Florian Lindner wrote:
> def fp_out(self):
> """
> .. math::
> M_2 = \frac{M^2 \cdot (\kappa-1)+2}{\kappa (2 M^2-1)+1}}
>
> """
> k = self.f_prop.kappa
>
> I've activated the pngmath extension and it works for easier examples
> from the sphinx doc. But the code above gives using make html:
>
> WARNING: inline latex u'M_2 = \x0crac{M^2 \\cdot (\\kappa-1)+2}{\
> \kappa (2 M^2-1)+1}}\n\n': latex exited with error:

You need to use raw strings, or double your backslashes.

Python 2.6.2 (r262:71600, Jul 20 2009, 02:19:59)
[GCC 4.4.0 20090630 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> '\frac'
'\x0crac'
>>> r'\frac'
'\\frac'
>>>


--
("\''/").__..-''"`-. . Roberto Alsina
`9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH)
(_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar
_..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia
(l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)

Guenter Milde

unread,
Sep 11, 2009, 3:41:36 PM9/11/09
to sphin...@googlegroups.com
On 2009-09-11, Florian Lindner wrote:

> Hello,

> I try to use math in my docstrings:

> def fp_out(self):
> """
> .. math::
> M_2 = \frac{M^2 \cdot (\kappa-1)+2}{\kappa (2 M^2-1)+1}}

> """
> k = self.f_prop.kappa

> I've activated the pngmath extension and it works for easier examples
> from the sphinx doc. But the code above gives using make html:

> WARNING: inline latex u'M_2 = \x0crac{M^2 \\cdot (\\kappa-1)+2}{\
> \kappa (2 M^2-1)+1}}\n\n': latex exited with error:

> I got no idea where \x0 comes from, I've deleted the line and typed it
> again from scratch but nothing changed. None of the editors I tried
> displays it like that.

Did you realize that it is ``\x0c``, the code for the character with
hex-number 0c, (sometimes written as ^L or line-feed)?

Comparing input to output you see:
\f \x0c
\c \\c
...

It looks like at some stage the backslash escaping is invoked.
You could try with a raw string or double backslashs.

r"""


.. math::
M_2 = \frac{M^2 \cdot (\kappa-1)+2}{\kappa (2 M^2-1)+1}}

"""


Günter

Reply all
Reply to author
Forward
0 new messages