# Verbatim and polyglossia

I use polyglossia in arabic tex files and I want to use the verbatim environment to write the Latex commands for a user's manual. All works well, with adding the command '\let\arabicfonttt\ttfamily' if we write english characters but it doesn't recognize I think the arabic character. How I can I fix it ? I give a simple example, where we can see that arabic letters are completely omitted.

\documentclass[12pt,a4paper]{article}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\let\arabicfonttt\ttfamily
\begin{document}

\begin{english}
\begin{verbatim}
The command \LaTeX prints the Latex logo.

أمر
\LaTeX
يعطي لوجو لاتخ
\end{verbatim}
\end{english}
\end{document}


One can see that only the word \LaTeX of

أمر

\LaTeX

يعطي لوجو لاتخ


is taken in account

• Besides \let\arabicfonttt\ttfamily you have to do \setmonofont{DejaVu Sans Mono} or any other monospaced font supporting Arabic. Oct 17, 2014 at 16:13

Besides \let\arabicfonttt\ttfamily you have to do \setmonofont{DejaVu Sans Mono} or any other monospaced font supporting Arabic.

\documentclass[12pt,a4paper]{article}

\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily
\begin{document}

\begin{english}
\begin{verbatim}
The command \LaTeX prints the Latex logo.

أمر
\LaTeX
يعطي لوجو لاتخ
\end{verbatim}
\end{english}
\end{document}


• It seems ok on a try file what I have done but there is still a problem : The arabic words must be in Right to left environment... we can solve this problem by doing two verbatim, one for arabic and it's written in Right to Left mode and one for english between \begin{english} and \end{english}... The question is : can we write an english sentence in Left to Right mode and an arabic one in Right to Left mode in the same verbatim ? Oct 17, 2014 at 22:14
• @FaouziBellalouna Sorry, but that's as much as I can help: my knowledge of Arabic doesn't go beyond the fact it's written right to left. Oct 17, 2014 at 22:15
• Ok the problem which remains is minor for me. Thanks Oct 17, 2014 at 22:25

We can do this with listings package, putting arabic words inside symbols defined with escapeinside like this :

\documentclass[12pt,a4paper]{article}
\usepackage{listings}
\usepackage{polyglossia}
\setmainlanguage[numerals=maghrib]{arabic}
\setotherlanguage{english}

\setmonofont{DejaVu Sans Mono}
\let\arabicfonttt\ttfamily

\lstset{language=[LaTeX]TeX,escapeinside={*}{*}}

\begin{document}

\begin{english}
\begin{lstlisting}
The command \LaTeX prints the Latex logo.
*\textarabic{أمر}*
\LaTeX
*\textarabic{يعطي لوجو لاتخ}*
\end{lstlisting}
\end{english}
\end{document}


and the result:

• This seems good two. Thks Nov 2, 2014 at 5:53