2

Note: Please scroll down and see the UPD 2, which clarifies the problem.

I need to use \texttt (or even \verbatim) in my presentation. Unfortunately, it looks like it doesn’t work with beamer at all.

MWE:

\documentclass{beamer}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\begin{document}
    \begin{frame}[fragile]
        \frametitle{English + русский}
            English is okay.
            Русский работает.
%            \texttt{English} is not okay.
%            \verb+Русский+ не работает.
    \end{frame}
\end{document}

If I the uncomment the first commented line with \texttt{English}, the document does not compile. The error is

Font T2A/cmtt/m/n/10.95=latt1095 at 10.95pt not loadable: Metric (TFM) file not found.

If I the uncomment the second commented line with \verb..., the document does not compile. The error is

File ended while scanning use of \next.

I am using TexLive on OS X 10.11 with all packages (including cm-super) installed and updated. Compiling the same document with \documentclass{article} (and deleting frame environment with \frametitle, of course) works great.

P.S. Please do not try offering XeLaTex, because I have to rely on pdftex.

P.P.S. After playing around for approx. an hour, I found that \documentclass[10pt]{beamer} or other variants like \documentclass[12pt]{beamer}may help, but it looks more as a hack, than as a solution.


UPD:

The problem with verbatim, fragile and spaces is solved, but the main problem remains. The code from cfr’s answer still gives me an error

Font T2A/cmtt/m/n/10.95=latt1095 at 10.95pt not loadable: Metric (TFM) file not found. \verb

So my question is about dealing with \texttt in beamer.


UPD 2:

Compiling the following MWE (a bit edited variant of cfr’s answer)

\documentclass{beamer}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american,russian]{babel}
\newcommand*\texteng[1]{\foreignlanguage{american}{#1}}
\begin{document}
\begin{frame}[fragile]
  \frametitle{English + русский}
  \texteng{English is okay.} \\
  Русский работает. \\
  \texteng{\texttt{English} is not okay.} \\
  \texttt{Русский} не работает. \\
\end{frame}
\end{document}

Provides this result:

No Cyrillic glyphs for \texttt

The errors and warnings are these:

Font T2A/cmtt/m/n/10.95=latt1095 at 10.95pt not loadable: Metric (TFM) file not found. \end{frame}
Font shape `T2A/cmss/m/n' in size <4> not available(Font) size <5> substituted
Size substitutions with differences(Font) up to 1.0pt have occurred.

The missfont.log file contains the following line:

mktextfm latt1095

And the main .log file can be seen here: http://pastebin.com/WUcU9Nv5.

As I mentioned before, all packages are installed, including cm-super, and TeXLive utility reports everything is up-to-date.

So there are no Cyrillic glyphs for \texttt, and the question is why?

  • Welcome! You need to change languages using the commands provided by Babel. You've set the document up to default to Russian. So you need to say when you are using something else. Babel provides both switches and commands for limited bits of text for many languages. If not or if you don't like the names it uses, you can spin your own. For example, \foreignlanguage{american}{text in US English}. – cfr Mar 23 '16 at 3:16
  • Actually, the error has nothing to do with English. I get the same error if I comment out everything but the line with \verb. – cfr Mar 23 '16 at 3:22
  • 1
    Can you try running from a shell the command mktextfm latt1095 and tell what happens? Also the output from tlmgr info lh, please – egreg Mar 24 '16 at 13:56
  • Output for mktextfm latt1095 can be found here: pastebin.com/hhYj8KFE. And here is the output for tlmgr info lh: pastebin.com/mWKJE4bk. – Eugene F Mar 24 '16 at 18:46
  • After running these commands the MWE from the UPD 2 compiled successfully! How did it happen? What was the problem with mktextfm? By the way, I still have the warnings mentioned in the UPD 2, but the problem is solved! If someone posts an answer explaining this workaround, I’ll have to accept it. – Eugene F Mar 24 '16 at 18:51
2

The problem actually causing the error is simply the space before \end{frame} which is not allowed when fragile is used.

However, text in English should be marked as such for Babel. Although it can cope with basic Latin script regardless, hyphenation and other niceties will be wrong.

\documentclass{beamer}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[american,russian]{babel}
\newcommand*\texteng[1]{\foreignlanguage{american}{#1}}
\begin{document}
\begin{frame}[fragile]
  \frametitle{English + русский}
  \texteng{English is okay.}
  Русский работает.
  \texteng{\texttt{English} is not okay.}
  \verb+Русский+ не работает.
\end{frame}
\end{document}

American English and Russian

  • Thank you for your answer! I missed the point with fragile and spaces, but the main problem remains. Your code still gives me an error Font T2A/cmtt/m/n/10.95=latt1095 at 10.95pt not loadable: Metric (TFM) file not found. \verb So now my question is about dealing with \texttt in beamer. – Eugene F Mar 23 '16 at 8:14
  • In that case, you are missing the relevant fonts and need to install them. I am guessing you are using MikTeX or the packages provided by a Linux distro in that case because a default TeX Live installation would provide them out-of-the-box. You need to install cm-super, I think. At least, that's what gets used when I compile this. You could alternatively tweak the \texteng macro to switch fonts and encoding (to T1 etc. explicitly) but installing the fonts will be the better option. (Or use fonts you know you have installed and use in other documents with the professional Beamer theme.) – cfr Mar 23 '16 at 12:41
  • As I mentioned in the original post, I am using TexLive on OS X 10.11 with all packages (including cm-super) installed and updated. Therefore, my question was how this can possible. – Eugene F Mar 23 '16 at 13:41
  • @EugeneF Then probably you should post the log file. But make sure that MacTeX is fully updated first. – cfr Mar 23 '16 at 13:56
  • Please see the second update of the question: I added the info from missfont.log and the link to the main .log file. – Eugene F Mar 24 '16 at 7:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.