1

I want to use verbatim to type both English and Russian in the same block.

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

\begin{document}

\begin{verbatim}
Hello - привет
\end{verbatim}

This doesn't work, on the PDF the Russian part is blank, and when I copy it shows these question marks:

Hello - ������

Russian text works fine in the rest of the document, it seems only to be in verbatim that it doesn't. I'm using LuaLaTex on Overleaf, and have tried the other options available and they messed things up even more with the rest of the document, so a solution with LuaLaTex would be ideal. Does anyone have any suggestions?

1
  • 1
    if you are using lualatex you shouldn't use T1 and T2A and fontenc and inputenc. Aug 30, 2021 at 7:59

1 Answer 1

2

It works fine if you setup a mono font which supports russian:

\documentclass{article}
\usepackage[russian, english]{babel}
\usepackage{fontspec}
\setmainfont{dejavuserif}
\setmonofont{dejavusansmono}
\begin{document}

Hello - привет

\begin{verbatim}
Hello - привет
\end{verbatim}
\end{document}

enter image description here

1
  • Thank you very much @Ulrike, I don't know why I didn't realise it was a font issue. Simply changing the monofont as you advised has solved it
    – Joseph
    Aug 30, 2021 at 8:23

You must log in to answer this question.

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