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?

4

1 回答 1

6

Haskell wiki建议定义一个 LaTeX 宏,如:

\long\def\ignore#1{}

你也可以定义这个\newcommand,对我来说,这似乎更自然:

\newcommand{\ignore}[1]{}

在这两种情况下,它都是这样使用的:

\ignore{

> import Foo.Bar (baz)

}

`

于 2013-05-09T23:35:52.500 回答