Verbatim alignment in XePersian

Verbatim environment is right-aligned when using XePersian package, so I have to wrap it in latin environment. So I decide to create a new environment:

\newenvironment{faverbatim}
{\begin{latin}‎‎\begin{verbatim}‎}
{‎\end{verbatim}‎‎\end{latin}‎ }


Unfortunately it generates an error.

You can't use \begin{verbatim} and \end{verbatim} in arguments to other commands (in this case \newenvironment).

The package \verbatim allows to overcome this limitation:

\usepackage{verbatim}
\newenvironment{faverbatim}
{\latin\verbatim}
{\endverbatim\endlatin}


Notice that the "internal" versions of the commands should be used.

• Thanks, can you please explain which commands can be used in \newenvironment and which one can't? – PHPst Sep 21 '12 at 11:37
• \begin{verbatim} is the exception, in general. However the situation is a bit different when using the verbatim package for defining a new verbatim environment; read the manual for the package: either do texdoc verbatim in a terminal window or click here – egreg Sep 21 '12 at 12:02