tools for writing papers

66 views
Skip to first unread message

Greg

unread,
Dec 10, 2011, 4:36:54 AM12/10/11
to Stanford CS240h 2011 Autumn
Hi,

I'm trying to get nice syntax-highlighted Haskell in my Latex document
without much luck. I don't think Pandoc can do it yet, I haven't been
successful with lhs2TeX, now I'm trying with lhs2TeX-hl.

Anyone have a workflow they like?

Greg

Greg

unread,
Dec 10, 2011, 8:19:05 PM12/10/11
to Stanford CS240h 2011 Autumn
I found the "minted" latex package is simple and works well. Get
the .sty file at http://code.google.com/p/minted/ (and you'll need to
apt-get install python-pygments)

I added this at the top of my .tex file:

\usepackage{minted}
\definecolor{frame_color}{gray}{0.70}
\addtolength\fboxsep{0.2cm}
\usemintedstyle{trac}
\newminted[code]{haskell}{frame=single, samepage=true, rulecolor=
\color{frame_color}}

and then where I want the code block put

\input{SomeCode.lhs}

where SomeCode.lhs is a literate haskell file that looks like this

% this is a literate haskell file
\begin{code}
f x = x + 1
\end{code}

then add -shell-escape to your pdflatex command

pdflatex -shell-escape mydoc.tex

and you're done

Greg

unread,
Dec 10, 2011, 8:33:19 PM12/10/11
to Stanford CS240h 2011 Autumn
sorry to spam

changing \usemintedstyle{trac} to \usemintedstyle{default} looks
better

On Dec 10, 5:19 pm, Greg <gregmainl...@gmail.com> wrote:
> I found the "minted" latex package is simple and works well.  Get

> the .sty file athttp://code.google.com/p/minted/(and you'll need to

Reply all
Reply to author
Forward
0 new messages