Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#5836 closed defect (duplicate)

Cyrillic formatted text in mathmode

Reported by: regonly-noreply@… Owned by: lasgouttes
Priority: high Milestone: 1.6.3
Component: general Version: 1.6.1
Severity: normal Keywords:
Cc: milde@…, forenr@…, vfr@…

Description

Hi, dear developers!

We have mathtext package to write russian in math mode. By default russian letters are
upright, but we can say:

\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}

аnd make them italic (or slanted etc.). That is very important possibility, but in LyX it
doesn't work! I think, the occasion is in LyX code, which programm adds into document:

\DeclareRobustCommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}

\def\rmorbf##1{\ifx\math@version\b@ld\textbf{##1}\else\textrm{##1}\fi}
\mathchoice{\hbox{\rmorbf{#1}}}{\hbox{\rmorbf{#1}}}
{\hbox{\smaller[2]\rmorbf{#1}}}{\hbox{\smaller[3]\rmorbf{#1}}}
\endgroup\else#1\fi}

but I don't know, how to resolve this problem. Could you fix it in next releases and how to
fix it now?

Best regards, neGODnick

Attachments (6)

bug5836.lyx (1004 bytes ) - added by forenr@… 15 years ago.
LyX document demonstrating the problem.
rus-math_lyx_.lyx (11.2 KB ) - added by regonly-noreply@… 15 years ago.
My LyX example for russian letters in math mode
rus-math.tex (826 bytes ) - added by regonly-noreply@… 15 years ago.
Hand-made TeX example, not imported from LyX
bug5836c.lyx (4.4 KB ) - added by forenr@… 15 years ago.
LyX document (brief tutorial on \lyxmathsym)
cyrillic-in-math.lyx (4.2 KB ) - added by milde@… 15 years ago.
How to input cyrillic chars in a formula with LyX 1.6.1
cyrillic-in-math.2.lyx (5.1 KB ) - added by milde@… 15 years ago.
fixed version + additional reference

Download all attachments as: .zip

Change History (24)

comment:1 by Vincent van Ravesteijn, 15 years ago

Cc: forenr@… added

comment:2 by forenr@…, 15 years ago

Please, can you attach a small LaTeX file where you get italic Russian
letters in math mode? The following doesn't work for me:

\documentclass[russian]{article}
\usepackage[T1]{fontenc}
\usepackage[koi8-r]{inputenc}
\usepackage{mathtext}
\usepackage{babel}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\begin{document}
É$\textrm{É}É$
\end{document}

comment:3 by Vincent van Ravesteijn, 15 years ago

This works for me. You should use T2A as fontenc and load mathext before
fontenc and babel. (PS. mathrm doesn't work in math somehow)

\documentclass[russian]{article}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\usepackage[koi8-r]{inputenc}
\usepackage{babel}
\begin{document}
Æ$ÆÙ$
\end{document}

comment:4 by Vincent van Ravesteijn, 15 years ago

Cc: vfr@… added
Severity: majornormal

This works for me. You should use T2A as fontenc and load mathext before
fontenc and babel. (PS. mathrm doesn't work in math somehow)

\documentclass[russian]{article}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\usepackage[koi8-r]{inputenc}
\usepackage{babel}
\begin{document}
Æ$ÆÙ$
\end{document}

comment:5 by regonly-noreply@…, 15 years ago

My working (in TeX) example:

\documentclass{article}
\usepackage{mathtext} % Use russian letters in math mode. Load BEFORE fontenc!

\usepackage[T2A]{fontenc}
\usepackage[cp1251]{inputenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it} % Select font for russian
letters in math mode. Load AFTER fontenc!
\usepackage[english,russian]{babel}
%\usepackage{amsmath} % amsmath not need for this example

\begin{document}

$X_{ёлок}+Y_{берёзок}=Z\quad(всего\:деревьев\:в\:лесу)$

\end{document}

Now I found temporary solution --- I add in “user” preambula (in LyX dialog
window) changed daclaration:

\DeclareRobustCommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}
\def\rmorbf##1{\ifx\math@version\b@ld\textbf{##1}\else\textit{##1}\fi}

\mathchoice{\hbox{\rmorbf{#1}}}{\hbox{\rmorbf{#1}}}
{\hbox{\smaller[2]\rmorbf{#1}}}{\hbox{\smaller[3]\rmorbf{#1}}}
\endgroup\else#1\fi}

This works in LyX! I've changed command before first \fi (second line
downward). This was “\textrm”, it may be changed with \textit, \textsl etc.
But this solution is not optimal and methodologically wrong, imho.

comment:6 by regonly-noreply@…, 15 years ago

Forgotten:

Than we use changed LyX's declaration

\DeclareRobustCommand{\lyxmathsym}[1]{\ifmmode\begingroup\def\b@ld{bold}
\def\rmorbf##1{\ifx\math@version\b@ld\textbf{##1}\else“\CHANGED”{##1}\fi}

\mathchoice{\hbox{\rmorbf{#1}}}{\hbox{\rmorbf{#1}}}
{\hbox{\smaller[2]\rmorbf{#1}}}{\hbox{\smaller[3]\rmorbf{#1}}}
\endgroup\else#1\fi}

command \DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it} is not required. We may
delete it.

by forenr@…, 15 years ago

Attachment: bug5836.lyx added

LyX document demonstrating the problem.

comment:7 by forenr@…, 15 years ago

Keywords: fixedintrunk added
Milestone: 1.6.3

by regonly-noreply@…, 15 years ago

Attachment: rus-math_lyx_.lyx added

My LyX example for russian letters in math mode

by regonly-noreply@…, 15 years ago

Attachment: rus-math.tex added

Hand-made TeX example, not imported from LyX

comment:8 by forenr@…, 15 years ago

Note that the bug discussed here is not due to \lyxmathsym per se. If this
had been the case, it would have been solved by simply using
\renewcommand{\lyxmathsym}{}
in the user preamble. The bug is instead due to the fact that the package
mathtext should be loaded immediately before the LyX generated preamble.
There are a number of bugs related to this problem, e.g., #991, #5031,
and #5366.

Now this specific bug (cyrillic letters must be italic in math) is solved and
mathtext is not needed anymore.

comment:9 by regonly-noreply@…, 15 years ago

Enrico, you wrote: “...(cyrillic letters must be italic in math)...”.

Not MUST be italic in math --- they MAY be italic, or slanted, or another ---
as user want! It must be POSSIBILITY TO CHANGE the font, and imho the behavior
in LyX must be the same as in TeX editors to be clear for user :—)

Best regards, neGODnick

comment:10 by forenr@…, 15 years ago

This is already the case. If you want them slanted, then put the line
\renewcommand{\lyxmathsym}{\@ifstar{\lyxm@thsym\textsl}{\lyxm@thsym\textrm}}
in the user preamble (this works with the previous patch applied).
But you can even switch their shape multiple times in the same document.

by forenr@…, 15 years ago

Attachment: bug5836c.lyx added

LyX document (brief tutorial on \lyxmathsym)

by milde@…, 15 years ago

Attachment: cyrillic-in-math.lyx added

How to input cyrillic chars in a formula with LyX 1.6.1

comment:11 by milde@…, 15 years ago

According to [1], "In all cases when Cyrillic letters are used in mathematics
they should be typed using the upright shape to distinguish them from the
Latin letters with a similar shape."

This would mean that by default, Cyrillic letters (like hebrew ones)
should not have the "mathalpha" feature.

[1] Russian Typographical Traditions in Mathematical Literature

Valentin Zaitsev, Andrew Janishewsky, Alexander Berdnikov,
EuroTEX´99 Proceedings, 1999.
http://www.uni-giessen.de/partosch/eurotex99/zaitsev.pdf

comment:12 by milde@…, 15 years ago

Cc: milde@… added

by milde@…, 15 years ago

Attachment: cyrillic-in-math.2.lyx added

fixed version + additional reference

comment:13 by milde@…, 15 years ago

attachments.isobsolete: 01

comment:14 by forenr@…, 15 years ago

Note that, by default, TeX doesn't follow Russian conventions and letters are
typeset in italic in math. By marking as "mathalpha" Cyrillic letters, it is
easy to make them the way one wants, as requested in comment 11 and as
explained in comment 12. The moment the \lyxmathsym macro comes into one's
way, it can be redefined in the preamble as
\renewcommand{\lyxmathsym}{\@ifstar{}{}}
and it will be as it was not there. So the way things are now, one has maximum
flexibility. For example, nobody stops you from using \text, \textit, \textsl
and company for getting things as you want them without having to deal with
\lyxmathsym. AFAIC, this is a non-issue.

comment:15 by g.mildexxx@…, 15 years ago

Subject: Re: Cyrillic formatted text in mathmode

Note that, by default, TeX doesn't follow Russian conventions and
letters are typeset in italic in math.

Russion conventions on this are in line with international conventions as
outlined in e.g. ISO 31, by the International Bureau of Weights and
Measures (BIPM) <http://www.bipm.org/en/si/si_brochure/> or the American
NIST <http://physics.nist.gov/Document/typefaces.pdf>:

Whether a letter in a math formula is typeset upright or italic depends
on its meaning and the context.

In short:

italic

is used for one-character symbols for variable values
taken from the Latin and Greek alphabet,


roman

is used for explanatory text, abbreviations and acronyms.

Usually, Russian mathematicans use Cyrillic letters for the second task
only and Latin and Greek for variable symbols.
(This is also the case in the example documents in the attachments.)

OTOH, by default, (La)TeX

a) does not accept Russian letters in math at all.
b) Latin letters (a-zA-Z) and small Greek letters are typeset italic,
c) capital Greek letters are typeset upright (roman).

(This is not in line with international conventions.)


d) provides the \mathrm, \mathit, ... commands for styling Latin chars.

By marking as "mathalpha" Cyrillic letters,

...

they are typeset as italic by default,

However, the default should correspondent to the most needed use case -
which for Cyrillic letters means "typeset upright". This way,
abbreviations like E_пот or acronyms like НОД (GCD) come out in the
preferred typeface by default.

"mathalpha" should be reserved for Greek and Latin, while Cyrillic
letters should be handled like Armenian, Georgian, Hebrew, Arab,
Devanagari, ...

comment:16 by forenr@…, 15 years ago

I think that the devel list is the right forum for discussing this.
If you are concerned about the default italic shape for Cyrillic letters,
please bring the discussion there. I have no strong opinion on this and
it boils down to simply taking away the "mathalpha" flag from unicodesymbols.

comment:17 by Enrico Forestieri, 15 years ago

Keywords: fixedintrunk removed
Resolution: duplicate
Status: newclosed

I am marking this bug as a duplicate of #5031 as the problem is not due to the \lyxmathsym macro per se but to the impossibility of inserting user commands before the LyX generated preamble.

Note: See TracTickets for help on using tickets.