Discussion:
Major problem with \textdegree
Abdelrazak Younes
2007-05-21 15:46:45 UTC
Permalink
Hello,

There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.

Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.

Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.

This is a major bug IMHO, LateX expert someone?

Abdel.

________________________________

Hi,
studying the Latex error messages, I noticed that lyx-1.4 sets the
inputencoding to latin1. This works for textdegree. lyx-1.5 sets it to
latin9, this does not work for textdegree.

On my debian system are both encodings installed:
***@bigix:~$ locale -a|grep de
de_DE
***@euro
de_DE.iso88591
***@euro
de_DE.utf8
deutsch

In the preferences dialog I found no possibility to tell lyx, which
encoding
to use. My workaround: put the "Use language's default encoding" off and
put
in the latex preamble \usepackage[latin1]{inputenc}.

Now textdegree works, and as I am writing text about chemistry with a
lot of
textdegree symbols I have only one change to do to make my scripts working
again with this very nice lyx-1.5.

Bernd
Jürgen Spitzmüller
2007-05-21 16:04:27 UTC
Permalink
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
I don't know how he inserted it, but the problem is that \textdegree is in
math mode, while it should be in math-text mode. This has nothing to do with
the encoding. It doesn't work either if you change the document encoding to
latin1.

Maybe a case of this
http://bugzilla.lyx.org/show_bug.cgi?id=2315

Jürgen
Abdelrazak Younes
2007-05-21 16:17:50 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
I don't know how he inserted it, but the problem is that \textdegree is in
math mode, while it should be in math-text mode.
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
Post by Jürgen Spitzmüller
This has nothing to do with
the encoding. It doesn't work either if you change the document encoding to
latin1.
Maybe a case of this
http://bugzilla.lyx.org/show_bug.cgi?id=2315
I am not expert enough to see the similarities :-/

Abdel.
Jürgen Spitzmüller
2007-05-21 16:39:26 UTC
Permalink
Post by Abdelrazak Younes
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
Now I know what the problem is. $\textdegree$ works in 1.4 (and also in 1.5)
because it is defined in lib/symbols:
\def\textdegree{\kern-1mu^{\circ}\kern-4mu}

However, as soon as the package textcomp is loaded, this definition will be
overridden by textcomps definition, which does only work in text mode.

Now in the test file, there's an additional unicode symbol °, which requests
unicode. Delete that symbol, and the math \textdegree will show up.

I'm not sure yet what we can do about it.

Jürgen
Jürgen Spitzmüller
2007-05-21 17:00:40 UTC
Permalink
Post by Jürgen Spitzmüller
Now in the test file, there's an additional unicode symbol °, which
requests unicode.
which requests textcomp, of course.

Jürgen
Abdelrazak Younes
2007-05-21 17:34:01 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Abdelrazak Younes
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
Now I know what the problem is. $\textdegree$ works in 1.4 (and also in 1.5)
\def\textdegree{\kern-1mu^{\circ}\kern-4mu}
However, as soon as the package textcomp is loaded, this definition will be
overridden by textcomps definition, which does only work in text mode.
Now in the test file, there's an additional unicode symbol °, which requests
unicode. Delete that symbol, and the math \textdegree will show up.
I'm not sure yet what we can do about it.
Remove the hack in lib/symbols?

Abdel.
Jürgen Spitzmüller
2007-05-21 17:51:42 UTC
Permalink
Post by Abdelrazak Younes
Post by Jürgen Spitzmüller
I'm not sure yet what we can do about it.
Remove the hack in lib/symbols?
Maybe. But then lyx2lyx will have to translate the textdegrees to text mode.

Jürgen
Georg Baum
2007-05-21 19:00:26 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Abdelrazak Younes
Post by Jürgen Spitzmüller
I'm not sure yet what we can do about it.
Remove the hack in lib/symbols?
Maybe. But then lyx2lyx will have to translate the textdegrees to text mode.
No. This part of lib/symbols is only used for display, so removing the hack
does not cause a fileformat change.

The problem is really that both a literal ° and \textdegree work with
latin1 encoding _in mathed_. They don't work with latin9 encoding.

So the hack in lib/symbols only reflects the fact that \textdegree
sometimes works even in mathed, but it does not cause any harm.

Don't ask me why the inputenc package does what it does, I don't understand
it, I only see the results.

This does also mean that at the time when the language encoding of some
languages was changed to latin9 there should have been a lyx2lyx change,
because old documents with encoding setting auto and ° in math or text
will not work anymore.


Georg
Jürgen Spitzmüller
2007-05-22 04:45:24 UTC
Permalink
Post by Georg Baum
This does also mean that at the time when the language encoding of some
languages was changed to latin9 there should have been a lyx2lyx change,
because old documents with encoding setting auto and ° in math or text
will not work anymore.
But it dosen't work either in latin1 if you use textcomp. I don't see a
difference.

Jürgen
Georg Baum
2007-05-22 08:10:51 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Georg Baum
This does also mean that at the time when the language encoding of some
languages was changed to latin9 there should have been a lyx2lyx change,
because old documents with encoding setting auto and ° in math or text
will not work anymore.
BTW this would not be correct either for multilanguage docs.
Post by Jürgen Spitzmüller
But it dosen't work either in latin1 if you use textcomp. I don't see a
difference.
I did not use textcomp, this is a separate problem. The problem that was
originally reported is a pure inputenc problem. Without using textcomp you
get the following:

latin1 latin9
° in math works does not work
\textdegree in math works works
° in text works does not work
\textdegree in text (ERT) works works


This is with TeXLive 2005. It might be fixed in newer versions of the
inputenc package, but ° with latin9 encoding does definitely not work with
TeXLive 2005. The error message is

! Package inputenc Error: Keyboard character used is undefined
(inputenc) in inputencoding `latin9'.


Georg
Jürgen Spitzmüller
2007-05-22 08:26:14 UTC
Permalink
Post by Georg Baum
I did not use textcomp, this is a separate problem. The problem that was
originally reported is a pure inputenc problem.
No, the problem originally reported was that $\textdegree$ does not work in
1.5 (in a file that requested textcomp). This is at least indicated by the
testcase (I didn't follow the actual thread).
Post by Georg Baum
Without using textcomp you
                            latin1   latin9
° in math                   works    does not work
\textdegree in math         works    works
° in text                   works    does not work
\textdegree in text (ERT)   works    works
This is with TeXLive 2005.
TeXLive 2007, without textcomp loaded:

latin1 latin9
° in math works works*
\textdegree in math works works*
° in text works** works**
\textdegree in text (ERT) works works

TeXLive 2007, with textcomp loaded:

latin1 latin9
° in math does not work does not work
\textdegree in math does not work does not work
° in text works** works**
\textdegree in text (ERT) works works

* although I get error messages:
./degree.tex:16: Command \textdegree invalid in math mode on input line 16.
./degree.tex:18: Command \^ invalid in math mode on input line 18.
./degree.tex:18: Command \textdegree invalid in math mode on input line 18.

** sort of: in both encodigs, I get an additional weird character

So the problem is: what can we do with $\textdegree$ and $°$ in case textcomp
is requested?

Jürgen
Herbert Voss
2007-05-22 09:10:51 UTC
Permalink
Post by Jürgen Spitzmüller
So the problem is: what can we do with $\textdegree$ and $°$ in case textcomp
is requested?
a _correct_ and save way is to do nothing inside LyX and using
always the LaTeX definitions. In fact of some compatibility
you can do inside LyX

\providecommand\LyXtextdegree{\ensuremath{^\circ}}
\let\textdegree\LyXtextdegree

and using \LyXtextdegree _always_ in math mode.

all other cases cannot be handled in a save way, because the user
can load packages in his own order, packages which redefine this
setting, ...

However, using the gensymb package with its \degree-Symbol is
the best choice.


Herbert
Georg Baum
2007-05-22 09:30:58 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Georg Baum
I did not use textcomp, this is a separate problem. The problem that was
originally reported is a pure inputenc problem.
No, the problem originally reported was that $\textdegree$ does not work
in 1.5 (in a file that requested textcomp). This is at least indicated by
the testcase (I didn't follow the actual thread).
The test case was by Abdel, the original report to which I refered (cited by
Abdel) was a bit different.
Post by Jürgen Spitzmüller
Post by Georg Baum
Without using textcomp you
latin1   latin9
° in math                   works    does not work
\textdegree in math         works    works
° in text                   works    does not work
\textdegree in text (ERT)   works    works
This is with TeXLive 2005.
latin1 latin9
° in math works works*
\textdegree in math works works*
° in text works** works**
\textdegree in text (ERT) works works
latin1 latin9
° in math does not work does not work
\textdegree in math does not work does not work
° in text works** works**
\textdegree in text (ERT) works works
./degree.tex:16: Command \textdegree invalid in math mode on input line
16. ./degree.tex:18: Command \^ invalid in math mode on input line 18.
./degree.tex:18: Command \textdegree invalid in math mode on input line 18.
I get these, too, but the output is still OK.
Post by Jürgen Spitzmüller
** sort of: in both encodigs, I get an additional weird character
So the problem is: what can we do with $\textdegree$ and $°$ in case
textcomp is requested?
Nothing IMHO, since this problem is not new. In the long run mathed should
probably use some mechanism similar to the unicodesymbols file to replace
unicode characters with appropriate commands, and then it could also
replace ° with a command that works always.

It might be possible that this would already work with the lib/symbols file,
but I am not sure if you can put single characters in there and only
redefine the LaTeX output.


Georg
Georg Baum
2007-05-21 16:50:31 UTC
Permalink
Post by Abdelrazak Younes
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
The inputenc package is stupid. The latin9 encoding does contain the degree
symbol, but the inputenc package does not know that. The same is true for
\textmu, so if you use the same workaround for \textdegree as is used for
\textmu (force flag in unicodesymbols) it should work.
Post by Abdelrazak Younes
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
No. With ERT you are allowed to shoot yourself in the foot, both in normal
text and in mathed.


Georg
Abdelrazak Younes
2007-05-21 17:33:24 UTC
Permalink
Post by Georg Baum
Post by Abdelrazak Younes
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
The inputenc package is stupid. The latin9 encoding does contain the degree
symbol, but the inputenc package does not know that. The same is true for
\textmu, so if you use the same workaround for \textdegree as is used for
\textmu (force flag in unicodesymbols) it should work.
Post by Abdelrazak Younes
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
No. With ERT you are allowed to shoot yourself in the foot, both in normal
text and in mathed.
I meant automatically replace \textdegree<space> with \mbox{\textdegree}
inside mathed. But I see that Jurgen has discovered what the real
problem is.

Abdel.
Herbert Voss
2007-05-21 17:56:59 UTC
Permalink
Post by Abdelrazak Younes
Post by Georg Baum
Post by Abdelrazak Younes
Right, if I insert \textdegree inside an ERT, the degree symbol is
shown. So, the correction would be to automatically encapsulate
\textdegree inside an mbox when with mathed. Is it possible to do that
thanks to some definition in lib/symbols?
No. With ERT you are allowed to shoot yourself in the foot, both in normal
text and in mathed.
I meant automatically replace \textdegree<space> with \mbox{\textdegree}
inside mathed. But I see that Jurgen has discovered what the real
problem is.
with latin9 encoding it works in math and text mode anymay.

Herbert
Jürgen Spitzmüller
2007-05-21 18:07:01 UTC
Permalink
Post by Herbert Voss
with latin9 encoding it works in math and text mode anymay.
but as soon as textcomp is loaded, it fails:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{textcomp} %<---
\usepackage{babel}

\begin{document}

mathed: $\textdegree$
text: °

\end{document}

Even if ° would not request textcomp, there's always the possibility that some
other package does.

Jürgen
Herbert Voss
2007-05-21 18:58:35 UTC
Permalink
Post by Jürgen Spitzmüller
Post by Herbert Voss
with latin9 encoding it works in math and text mode anymay.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{textcomp} %<---
\usepackage{babel}
\begin{document}
mathed: $\textdegree$
text: °
\end{document}
Even if ° would not request textcomp, there's always the possibility that some
other package does.
sure, textcomp overwrites the definition without an \ensuremath command.

Herbert
Herbert Voss
2007-05-21 17:48:37 UTC
Permalink
Post by Georg Baum
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
The inputenc package is stupid. The latin9 encoding does contain the degree
symbol, but the inputenc package does not know that. The same is true for
??
With latin9 you get a working \textdegree ...
and also some other symbols different to latin1
Post by Georg Baum
\textmu, so if you use the same workaround for \textdegree as is used for
\textmu (force flag in unicodesymbols) it should work.
Herbert
Georg Baum
2007-05-21 18:44:23 UTC
Permalink
Post by Herbert Voss
Post by Georg Baum
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
Bernd Sellentin (message reproduced below) suggests to put
\usepackage[latin1]{inputenc} in the preamble. But this leads to a LateX
error about a clash in the inputenc package.
The inputenc package is stupid. The latin9 encoding does contain the degree
symbol, but the inputenc package does not know that. The same is true for
??
With latin9 you get a working \textdegree ...
and also some other symbols different to latin1
Sure, \textdegree does not depend on the inputenc package.

What does not work with \usepackage[latin9]{inputenc} (in TeXlive 2005) is
a literal °. It does work with latin1. And this is stupid, because ° is
contained in the latin9 encoding at the same position as in latin1: 0xb0.


Georg
Herbert Voss
2007-05-22 08:51:30 UTC
Permalink
Post by Georg Baum
Post by Herbert Voss
??
With latin9 you get a working \textdegree ...
and also some other symbols different to latin1
Sure, \textdegree does not depend on the inputenc package.
??? \inputenc does nothing else than loading
the definition file ...
Post by Georg Baum
What does not work with \usepackage[latin9]{inputenc} (in TeXlive 2005) is
a literal °. It does work with latin1. And this is stupid, because ° is
contained in the latin9 encoding at the same position as in latin1: 0xb0.
sure, nobody did such a \DeclareTextCommand. But it is really easy
to do it yourself. This has nothing to do with inputenc as package.

Hebrert
Georg Baum
2007-05-22 09:35:59 UTC
Permalink
Post by Herbert Voss
Post by Georg Baum
Post by Herbert Voss
??
With latin9 you get a working \textdegree ...
and also some other symbols different to latin1
Sure, \textdegree does not depend on the inputenc package.
??? \inputenc does nothing else than loading
the definition file ...
I don't understand what you want to tell here.
Post by Herbert Voss
Post by Georg Baum
What does not work with \usepackage[latin9]{inputenc} (in TeXlive 2005)
is a literal °. It does work with latin1. And this is stupid, because °
0xb0.
sure, nobody did such a \DeclareTextCommand. But it is really easy
to do it yourself.
Of course I can. But I believe that inputenc is supposed to do that for me.
Post by Herbert Voss
This has nothing to do with inputenc as package.
Then you can surely explain what inputenc is supposed to do? I always
believed that

\usepackage[xxx]{inputenc}

would allow me to type directly in xxx encoding, without the need to use
commands like \textdegree directly, but now you are telling me that that is
wrong?


Georg
Helge Hafting
2007-05-22 11:13:07 UTC
Permalink
Post by Georg Baum
Then you can surely explain what inputenc is supposed to do? I always
believed that
\usepackage[xxx]{inputenc}
would allow me to type directly in xxx encoding, without the need to use
commands like \textdegree directly, but now you are telling me that that is
wrong?
Looks like inputenc is incomplete then - the correct action then
is to fix inputenc.

Helge Hafting

Jean-Marc Lasgouttes
2007-05-21 16:32:47 UTC
Permalink
Abdelrazak> Hello, There's some problems with \textdegree reported on
Abdelrazak> the users list that I can easily reproduce. With the
Abdelrazak> attached LyX file, the LateX export will translate the
Abdelrazak> degree symbol in mathed to \textdegree.

Does adding \usepackage{textcomp} help?

JMarc
Abdelrazak Younes
2007-05-21 16:37:26 UTC
Permalink
Post by Jean-Marc Lasgouttes
Abdelrazak> Hello, There's some problems with \textdegree reported on
Abdelrazak> the users list that I can easily reproduce. With the
Abdelrazak> attached LyX file, the LateX export will translate the
Abdelrazak> degree symbol in mathed to \textdegree.
Does adding \usepackage{textcomp} help?
No.

Abdel.
Herbert Voss
2007-05-21 16:37:54 UTC
Permalink
Post by Abdelrazak Younes
There's some problems with \textdegree reported on the users list that I
can easily reproduce. With the attached LyX file, the LateX export will
translate the degree symbol in mathed to \textdegree.
Neither the dvi nor the pdf (pdflatex) file shows the \textdegree symnol
but both of them shows the unicode symbol just fine.
the log file says it all ...

Herbert
Darren Freeman
2007-05-22 02:45:39 UTC
Permalink
I thought I'd re-use this thread.

Hit C-m, "\circ", on my system I get red writing "circ" which is
basically what I would get if I typed anything else with a backslash.

But the generated output has a circle.

Something missing from my system? I think when this happened in the
distant past it was related to missing fonts that the X-server didn't
know how to find.

It's not very good behaviour because I was trying to figure out why
something I remembered from 4 years ago wasn't recognised. I think the
correct behaviour for a missing font is to emphasise it somehow so I
know it's going to be recognised by LaTeX at least.

Have fun,
Darren
Loading...