Cyrillic letters in the forumlas - how?

Cyrillic letters in the forumlas - how?

by Michael Goncharenko -
Number of replies: 2

Hi,

I have tried to insert cyrillic letters in the formulas and got no result, they appeared as "[?]" in TeX and report Syntax errors in algebra filter. Could I fix this and how?

Average of ratings: -
In reply to Michael Goncharenko

Re: Cyrillic letters in the forumlas - how?

by John Forkosh -
Sorry, the AMS Cyrillic fonts aren't available in mimetex.
In reply to Michael Goncharenko

Re: Cyrillic letters in the forumlas - how?

by Davide Cervone -
The jsMath filter could do this for you. I don't know Cyrillic myself, so I'm not sure of all the details that you may need to cover, but there are several ways to get non-Latin characters from jsMath. First, if you enter a character that jsMath doesn't recognize, it will simply treat it as it would a standard letter used for a variable, and pass the character through to the browser unchanged.

This will work for simple situations, but if you do this, jsMath will not know the correct height and depth for the character, and so will use the default size, which is the size of an "M" character. (The width will be correctly determined, but not the height or depth.) This will not be correct if the character has descenders, for example, so if you use the character in things like square roots, fractions, or exponents, it may not be positioned perfectly.

An alternative is to use jsMath's \unicode macro to insert a specific Unicode character. For example \unicode{x042F} will produce a capital letter "ya". This will also use the default character size, but you can also specify the ascender height and descender depth, as in \unicode{x0442,normal,0,.2}, which uses a descender of .2ems and no extra ascender height. (The "normal" specifies a CSS class to use for the character in case special treatment is needed.) Note that a value of 1 for the height means use the usual height for an M; otherwise it specifies an ascender height, which is the amount of extra space to add above the usual height of an "x" in ems.

Of course, inserting the \unicode calls by hand would be very tedious, so it is possible to create macros for them. This is probably best handled by creating an external JavaScript file that gets loaded automatically when jsMath is loaded. It can include commands like:

    jsMath.Macro('Ya','\unicode{x042F,normal,1,0}');
    jsMath.Macro('ya','\unicode{x044F,normal,0,0}');
to define \Ya for capital "ya" and \ya for lower-case "ya". If you store these commands in a file called cyrillic.js in the filters/jsmath/jsMath/extensions directory, you can cause the jsMath filter to load the file automatically by adding "extensions/cyrillic.js" to the loadFiles parameter of the filters/jsmath/javascript.php file. (It is also possible to define these in TeX using \def\Ya{\unicode{x042F,normal,1,0}}, but that is not so easy to load automatically.)

It would also be possible to map the character you normally type to macros that insert the unicode references. This would require you to have a file that includes something like:

    jsMath.Package(jsMath.Parser,{

      special: {
        "\u042F": 'CyrillicChar',
        "\u044F": 'CyrillicChar'
      },
  
      cyrillic: {
        "\u042F": ['x042F',1,0],  // [unicode code point, height, depth]
        "\u044F": ['x044F',0,0]
      },
  
      CyrillicChar: function (c) {
        data = this.cyrillic[c];
        this.mlist.Add(
          jsMath.mItem.TextAtom('ord',''+data[0]+';','normal',data[1],data[2])
        );
      }

    });
This should make "?" (not sure if that will show up correctly) produce the unicode character 0x044F. You might need to change the "\u042F" to correspond to whatever you usually type for this character. You may be able to enter the character directly within the parentheses rather than use a numeric code. Of course, you will need to add entries to the special and cyrillic definitions above to handle all the characters you are interested in using.

If you are looking to use one of the Cyrillic TeX fonts (which are not included with jsMath) rather than Unicode characters, you can do that, but it would require you to build your own jsMath font definition files; I can tell you how if that's what you have in mind.

Hope one of these approaches works for you.

Davide