[Tex/LaTex] Cyrillic on Ubuntu Precise

fonts

Background

I'm using Ubuntu Precise with the standard repository packages rather than a manually installed TeXLive. I'm trying to include some Cyrillic in the bibliography of a paper which I'm compiling with pdflatex, following the advice of egreg that the best option is to use

\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

But even a very simple test case

\documentclass[a4paper]{article}

\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,english]{babel}

\begin{document}
Testing \foreignlanguage{russian}{Обмен шифрами}
\end{document}

gives errors:

This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(./minimum.tex
LaTeX2e <2009/09/24>

  <snip>

kpathsea: Running mktextfm larm1000
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000
/usr/bin/mktextfm: 96: /usr/bin/mktextfm: mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000: not found
grep: larm1000.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000' failed to make larm1000.tfm.
kpathsea: Appending font creation commands to missfont.log.

! Font T2A/cmr/m/n/10=larm1000 at 10.0pt not loadable: Metric (TFM) file not fo
und.
<to be read again> 
                   relax 
l.8 ...anguage{russian}{Обмен шифрами}

I think the only relevant extra information from minimum.log is

LaTeX Font Info:    Try loading font information for T2A+cmr on input line 7.

(/usr/share/texmf-texlive/tex/latex/cyrillic/t2acmr.fd
File: t2acmr.fd 2001/08/11 v1.0a Computer Modern Cyrillic font definitions
)
LaTeX Font Info:    ... okay on input line 7.
! Font T2A/cmr/m/n/10=larm1000 at 10.0pt not loadable: Metric (TFM) file not fo
und.

Extra details

I don't understand all the levels of indirection, but in an attempt to track them down I ran

$ grep -rE "\blarm([^0-9]|1000)" /usr/share/tex* 2>/dev/null
Binary file /usr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb matches
/usr/share/texmf/fonts/map/dvips/cm-super/cm-super-minimal-t2a.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/scripts/pkfix/pkfix.pl:#       same type 1 font, eg. (ecrm1000, larm1000) -> SFRM1000.
/usr/share/texmf-texlive/tex/latex/cyrillic/t2acmr.fd:\EC@family{T2A}{cmr}{m}{n}{larm}
/usr/share/texmf-texlive/doc/fonts/lh/fonttest/allenc0.tex:\FontPage {larm1000}
/usr/share/texmf-texlive/doc/fonts/lh/fonttest/allenc2.tex:\FontPage {larm1000}
/usr/share/texmf-texlive/doc/generic/t2/examples/example2.tex:\font\larm=larm1000    % Set the default font --- Cyrillic
/usr/share/texmf-texlive/doc/generic/t2/examples/example2.tex:\larm                  % T2A encoded Computer Modern font.
/usr/share/texmf-texlive/fonts/map/dvips/updmap/psfonts.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/dvips/updmap/psfonts_t1.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/dvips/updmap/ps2pk.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/fontname/special.map:larm            lh              lh-t2a
/usr/share/texmf-texlive/fonts/map/pdftex/updmap/pdftex_ndl14.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/pdftex/updmap/pdftex.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/pdftex/updmap/pdftex_dl14.map:larm1000 SFRM1000 "T2AEncoding ReEncodeFont" <cm-super-t2a.enc <sfrm1000.pfb
/usr/share/texmf-texlive/fonts/map/dvipdfm/updmap/dvipdfm_dl14.map:larm1000 cm-super-t2a sfrm1000 -r
/usr/share/texmf-texlive/fonts/map/dvipdfm/updmap/dvipdfm_ndl14.map:larm1000 cm-super-t2a sfrm1000 -r
/usr/share/texmf-texlive/fonts/map/dvipdfm/updmap/dvipdfm.map:larm1000 cm-super-t2a sfrm1000 -r

I have /usr/share/texmf/fonts/type1/public/cm-super/sfrm1000.pfb and /usr/share/texmf/fonts/enc/dvips/cm-super/cm-super-t2a.enc from Ubuntu package cm-super-minimal, so I think that I have the source files and am just missing some files to tie it all together.

Question

I'm not too fussed about fixing the underlying problem – it's a bit late to propose a patch for Precise, because it's in support mode now. But how can I obtain or generate the files which I'm missing, and get my document to compile and display the Cyrillic text?

Best Answer

pdflatex is actually trying to create the missing files, but there's some permissions issue. I don't know how to fix the real problem, but there are two workarounds which will allow you to compile your document.

The clue

The error messages talk about mktextfm larm1000. If you try to run that command directly from the shell, you get the same errors:

mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000
/usr/bin/mktextfm: 96: /usr/bin/mktextfm: mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000: not found
grep: larm1000.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input larm1000' failed to make larm1000.tfm.

Workaround 1

If you sudo it, it will succeed, even though the files which it writes are in ~/.texmf-var and it shouldn't obviously need any privileges beyond those which you have.

Workaround 2

The error messages also show that mktextfm is trying to run

mf-nowin -progname=mf "\mode:=ljfour; mag:=1; nonstopmode; input larm1000"

You can run that without sudo; it will create ~/.texmf-var/fonts/source/lh/lh-t2a/larm1000.mf as well as ./larm1000.600gf, ./larm1000.log, and ./larm1000.tfm. pdflatex will now compile your document. However, it's a good idea to

mv ./larm1000.tfm ~/.texmf-var/fonts/tfm/lh/lh-t2a/

because otherwise you may run into the same problem in future if you try to compile documents with Cyrillic from a different working directory.