Problem with edit caret

Help
2010-06-14
2013-04-29
  • Kenneth Tilton
    Kenneth Tilton
    2010-06-14

    I have been using this as my insertion point indicator (what I call the "caret")  in my wysiwyg jsMath editor:

       \\smash{\\rlap{\\kern-.1em\\color{red}{\\vert}}}

    I think that is the product of my clumsy messing with something you (Davide) kindly provided. I think I broke it. :) I'll go dig up the original, but…

    One problem is that (I think these are the necessary conditions) (a) in FireFox (b) without the user installing fonts the caret is invisible. On Chrome and Safari with no user fonts it is a barely visible black rectangle with a white interior. I'd really like to stay with a colored vertical bar (you kindly also offered code for a "hat" as the indicator) - doable?

    The second problem is that if you type in something like E=mc^2 (or anything) and then hit left-arrow to move the caret back across the expression you'll see the characters jiggle around. The web site is "teamalgebra dot com" (and has a couple of issues with missing ordinary text instructions, but just click on anything yellow and type the characters above it using the Legend as a guide). I recall you discussing how to make the caret not take up space with this or the other candidate, but I thought the rlap covered this and I have that in there. Any guidance appreciated (and I will revisit the original syntax to see what I can learn).

    Finally, thanks so much for making my Web site possible!

    ken

     
  • Kenneth Tilton
    Kenneth Tilton
    2010-06-14

    ps. I just confirmed that if I install the fonts (on Ubuntu anyway) that the red bar comes up fine in both FireFox and Chrome. I guess "vert" translates to something not in the fallbacks fonts? kt

     
  • Looks like you are making good progress.

    Here are some suggestions:

    Use \\unicode{x7C} in place of \\vert (this will generate the | character as an ASCII character 7C rather than use the TeX fonts, and that will be more reliable for this case).

    To avoid the "jumping characters" problem, try putting \\mathord{…} around the \\smash{…}.  TeX's spacing rules depend on the "class" of the two objects on either side of the space.  In particular, for things like binary operators, the spacing is only right for binary operators if the objects on either side are "Ord" (for "ordinary"?) symbols.  That will not be the case for the \\smash{}, so you need to tell TeX that the contents should be treated as an "Ord" using \mathord{…}.  See if that helps.

    Davide