On Mon, Sep 14, 2015 at 12:52:34PM +0000, Guenter Milde wrote: > Dear Enrico, > > thanks for the patch. I tested it and unfortunately, it solves only part of > the problem: > > On 2015-09-12, Enrico Forestieri wrote: > > On Thu, Sep 10, 2015 at 02:14:26PM +0000, Guenter Milde wrote: > > >> LyX mis-handles some text commands in math mode. > > >> Try: > > >> * open LyX, > >> * open a new document, > >> * open a math box (CTRL-M) > >> * write \text\AA > > ... > > >> A complete discussion and patch are at http://www.lyx.org/trac/ticket/9742 > > > I think that all is needed is the attached patch. > > While the patch fixes the worst case (i.e. the above example), it is no > solution for #9742: > > * open LyX, > * open a new document, > * open a math box (CTRL-M) > * write \AA > > The ERT is replaced by a blue italic Å, indicating that LyX regards "\AA" as > a valid math command. > > However, when compiling, there is the error > > Missing character: There is no � in font cmr10! > > > In contrast, if you input a literal Å in math mode (with the compose-key > or a scandinavian keyboard, say), it is shown as just the same italic > blue letter but exported as $\mathring{A}$ (due to the > lib/unicodesymbols replacements) which compiles fine -- identical looking > symbols, where one works and one fails!
This is a more general problem that is difficult to get right in all circumstances. The lib/unicodesymbols replacements are not a panacea that always work, and sometimes those replacements simply get in the way. As an example I attach here a file where I introduced a literal Å in mathed and the lib/unicodesymbols replacement is wrong (try compiling). Instead, try now commenting the "LATIN CAPITAL LETTER A WITH RING ABOVE" line in lib/unicodesymbols, quit and relaunch lyx, load the exact same file and now compilation succeeds. > The same problem holds for "\O" and "\textdegree"¹. > > No error but a completely different symbol is the outcome for 17 of the 18 > "wasy textmode" commands in /lib/symbols (\AC is tagged as “textmode”, > but works in text and maths). > > Günter > > > > ¹ \textdegree works in math if and only if the textcomp package is *not* > loaded and the LaTeX inputencoding is set to one of the 8-bit encodings > that provide a fallback definition of \textdegree as \ensuremath{^\circ}. I think that it is very difficult, if not impossible, catching all quirks of latex. IMO lyx should simply help in the most common cases and not trying to be too smart (I think you made the same point recently). This does not mean that one should not try to address an issue, but I rather avoid radical changes. Those macros had been defined in the symbols file for a very long time and I find them useful. You pointed out a problem and a partial solution was found. This is not a complete solution but at least it solves the problem when you input those macros in the right environment (yes, I think that for proficiently using lyx one needs to know latex to some degree). For this reasons I am going to commit the change. I may also think of something acceptable to everyone for the remaining issues, but also someone else could try to do that. -- Enrico
#LyX 2.1 created this file. For more info see http://www.lyx.org/ \lyxformat 474 \begin_document \begin_header \textclass article \begin_preamble \def\mytextrm{\textrm} \end_preamble \use_default_options false \maintain_unincluded_children false \language english \language_package default \inputencoding auto \fontencoding global \font_roman default \font_sans default \font_typewriter default \font_math auto \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \default_output_format default \output_sync 0 \bibtex_command default \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry false \use_package amsmath 1 \use_package amssymb 1 \use_package cancel 1 \use_package esint 0 \use_package mathdots 0 \use_package mathtools 1 \use_package mhchem 0 \use_package stackrel 1 \use_package stmaryrd 1 \use_package undertilde 1 \cite_engine basic \cite_engine_type default \biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \justification true \use_refstyle 0 \index Index \shortcut idx \color #008000 \end_index \leftmargin 1.5cm \topmargin 2cm \rightmargin 1.5cm \bottommargin 2cm \secnumdepth 5 \tocdepth 5 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \end_header \begin_body \begin_layout Standard \begin_inset Formula $\mytextrm{Å}$ \end_inset \end_layout \end_body \end_document