
Como usar mais de um idioma no XeLaTeX dentro do \alltt
ambiente?
Tenho problemas para fazer isso usando babel e compilar com pdfLaTeX
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{alltt}
\begin{document}
\begin{alltt}
this is a test
\foreignlanguage{greek}{αυτό είναι μια δοκιμή}
\end{alltt}
\end{document}
mas se eu tentar algo semelhante ao compilar com XeLaTeX: (veja exemplo em ShareLateX) o texto em grego não aparece no pdf compilado
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{alltt}
% Times New Roman
\setmainfont[BoldFont=timesbd.ttf, ItalicFont=timesi.ttf, BoldItalicFont=timesbi.ttf
]{times.ttf}
\begin{document}
\begin{alltt}
this is a test
αυτό είναι μια δοκιμή
\end{alltt}
\end{document}
Responder1
Você deve definir uma fonte monoespaçada com caracteres gregos. Por exemplo
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{alltt}
\setmainfont[
Extension=.ttf,
UprightFont=*,
BoldFont=*bd,
ItalicFont=*i,
BoldItalicFont=*bi,
]{times}
\setmonofont{cmuntt.otf} % or any other monospaced font supporting Greek
\begin{document}
\begin{alltt}
this is a test
αυτό είναι μια δοκιμή
\end{alltt}
\end{document}