TransWikia.com

Change Font for a newcommand (cyrilic)

TeX - LaTeX Asked on August 7, 2021

I had to

I had to define (because of beamer and interference with other languages) the environment for Cyrillic. How can I now make the Cyrillic appear in a nicer Cyrilic font?

MWE:

documentclass{article}
usepackage[utf8]{inputenc}

usepackage[OT2, T1]{fontenc}
newcommand{textcyr}[1]{
{donothyphenatefontencoding{OT2}selectfont #1}}
newlanguagenohyphensnewcommand{donothyphenate}{
language=nohyphens}

begin{document}

Russia textcyr{izmenitp1}  emph{izmenit} (tr.) ‘change’ 
 
end{document}```

2 Answers

I'd use babel for disabling hyphenation, but your method is good as well.

The key is to use the font family wncyr that has Type1 fonts compatible with Computer Modern, if you're tied to transliterated input.

documentclass{article}
usepackage[base]{babel}

usepackage[OT2, T1]{fontenc}

DeclareFontFamilySubstitution{OT2}{cmr}{wncyr}
newcommand{textcyr}[1]{%
  begin{hyphenrules}{nohyphenation}%
    fontencoding{OT2}selectfont #1%
  end{hyphenrules}%
}

begin{document}

Russian textcyr{izmenitp1} emph{izmenit} (tr.) ‘change’

end{document}

enter image description here

Correct answer by egreg on August 7, 2021

The approach in https://tex.stackexchange.com/a/215454/ works also for beamer. I'm not sure this fits your requirements but maybe it can be a starting point. The font is similar to Times. The MWE below shows sans serif (default in beamer) and serif (using the rmfamily font switch).

documentclass{beamer}
usepackage[utf8]{inputenc}
usepackage[T1,T2A]{fontenc}
usepackage{paratype}
usepackage{tgpagella}
usepackage[russian]{babel}
usepackage{substitutefont}
substitutefont{T2A}{rmdefault}{PTSerif-TLF}
begin{document}
begin{frame}{Russian in texttt{beamer}}
Russia изменить emph{izmenit} (tr.) ‘change’ 

rmfamily Russia изменить emph{izmenit} (tr.) ‘change’
end{frame}
end{document}

Result:

enter image description here

Note that you have the option of choosing an arbitrary font if you use XeLaTeX or LuaLaTeX, see for example the second part of the answer in Change font in Beamer to a more modern, sleek font.

Answered by Marijn on August 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP