[Tex/LaTex] Insert symbols inside verbatim mode LaTeX

math-modesymbolsverbatim

I cannot insert mathematics symbols inside a verbatim mode in LaTeX.
This how I do:

\usepackage{alltt}

 \begin{verbatim}

 1- Train triggers model \(  X_{i}  \)  -> Y_j (X_i: source phrase
 composed of i words, Y_j : target phrase composed of j words

 \end{verbatim}

Any ideas?

Best Answer

Just to give Bakuriu's comment as an answer and extend it a bit:

\documentclass{article}

\usepackage{alltt}

\begin{document}

\begin{alltt}
1- Train triggers model \(X\sb{i} \to Y\sb{j}\) (\(X\sb{i}\): source phrase
composed of \(i\) words; \(Y\sb{j}\): target phrase composed of \(j\) words)
\end{alltt}
or
\begin{alltt}
1- Train triggers model \(X\sb{i}\,\to\,Y\sb{j}\) (\(X\sb{i}\): source phrase
composed of \(i\) words; \(Y\sb{j}\): target phrase composed of \(j\) words)
\end{alltt}
or
\begin{alltt}
1- Train triggers model \(X\sb{i}\to{Y\sb{j}}\) (\(X\sb{i}\): source phrase
composed of \(i\) words; \(Y\sb{j}\): target phrase composed of \(j\) words)
\end{alltt}

\end{document}

output

Note the differences in spacing around \to in the three approaches.

Note: See http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/base/alltt.pdf for the implementation of the package and a few 'HowTo's.

Related Question