4

I'm writing a program in a .lhs file which contains code in Haskell (I'm specifying this because I want it to be clear that it's not only for rendering a pdf but it's also for being execute with runhaskell or ghci). I'm rendering the code with lstlisting like this:

\begin{lstlisting}

> Haskell code here

\end{lstlisting}

Anyway, the code itself require some modules that I have to import, but I don't want the imports to appear in the resulting pdf. So, I've tried to put the code without the lstlisting block, like this:

> import X
> import Y
...

But it's not working and the resulting PDF renders those lines only not as code like lstlisting would do. What should I do to write the import code only for being execute but not to be showed in the PDF itself?

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Jcao02
  • 794
  • 8
  • 24

1 Answers1

6

The Haskell wiki suggests defining a LaTeX macro like:

\long\def\ignore#1{}

You could also define this with \newcommand which, to me, seems more natural:

\newcommand{\ignore}[1]{}

In both cases, it is used like this:

\ignore{

> import Foo.Bar (baz)

}

`

AndrewC
  • 32,300
  • 7
  • 79
  • 115
Tikhon Jelvis
  • 67,485
  • 18
  • 177
  • 214