1

So I have been trying to add the Russian language to a template from Overleaf. Which has a custom class that looks like this:

\ProvidesClass{clean_cv}[2021/07/28 v1.0.0 'CleanCV' Class]

\LoadClass[11pt]{article}

\RequirePackage[margin=0.3in]{geometry} % half-inch margins \RequirePackage{microtype} \RequirePackage{fancyhdr} \RequirePackage{titlesec} \RequirePackage{array} \RequirePackage{xcolor} \RequirePackage{xpatch} \RequirePackage{enumitem}

% Load fonts \RequirePackage[fixed]{fontawesome5} \RequirePackage[scaled=.9,osf]{XCharter} \linespread{0.92}

% Load biber \RequirePackage[backend=biber,sorting=ydnt,block=none,bibstyle=nature,doi=false,isbn=false,url=false]{biblatex}

\RequirePackage[hidelinks]{hyperref}

\DeclareSourcemap{ \maps[datatype=bibtex]{ \map[overwrite]{ \step[fieldsource=date, match=\regexp{(\d{4})}, fieldset=keywords, fieldvalue={YEAR-$1}, append, ] } \map[overwrite]{ \step[fieldset=note, null] } }}

% \RequirePackage[T2A]{fontenc} % \RequirePackage[utf8]{inputenc} % \RequirePackage[russian]{babel} \AtBeginBibliography{\vspace*{-2em}}

%----------------------------------------------------- % Bold one author's name % https://tex.stackexchange.com/a/73246, CC-BY-SA 3.0 \def\makenamesetup{% \def\bibnamedelima{ }% \def\bibnamedelimb{ }% \def\bibnamedelimc{ }% \def\bibnamedelimd{ }% \def\bibnamedelimi{ }% \def\bibinitperiod{.}% \def\bibinitdelim{ }% \def\bibinithyphendelim{.-}}
\newcommand*{\makename}[3]{\begingroup\makenamesetup\xdef#1{#2, #3}\endgroup}

\newbibmacro*{name:bold}[2]{% \makename{\currname}{#1}{#2}% \makename{\findname}{\lastname}{\firstname}% \makename{\findinit}{\lastname}{\firstinit}% \ifboolexpr{ test {\ifdefequal{\currname}{\findname}} or test {\ifdefequal{\currname}{\findinit}} }{\bfseries}{}}

\newcommand*{\highlightauthorname}[3]{% \def\lastname{#3}% \def\firstname{#1}% \def\firstinit{#2}}

\xpretobibmacro{name:family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:given-family}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:family-given}{\begingroup\usebibmacro{name:bold}{#1}{#2}}{}{} \xpretobibmacro{name:delim}{\begingroup\normalfont}{}{}

\xapptobibmacro{name:family}{\endgroup}{}{} \xapptobibmacro{name:given-family}{\endgroup}{}{} \xapptobibmacro{name:family-given}{\endgroup}{}{} \xapptobibmacro{name:delim}{\endgroup}{}{} %------------------------------------------------------ \newcommand{\printbibyear}[1]{\printbibliography[heading=none,keyword=YEAR-#1]\vspace*{-2.5em},}

\definecolor{dateline}{gray}{0.5} \definecolor{datecolor}{gray}{0.4} \newcolumntype{R}{>{\raggedleft\arraybackslash}p{4em}} \newcommand{\daterule}{\color{dateline}\vrule width 1pt} \newcommand{\dateentry}[2]{{\leavevmode\color{datecolor}{#1}} & #2 \ \noalign{\medskip}} %\dimexpr(\textwidth - #1)\relax \newenvironment{datetabular}[1]{% \begin{tabular}{@{}>{\raggedleft\arraybackslash}p{#1}!{\daterule}p{\dimexpr(\linewidth - #1 - 1em)\relax}}% }{% \end{tabular}% }

\newcommand{\faCenter}[1]{\raisebox{-2pt}{\faIcon{#1}}} \newcommand{\faCenterStyle}[2]{\raisebox{-2pt}{\faIcon[#1]{#2}}}

\titleformat{\section}[display]{\large\bfseries}{}{0pt}{}[\vspace{-10pt}\rule{\linewidth}{1pt}] \titlespacing*{\section}{0pt}{0em}{0.4em}

\setlength\parindent{0pt} \setlength\parskip{0pt}

\setlist{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt} \newcommand{\eatvspace}{\vspace*{-1.5em},}

\newcommand*{\headlineposition}[1]{\def@headlineposition{#1}}

\let@author@empty \let@headlineposition@empty

\renewcommand{\maketitle}{% \begin{center} \ifx@author@empty\else{ \Huge @author} \\fi \ifx@headlineposition@empty\else\vspace{4pt} {\itshape @headlineposition}\fi \end{center}% \vspace{-17.2pt} \rule{\linewidth}{1pt} }

\pagestyle{empty}

I followed the Overleaf tutorial on adding Russian to latex and added these lines into my .tex file.

\documentclass{clean_cv}
%Russian-specific packages
%--------------------------------------
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
%--------------------------------------

%Hyphenation rules %-------------------------------------- \usepackage{hyphenat} \hyphenation{ма-те-ма-ти-ка вос-ста-нав-ли-вать}

\author{ASDXCASD ФЫВФЫВ} \headlineposition{ASDASD ФЫВФЫВ} \begin{document}

\maketitle

\end{document}

But then it gave me these errors:

Font T2A/XCharter-TOsF/m/it/10.95=XCharter1-Italic-tosf-t2a at 9.85492pt not loadable: Metric (TFM) file not found.
<to be read again> 
                   relax 
l.22 \maketitle

I wasn't able to read the size data for this font, so I will ignore the font specification. [Wizards can fix TFM files using TFtoPL/PLtoTF.] You might try inserting a different font spec; e.g., type `I\font<same font id>=<substitute font name>'.

pdfTeX error (font expansion): invalid font identifier. MT@font ->T2A/XCharter-TOsF/m/it/10.95

l.22 \maketitle

How can I fix this error? Is this the correct way of adding Russian support into this custom class?

Raguel
  • 113

1 Answers1

2

I think it's a packaging error of the maintainer of XCharter. On my machine, where I keep TeX Live from the 2012 release, I get

> locate XCharter1-Italic-tosf-t2a.tfm
/usr/local/texlive/2017/texmf-dist/fonts/tfm/public/xcharter/XCharter1-Italic-tosf-t2a.tfm
/usr/local/texlive/2018/texmf-dist/fonts/tfm/public/xcharter/XCharter1-Italic-tosf-t2a.tfm
/usr/local/texlive/2019/texmf-dist/fonts/tfm/public/xcharter/XCharter1-Italic-tosf-t2a.tfm
/usr/local/texlive/2021/texmf-dist/fonts/tfm/public/xcharter/XCharter1-Italic-tosf-t2a.tfm

> locate XCharter1-Italic-tosf-t2a.vf /usr/local/texlive/2017/texmf-dist/fonts/vf/public/xcharter/XCharter1-Italic-tosf-t2a.vf /usr/local/texlive/2018/texmf-dist/fonts/vf/public/xcharter/XCharter1-Italic-tosf-t2a.vf /usr/local/texlive/2019/texmf-dist/fonts/vf/public/xcharter/XCharter1-Italic-tosf-t2a.vf /usr/local/texlive/2021/texmf-dist/fonts/vf/public/xcharter/XCharter1-Italic-tosf-t2a.vf

so you see that in TeX Live 2020 (which is used by Overleaf) the font is missing. It's too late for updating it, because TeX Live 2020 is frozen, but you might compile with TeX Live 2018 (I believe it's possible with Overleaf).

By the way, compilation with TeX Live 2019 and 2021 fails with

! TeX capacity exceeded, sorry [max level recursion of virtual fonts=10].
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox
                                                  \fi \fi

A workaround is to remove the osf option, without which the test works with every version of TeX Live I have that supports XCharter (in particular TL 2020).

A bug report has been filed with the maintainer, but there is no chance to get this working with TeX Live 2020 (without heavy work on your side).

egreg
  • 1,121,712
  • I found out that issue was with XCharter I commented it out everything started to work great again, but the font has changed. – Raguel Sep 12 '21 at 16:51
  • 1
    @Raguel Maybe you can just remove the osf option, if you want to keep XCharter – egreg Sep 12 '21 at 19:32