Unknown control sequence '\texttt'

26 views
Skip to first unread message

ma...@mendelu.cz

unread,
Jan 10, 2010, 4:56:56 PM1/10/10
to sage-devel
Dear sage-devel

when doing in notebook

sage: show('x^2')

or

sage: show(type(factor))

I get error Unknown control sequence '\texttt'

When I try
sage:'x^2'

with checked "Typeset" button I get
\newcommand{\Bold}[1]{\mathbf{#1}}\hbox{x^2}
which is not valid LaTeX expression (supperscript outside math mode)

I think that this is a bug in Sage, Any idea where to fix it?
Thanks
Robert

John Cremona

unread,
Jan 10, 2010, 5:44:45 PM1/10/10
to sage-devel
I had exactly the same thing happen (with sage-4.3.1.alpha1, firefox).

John

2010/1/10 ma...@mendelu.cz <ma...@mendelu.cz>:

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
>

lutusp

unread,
Jan 25, 2010, 12:42:57 PM1/25/10
to sage-devel
I have just updated from Sage 4.2 to 4.3.1, but the problem described
here seems to be getting worse in 4.3.1 - I found more places where
this error appeared.

Simple example (4.3.1):

show('$a = x^2$')
Unknown control sequence '\texttt'

> Any idea where to fix it?

Seconded.

On Jan 10, 2:44 pm, John Cremona <john.crem...@gmail.com> wrote:
> I had exactly the same thing happen (with sage-4.3.1.alpha1, firefox).
>
> John
>
> 2010/1/10 ma...@mendelu.cz <ma...@mendelu.cz>:
>
> > Dear sage-devel
>
> > when doing in notebook
>
> > sage: show('x^2')
>
> > or
>
> > sage: show(type(factor))
>

> > I get errorUnknowncontrolsequence'\texttt'

John H Palmieri

unread,
Jan 25, 2010, 3:40:19 PM1/25/10
to sage-devel
In Jan 10, 1:56 pm, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> Dear sage-devel
>
> when doing in notebook
>
> sage: show('x^2')

I think that the show command doesn't work very well with strings, and
this is a bug. The relevant files are sage/misc/functional.py (!) and
sage/misc/latex.py. Note that all of

sage: show(x^2)
sage: view('x^2')
sage: view('$x^2$')

work just fine, as does clicking the "typeset" button and executing

sage: x^2

Using the "typeset" button is better behaved than "show": with the
button checked,

sage: 'x^2'
sage: type(factor)

both work fine.

Maybe use "view" instead of "show"? I'm not sure why we have both
commands anyway. I think "show" should be fixed so it just uses "view"
in this situation.

--
John

ma...@mendelu.cz

unread,
Jan 26, 2010, 1:44:05 AM1/26/10
to sage-devel

On 25 led, 21:40, John H Palmieri <jhpalmier...@gmail.com> wrote:
> sage: 'x^2'
> sage: type(factor)
>
> both work fine.

A similar problem:
sage:'x_2' (with checked Typeset button)
and
sage: view('x_2')
produce unwanted backslash (but the TeX code "\hbox{x\_2}" is O.K. and
jsmath should not include the backslash)

Robert

John H Palmieri

unread,
Jan 26, 2010, 4:38:02 PM1/26/10
to sage-devel
On Jan 25, 10:44 pm, "ma...@mendelu.cz" <ma...@mendelu.cz> wrote:
> On 25 led, 21:40, John H Palmieri <jhpalmier...@gmail.com> wrote:
>
> > sage: 'x^2'
> > sage: type(factor)
>
> > both work fine.
>
> A similar problem:
> sage:'x_2'  (with checked Typeset button)
> and
> sage: view('x_2')
> produce unwanted backslash (but the TeX code "\hbox{x\_2}" is O.K. and
> jsmath should not include the backslash)

Try the patch at <http://trac.sagemath.org/sage_trac/ticket/8084>.
The underscore issue is still present to some degree, mainly because
'x_2' is not valid LaTeX (as opposed to '$x_2$'). I think it looks
okay in the notebook now, but view('x_2') looks bad from the command
line. But this is to be expected, I think: from the command line,
"view" creates a file containing the string and runs LaTeX on it, so
if you pass it bad LaTeX, it will produce bad output.

Things to test before and after the patch, from the command-line and
from the notebook:

sage: view(type(factor))
sage: view(type(Sq(3))) # to make sure types with underscores in
their name look okay
sage: view('x^2') # invalid LaTeX, looks bad from the command line
sage: view('$x^2$')
sage: view('x_2') # invalide LaTeX
sage: view('$x_2$')

and the same things with "show" instead of "view". Also, probably the
same kinds of things but just evaluating the strings with the Typeset
button checked. What else should be tested?

--
John

lutusp

unread,
Jan 26, 2010, 9:13:09 PM1/26/10
to sage-devel
> Maybe use "view" instead of "show"?

A good solution until text and graphics are mixed, then it fails (by
requiring what 'show' has to offer). As I said elsewhere, this problem
is worse in 4.3.1 than it was in 4.2.

John H Palmieri

unread,
Jan 26, 2010, 9:55:37 PM1/26/10
to sage-devel

Give some examples, please. By the way, have you tried the patch I
mentioned in my other message today?

--
John

lutusp

unread,
Jan 29, 2010, 5:09:41 AM1/29/10
to sage-devel
> Give some examples, please.

var("y R")

a(y,R) = pi * (2*R - y) * y

lbl = text("$\int \ " + latex(a(y,R)) + "$",(3,20))

view(lbl)
... Graphics object consisting of 1 graphics primitive (not
displayed)
show(lbl)
... Unknown control sequence '\texttt'

No graphics shown.

> By the way, have you tried the patch I mentioned in my other message today?

I initially dealt with Sage problems that way, but the patches keep
changing with each new version while the problem remains unsolved. I
eventually concluded it was simpler not to upgrade. The present
problem is less severe in earlier versions.

John H Palmieri

unread,
Jan 29, 2010, 12:57:13 PM1/29/10
to sage-devel
On Jan 29, 2:09 am, lutusp <lut...@gmail.com> wrote:
> > Give some examples, please.
>
> var("y R")
>
> a(y,R) = pi * (2*R - y) * y
>
> lbl = text("$\int \  " + latex(a(y,R)) + "$",(3,20))
>
> view(lbl)
>  ... Graphics object consisting of 1 graphics primitive (not
> displayed)
> show(lbl)
>  ...  Unknown control sequence '\texttt'

When I evaluate "lbl", I don't get a picture; something is broken in
the "text" command. Because there is no picture, "show" defaults to
trying to print a text description, leading to this message. The
patch fixes it so the text description prints correctly. I don't know
why "text" is broken, but I bet someone can help.

By the way, if I run

var("y R")
a(y,R) = pi * (2*R - y) * y

lbl = text("$\int \ " + r"{\left(2 R - y\right)} \pi y" + "$",
(3,20))

then executing "lbl" or "show(lbl)" produce a picture. If I change
the last line to

lbl = text("$\int \ " + r"{\left(2 \, R - y\right)} \pi y" + "$",
(3,20)) # insert \, between 2 and R

I get an error.

> No graphics shown.
>
> > By the way, have you tried the patch I mentioned in my other message today?
>
> I initially dealt with Sage problems that way, but the patches keep
> changing with each new version while the problem remains unsolved. I
> eventually concluded it was simpler not to upgrade. The present
> problem is less severe in earlier versions.

Then why do you bother posting things that look like requests for
help?

--
John

John H Palmieri

unread,
Jan 29, 2010, 9:22:04 PM1/29/10
to sage-devel

On Jan 29, 2:09 am, lutusp <lut...@gmail.com> wrote:

> > Give some examples, please.
>
> var("y R")
>
> a(y,R) = pi * (2*R - y) * y
>
> lbl = text("$\int \  " + latex(a(y,R)) + "$",(3,20))
>
> view(lbl)
>  ... Graphics object consisting of 1 graphics primitive (not
> displayed)
> show(lbl)
>  ...  Unknown control sequence '\texttt'
>
> No graphics shown.

This is a bug with matplotlib. For Sage, it's being tracked on this
ticket:

<http://trac.sagemath.org/sage_trac/ticket/8125>

Meanwhile, you could try:

sage: s = latex(a(y,R)).replace('\\,', '') # remove \,
sage: lbl = text(r"$\int \ " + s + "$", (3, 20))
sage: show(lbl)

--
John

lutusp

unread,
Jan 31, 2010, 4:37:28 PM1/31/10
to sage-devel
> Then why do you bother posting things that look like requests for
> help?

In the hope that someone will fix the source, rather than offer new
patches? It's not as though it hasn't been reported yet, or discussed
yet, and several new releases have gone by without resolution.
Meanwhile I'll get around the problem any way I can. The reason? Sage
is terrific.

John H Palmieri

unread,
Jan 31, 2010, 6:31:58 PM1/31/10
to sage-devel
On Jan 31, 1:37 pm, lutusp <lut...@gmail.com> wrote:
> > Then why do you bother posting things that look like requests for
> > help?
>
> In the hope that someone will fix the source, rather than offer new
> patches?

This is contradictory: the way the source gets fixed is that people
post patches, and then other people test them and review them.

--
John

Reply all
Reply to author
Forward
0 new messages