Latex style file for formatting/coloring clojure code?

496 views
Skip to first unread message

Mark Engelberg

unread,
Feb 16, 2014, 6:05:24 PM2/16/14
to clojure
I am unable to find a style file that supports clojure code in LaTeX.  Can anyone point me in the right direction?

Thanks,

Mark

Andy-

unread,
Feb 16, 2014, 10:03:02 PM2/16/14
to clo...@googlegroups.com
On Sunday, February 16, 2014 6:05:24 PM UTC-5, puzzler wrote:
I am unable to find a style file that supports clojure code in LaTeX.  Can anyone point me in the right direction?
Pygments can output LaTeX. (There is also minted)

HTH 

Jean Niklas L'orange

unread,
Feb 17, 2014, 4:17:48 AM2/17/14
to clo...@googlegroups.com
Hi Mark,


On Monday, February 17, 2014 12:05:24 AM UTC+1, puzzler wrote:
I am unable to find a style file that supports clojure code in LaTeX.  Can anyone point me in the right direction?

I always use Minted for this kind of stuff: See https://code.google.com/p/minted/

It is available in most, if not all, linux distributions. A small example for clojure follows:

[...]
\usepackage[section]{minted}

\begin{document}
[...]
\begin{minted}[gobble=2, frame=single}{clj}
  (with-open [reader (-> "META-INF/maven/my-program/my-program/pom.properties"
                         io/resource
                         io/reader)]
    (-> (doto (java.util.Properties.)
          (.load reader))
        (.getProperty "version")))
\end{minted}
[...]
\end{document}

Keep in mind that pdflatex has to be invoked with -shell-escape in order to allow pygments to be called. If you use latexmk (if you don't know about it, check it out!), then you could use the following command stored in a shell script or Makefile:

latexmk -pdf -pdflatex='pdflatex -shell-escape %O %S' -pvc $(REPORT).tex

At least it has been immensely useful to me.

-- JN

Tassilo Horn

unread,
Feb 18, 2014, 1:53:15 PM2/18/14
to Jean Niklas L'orange, clo...@googlegroups.com
Jean Niklas L'orange <jean...@hypirion.com> writes:

>> I am unable to find a style file that supports clojure code in LaTeX.
>> Can anyone point me in the right direction?
>
> I always use Minted for this kind of stuff: See
> https://code.google.com/p/minted/

I just want to second that. Minted is excellent. The only downside is
that compiling the document takes some time if you have lots of
listings. But the most recent git version has a cache option which
won't call pygments only on listings that have changed.

BTW, minted is now on github:

https://github.com/gpoore/minted

Bye,
Tassilo
Reply all
Reply to author
Forward
0 new messages