24

I realize similar questions have been asked before but I am not satisfied with any of the answers I've seen. I would like to use the Cyrillic letter Ш to denote a particular group in mathematics. Most solutions involve using OT2 or T2A encoding; for example, at http://math.berkeley.edu/~vojta/tex/samp-l/sha.html. However, this makes the other text in the document look bad.

For example, using the solution above, I get

enter image description here

while I would like to have

enter image description here

The first seems to be shaded strangely and the characters don't seem to align right.

Does anyone know how I can write the character Ш (in math mode) without changing the default font for the rest of the text?

10
  • Welcome to TeX.SX! Did you see tex.stackexchange.com/questions/14633/…? The "shading" is probably due to the fact that you don't have the Type1 Cyrillic font. What TeX distribution are you using?
    – egreg
    Jul 19, 2013 at 20:13
  • @egreg Hi egreg, I did see that but I'm not completely satisfied. I would really like to use the default text, and the code there changes it to something quite like the first image. I am using MikTeX 2.9. Thank you!
    – user33931
    Jul 19, 2013 at 20:17
  • The quality of the image is not really good. Can you add a minimal example of code?
    – egreg
    Jul 19, 2013 at 20:18
  • @egreg I am using the code from math.berkeley.edu/~vojta/tex/samp-l/sha.html
    – user33931
    Jul 19, 2013 at 20:20
  • I don't see any blurring or "shading", both with Vojta's code and mine. Did you install the CM-Super package (for the T2A solution)? I really don't know what MiKTeX package provides the Type1 fonts for OT2.
    – egreg
    Jul 19, 2013 at 20:27

4 Answers 4

28

for someone who wants to use just one or two cyrillic letters in math, in a computer modern setting, the old wncy fonts are still distributed in tex live as part of the amsfonts collection, in type 1 format. (but they don't require use of the amsfonts package.)

this is the recommendation in the ams author faq.

I want to use some cyrillic letters for math variables, but there isn't any LaTeX support for cyrillic in the AMSfonts packages. How do I do it?

The following four lines will load the upright cyrillic font and define \Sh to access the letter "Sha".

    \DeclareFontFamily{U}{wncy}{}
    \DeclareFontShape{U}{wncy}{m}{n}{<->wncyr10}{}
    \DeclareSymbolFont{mcy}{U}{wncy}{m}{n}
    \DeclareMathSymbol{\Sh}{\mathord}{mcy}{"58} 

The location of a cyrillic letter in the wncyr font can be found by looking at the chart in the AMSFonts User's Guide or at a font chart created by TeXing the file testfont.tex (included in every TeX system).

the user's guide can be accessed with texdoc amsfonts or texdoc amsfndoc.

2
  • This is exactly what's done in math.berkeley.edu/~vojta/tex/samp-l/sha.html that the OP linked, with the only difference that the U encoding is used instead of OT2.
    – egreg
    Jul 20, 2013 at 7:06
  • 5
    @egreg -- true, but this doesn't require fontenc. (some of us still live and work in the "dark ages".) Jul 20, 2013 at 13:41
2

In a modern TeX installation, and if you want to use any other font, you either want to declare your symbol font in TU/Unicode (where it is in the slot "0448) or, if you are using 8-bit legacy fonts, in the T2A encoding (where it is in slot "F8). This should have character class mathalpha if it should be a letter, or mathop if it is supposed to be typeset like ln x.

Another approach that works regardless of what encoding you use is to wrap an arbitrary text command inside \text from amsmath.

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}

\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{CMU Serif}[Scale = 1.0]

\newcommand\sh[1]{\ensuremath{\mathop{\text{\normalfont ш}}#1}}

\begin{document}
\[ \sh(x), \sh y
\]
\end{document}

Font sample

This is a little more complicated in PDFTeX, but still works transparently with any font. For example, \usepackage{type1ec} to use CM-Super, or \usepackage{cmlgc} to use CM extended, or the font of your choice.

\documentclass{article}
\usepackage[T2A, T1]{fontenc}
\usepackage[utf8]{inputenc} % The default since 2018.
\usepackage{amsmath}

\newcommand\sh[1]{\ensuremath{\mathop{\text{\normalfont\fontencoding{T2A}\selectfont ш}}#1}}

\begin{document}
\[ \sh(x), \sh y
\]
\end{document}

PDFTeX font sample

2
  • Why does \sh take an argument? That doesn't seem to be necessary at all. Dec 30, 2019 at 3:24
  • @HenriMenke You’re right, you could eliminate it.
    – Davislor
    Dec 30, 2019 at 3:53
1

This works!

%Sha:
\usepackage[OT2,T1]{fontenc}
\DeclareSymbolFont{cyrletters}{OT2}{wncyr}{m}{n}
\DeclareMathSymbol{\Sha}{\mathalpha}{cyrletters}{"58}
%end of Sha
0

One hack could be to use:

\newcommand{\Sha}{\textls[0]{III}}

Which reduces the width between "I" characters and looks close enough. Just putting it out there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .