0

This question already has an answer here:

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?

marked as duplicate by egreg, Peter Jansson, Werner, Speravir, jub0bs Feb 19 '14 at 19:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Feb 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
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.