Hi I have installed the listings package in order to display my code. I am running the following code within my document:
\begin{lstlisting}
public static void main(String[] args) {
System.out.println("Hello World");
}
\end{lstlisting}
But that is giving me the following error:
! LaTeX Error: Environment lstlisting undefined.
I have mentioned \usepackage{listings} so I really dont know what the problem can be. Would anyone be kind enough to help or guide me the right way?
EDIT: Minimum working example:
\documentclass[a4paper,12pt]{book}
\usepackage{times,a4wide}
\usepackage{graphicx}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
public static void main(String[] args) {
System.out.println("Hello World");
}
\end{lstlisting}
\end{document}
\documentclass{...}and ending with\end{document}. – egreg Apr 30 '13 at 00:07\usepackageI had to synchronize MiKTeX – Mario S. E. Apr 30 '13 at 00:09listingsenvironment commented. check for any other errors – Mario S. E. Apr 30 '13 at 00:15listings', but the package provideslisting'. – M9A Apr 30 '13 at 00:17verbatimenvironment (\begin{verbatim} your code \end{verbatim}). However, there must be a reason why you are having this problem – Mario S. E. Apr 30 '13 at 00:27\usepackage{listings}– Charlie Parker Feb 23 '22 at 18:29