# Verbatim does not work latex [duplicate]

I want a piece of code to be monospaced. So I do the following. Commands are highlighted in Eclipse. But as soon as I type \verbatim all inside and the color of the command itself become gray.

\begin{verbatim}

public class main {
public statik void main (string[] args){
for(int i = 0; i < arg.length; i ++){
System.out.println(args[i]);
}
}
};

\end{verbatim}


The following packages are included. \usepackage{verbatim} \usepackage{alltt}

What am I doing wrong?

## migrated from stackoverflow.comFeb 19 '14 at 17:08

This question came from our site for professional and enthusiast programmers.

• Could you provide a Minimum Working Example (MWE)? – herohuyongtao Feb 18 '14 at 11:32

In order to use verbatim you don't have to use any packages, the code below works for me.

\documentclass[10pt]{article}

\begin{document}

\begin{verbatim}

public class main {
public static void main (string[] args){
for(int i = 0; i < arg.length; i ++){
System.out.println(args[i]);
}
}
};

\end{verbatim}

\end{document}


I am using miktex in windows.