Dear Enrico,

On 2015-09-17, Enrico Forestieri wrote:
> On Wed, Sep 16, 2015 at 09:02:23PM +0000, Guenter Milde wrote:
>> On 2015-09-14, Enrico Forestieri wrote:


> Please note that the patch you propose is not changing anything.

Both our suggestions handle the problem that mathed currently takes
responsibility for 20 text-commands but handles them wrong:

* Your patch tries to correct the handling of selected text-commands as
  "hardcoded math-macros".

* My patch focuses on consistent handling of textcommands: \AA is handled
  just like \aa, \oe, \i, \j, \OE, \textcopyright, \textmu, ...

  The misc-toobox is adapted to this, so that novices will not see a
  difference.

> You simply force the use of unicode symbols through the math panels.
> However, if a user directly inputs \AA this is now displayed in red,
> even if it is entered in a text mode environment. One has to save
> and reload the file to actually see that symbol.
...
> So, your patch is rather a step backward.

Yes. However, in a blind alley, a step back is the right thing to reach
the goal.

> The patch I am proposing let you display those symbols even if they are
> entered through a latex command and assures that no compile error
> occurs even without the need of saving and reloading.

> Instead your patch causes errors even after saving and reloading (and
> still leaves in red the symbol).

It does not *cause* errors:

* Old documents that worked despite of the incorrect use of textcommands
  in math (textdegree with 8-bit input encoding and without textcomp, \AA
  with LatinModern fonts) still work as before. (But the ERT will mark
  the incorrectly used commands as unsupported.)

* Old documents that failed before still fail (However, I don't think
  there are many failing documents lying around waiting for LyX to
  improve...).

* New documents

  - Correctly used commands require a save-relaod cycle to turn into Unicode
    characters (this should be improved).

  - Incorrect use of textcommands in math is not corrected. Like any
    unknown or wrong command, they are handled as "unsupported" (stay
    red).

Your patch silently corrects the wrong use of 3 text commands in math.
It wins regarding conveniency for the experienced LyX/LaTeX user 
at the cost of added complexity and blurring the line between text and math
commands.

With my patch, 



> As regards the value as a learning tool, I don't see how
> this can be countered by the fact that instead of remaining red a
> symbol is enclosed in a mode changing environment.

With your patch, the 20 textcommands in lib/symbols are still proposed
with autocompletion among the several hundred math commands and silently
wrapped during export. A user writing "\textdegree" in math mode will feel
vindicated by the way this is handled in LyX and be bitten when using the
pattern in a LaTeX source.

> Indeed, a learning user will see in the source panel that his symbol
> needs something else.

Not, unless the toobox entry for \textdegree is changed.


For other problems with your patch, see the test case at
http://www.lyx.org/trac/ticket/9742

Günter


PS

\textrm{\AA} (as inserted by the toolbox) is currently converted to
212B ANGSTROM SIGN

The Unicode standard says
  preferred representation is 00C5 latin capital letter a with ring above.

In LaTeX, both are equivalent: `latex.ltx' defines "\AA" as "\r A".

This is due to the different replacements in lib/unicodesymbols:

 0x00c5 "\\r{A}"                   "" "mathalpha" "\\mathring{A}" # LATIN 
CAPITAL LETTER A WITH RING ABOVE
 0x212b "\\AA"                     "" "force=utf8" "" "" # ANGSTROM SIGN

We need a way to handle the case of several LaTeX commands mapping to one
Unicode character, e.g. \aa is not converted to å because the
unicodesymbols mapping is "\\r{a}"

Reply via email to