On Fri, Feb 01, 2002 at 04:35:15PM +0100, Andre Poenitz wrote:

> On Fri, Feb 01, 2002 at 05:32:12PM +0200, Martin Vermeer wrote:
> > There isn't anything else that I am aware of and that you can get
> > rendered by LaTeX. It just refuses in math mode. Of couse \ddot is 
> > double differentiation wrt time. I suppose you just cannot use umlauted
> > letters in math.
> 
> Ok. So \ddot{o} is not too bad.
> 
> Andre'

Actually the situation is more complicated than that. You *can* get
text-mode accents into math, and sometimes you need them too, like when
writing explanatory strings in non-USASCII in a formula. Like

         ( +1 wenn größer
   var = (
         ( -1 wenn kleiner

Currently this requires ERT. Which is a bit silly for a piece of natural
language ;-) The math accents (like \ddots(o) for ö) will sort-of do but
are not quite right.

The probably best solution would be to have a \mbox inset or so, inside
of which things behave like in a text inset, Umlauts and all. There is
no easy fix here and now, I think.

I have been experimenting with macros for producing the Å (Ångström) and
Ø (Oersted) units in textrm. That solves that special problem, and one
could place them on some math panel too. But you wouldn't want to see
this for *all* the accented characters that people around the world
would want to embed in their math...

Alternatively use the same mechanism I used in producing the
calligraphic F, L, H and O on the Misc sub-panel. Minuses are that (1)
this is not a job for the front end really, and (2) it still allows a
user to go and change textrm back to the default math in spite of the
presence of Umlauts. And then LaTeX will spit out a warning, something
LyX sould protect against.

I attach a fix that gets the accents working in maths as it was probably 
intended. Now you can type "a to get ä and even press the ä key if you
have one. It still misbehaves a bit in anything but the default math
font though. But I think it is clearly better than what there is now.

-- Martin


Index: formulabase.C
===================================================================
RCS file: /cvs/lyx/lyx-devel/src/mathed/formulabase.C,v
retrieving revision 1.121
diff -u -b -B -p -r1.121 formulabase.C
--- formulabase.C       2002/01/16 14:24:37     1.121
+++ formulabase.C       2002/02/03 20:25:11
@@ -32,6 +32,7 @@
 #include "LaTeXFeatures.h"
 #include "debug.h"
 #include "math_support.h"
+#include "frontends/Dialogs.h"
 #include "support/lstrings.h"
 #include "LyXView.h"
 #include "Painter.h"
@@ -73,10 +74,13 @@ void handleFont(BufferView * bv, MathTex
 }
 
 
-void handleAccent(BufferView * bv, string const & name)
+void handleAccent(BufferView * bv, string const & name, string const & arg)
 {
        bv->lockedInsetStoreUndo(Undo::EDIT);
        mathcursor->insert(createMathInset(name));
+       mathcursor->left();
+       mathcursor->interpret(arg);
+       mathcursor->right();
 }
 
 
@@ -500,17 +508,33 @@ InsetFormulaBase::localDispatch(BufferVi
 
                // --- accented characters ------------------------------
 
-       case LFUN_UMLAUT:       handleAccent(bv, "ddot"); break;
-       case LFUN_CIRCUMFLEX:   handleAccent(bv, "hat"); break;
-       case LFUN_GRAVE:        handleAccent(bv, "grave"); break;
-       case LFUN_ACUTE:        handleAccent(bv, "acute"); break;
-       case LFUN_TILDE:        handleAccent(bv, "tilde"); break;
-       case LFUN_MACRON:       handleAccent(bv, "bar"); break;
-       case LFUN_DOT:          handleAccent(bv, "dot"); break;
-       case LFUN_CARON:        handleAccent(bv, "check"); break;
-       case LFUN_BREVE:        handleAccent(bv, "breve"); break;
-       case LFUN_VECTOR:       handleAccent(bv, "vec"); break;
-       case LFUN_UNDERBAR:     handleAccent(bv, "underbar"); break;
+       case LFUN_UMLAUT:
+       case LFUN_CIRCUMFLEX:
+       case LFUN_GRAVE:
+       case LFUN_ACUTE:
+       case LFUN_TILDE:
+       case LFUN_MACRON:
+       case LFUN_DOT:
+       case LFUN_CARON:
+       case LFUN_BREVE:
+       case LFUN_VECTOR:
+       case LFUN_UNDERBAR:
+       switch(action) {
+               case LFUN_UMLAUT:       handleAccent(bv, "ddot", arg); break;
+               case LFUN_CIRCUMFLEX:   handleAccent(bv, "hat", arg); break;
+               case LFUN_GRAVE:        handleAccent(bv, "grave", arg); break;
+               case LFUN_ACUTE:        handleAccent(bv, "acute", arg); break;
+               case LFUN_TILDE:        handleAccent(bv, "tilde", arg); break;
+               case LFUN_MACRON:       handleAccent(bv, "bar", arg); break;
+               case LFUN_DOT:          handleAccent(bv, "dot", arg); break;
+               case LFUN_CARON:        handleAccent(bv, "check", arg); break;
+               case LFUN_BREVE:        handleAccent(bv, "breve", arg); break;
+               case LFUN_VECTOR:       handleAccent(bv, "vec", arg); break;
+               case LFUN_UNDERBAR:     handleAccent(bv, "underbar", arg); break;
+               default: ;
+       }
+       updateLocal(bv, true);
+       break;  
 
        //  Math fonts
        case LFUN_GREEK_TOGGLE: handleFont(bv, LM_TC_GREEK); break;

Attachment: msg32340/pgp00000.pgp
Description: PGP signature

Reply via email to