[Tex/LaTex] Environment code undefined

codeverbatim

Why do I get ! LaTeX Error: Environment code undefined. when I use:

\documentclass[10pt,a4wide]{article}
\usepackage{a4wide}
\usepackage[utf8]{inputenc}
\usepackage[portuguese]{babel}
\usepackage{graphicx}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}

\begin{document}
\begin{minipage}{7cm}  

\begin{code}  

module Dir where

import TeX
import Data.List

\end{code}

\end{minipage}\hfill
\begin{minipage}{7cm}

\begin{code}

module DirV where

import TeX
import Data.List

\end{code}

\end{minipage}

With code

With verbatim

Best Answer

You don't have an environment called code. If you are trying to print code, you might be interested in the verbatim environment, or other pretty-printing environments/packages. See Print programs with its proper syntax.

Wrapping your code snippet into a minimal compiling document using verbatim, it produces the following output:

enter image description here

\documentclass{article}
\begin{document}
\begin{minipage}{7cm}%
\begin{verbatim}
module Dir where

import TeX
import Data.List
\end{verbatim}
\end{minipage}\hfill
\begin{minipage}{7cm}%
\begin{verbatim}
module DirV where

import TeX
import Data.List
\end{verbatim}
\end{minipage}
\end{document}
Related Question