<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">The source code for my thesis is public, and it includes this file: <a href="https://github.com/goldfirere/thesis/blob/master/tex/rae.fmt" class="">https://github.com/goldfirere/thesis/blob/master/tex/rae.fmt</a><div class=""><br class=""></div><div class="">But there weren't colors in my thesis. (Or, at least, the code wasn't syntax highlighted with colors.)</div><div class=""><br class=""></div><div class="">These days, I use that fmt file with these definitions in the tex file:</div><div class=""><br class=""></div><div class=""><div class=""></div><blockquote type="cite" class=""><div class="">\newcommand{\keyword}[1]{\textcolor{BlueViolet}{\textbf{#1}}}</div><div class="">\newcommand{\id}[1]{\textsf{\textsl{#1}}}</div><div class="">\newcommand{\varid}[1]{\textcolor{Sepia}{\id{#1}}}</div><div class="">\newcommand{\conid}[1]{\textcolor{OliveGreen}{\id{#1}}}</div></blockquote><div class=""><br class=""></div><div class="">I hope this is helpful!</div><div class="">Richard</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 21, 2018, at 5:20 PM, Artem Pelenitsyn <<a href="mailto:a.pelenitsyn@gmail.com" class="">a.pelenitsyn@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Dear Oleg,</div><div class=""><br class=""></div><div class="">Thanks for the reply! It works modulo line 24 where, it seems, your mail client broke the line which happened to be inside comment and that drives pdflatex mad. The gist is fine though, so I put the link here:</div><div class=""><a href="https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex" class="">https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex</a></div><div class=""><br class=""></div><div class="">Your answer shows the approach one could apply to tune the color of various lexical element. I wonder if there are prebaked set of definitions covering the whole (or most of) grammar: literals, comments, type variables… {- Obviously, RIchard has one :) -}<br class=""></div><div class=""><br class=""></div><div class="">--</div><div class="">Best, Artem<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, 21 Jun 2018 at 19:22 Oleg Grenrus <<a href="mailto:oleg.grenrus@iki.fi" class="">oleg.grenrus@iki.fi</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Artem,<br class="">
<br class="">
I answer with inline lhs2Tex file. Hopefully it helps in your typed-code<br class="">
type-settings!<br class="">
<br class="">
cheers, Oleg.<br class="">
<br class="">
\documentclass{article}<br class="">
%include polycode.fmt<br class="">
<br class="">
\usepackage{hyperref}<br class="">
\hypersetup{pdfborder={0 0 0}}<br class="">
<br class="">
% in lhs2TeX.style there are<br class="">
%<br class="">
% \newcommand{\Conid}[1]{{\mathit #1}}<br class="">
% \newcommand{\Varid}[1]{{\mathit #1}}<br class="">
% \newcommand{\anonymous}{\_}<br class="">
%<br class="">
% We can renew these<br class="">
<br class="">
\usepackage{xcolor}<br class="">
\definecolor{darkred}{rgb}{.5,0,0}<br class="">
\definecolor{darkgreen}{rgb}{0,0.5,0}<br class="">
\definecolor{darkblue}{rgb}{0,0,.5}<br class="">
\definecolor{color4}{rgb}{0,.4,.4}<br class="">
\definecolor{color5}{rgb}{.4,.4,0}<br class="">
<br class="">
\renewcommand{\Conid}[1]{{\color{darkblue}\mathit #1}}<br class="">
<br class="">
% however types and constructors look the same, we can differentiate<br class="">
them though<br class="">
<br class="">
%format Foo = "{\color{darkred}\mathit Foo}"<br class="">
%format MkFoo = "{\color{darkgreen}\mathit Foo}"<br class="">
<br class="">
% Note how I "cheat" making MkFoo render as Foo!<br class="">
<br class="">
% We can also highlight operators<br class="">
%format + = "\mathbin{\color{color4}+}"<br class="">
<br class="">
% or symbols (note I also make thing look prettier)"<br class="">
%format plusFoo = "{\color{color5}\mathit plus_{Foo}}"<br class="">
%format ColorsInLhs2TeX = "{\text{Colors in lhs2\TeX}}"<br class="">
<br class="">
\begin{document}<br class="">
<br class="">
An example of colorful lhs2\TeX\ file.<br class="">
See the source at<br class="">
\url{<a href="https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex%7D%" rel="noreferrer" target="_blank" class="">https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex}%</a><br class="">
\footnote{It's named tex to trick \emph{Pandoc} in my blog setup},<br class="">
and the result PDF at<br class="">
\url{<a href="https://github.com/phadej/gists/blob/master/pdf/ColorsInLhs2TeX.pdf" rel="noreferrer" target="_blank" class="">https://github.com/phadej/gists/blob/master/pdf/ColorsInLhs2TeX.pdf</a>}<br class="">
<br class="">
\begin{code}<br class="">
module ColorsInLhs2TeX where<br class="">
<br class="">
newtype Foo = MkFoo Int<br class="">
<br class="">
plusFoo :: Foo -> Foo -> Int<br class="">
plusFoo (MkFoo n) (MkFoo m) = n + m<br class="">
\end{code}<br class="">
\end{document}<br class="">
<br class="">
<br class="">
On 21.06.2018 18:29, Artem Pelenitsyn wrote:<br class="">
> Dear Cafe,<br class="">
><br class="">
> In his recent Stitch manuscript,<br class="">
> <a href="https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf" rel="noreferrer" target="_blank" class="">https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf</a><br class="">
> <<a href="https://cs.brynmawr.edu/%7Erae/papers/2018/stitch/stitch.pdf" rel="noreferrer" target="_blank" class="">https://cs.brynmawr.edu/%7Erae/papers/2018/stitch/stitch.pdf</a>><br class="">
> Richard Eisenberg mentions that he uses lhs2TeX to typeset Haskell<br class="">
> listings, but I'm not aware of the support for colors in lhs2TeX. Can<br class="">
> anyone suggest how to get such a nice code highlighting (presumably<br class="">
> with lhs2TeX).<br class="">
><br class="">
> --<br class="">
> Best wishes,<br class="">
> Artem<br class="">
><br class="">
><br class="">
> _______________________________________________<br class="">
> Haskell-Cafe mailing list<br class="">
> To (un)subscribe, modify options or view archives go to:<br class="">
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
> Only members subscribed via the mailman list are allowed to post.<br class="">
<br class="">
_______________________________________________<br class="">
Haskell-Cafe mailing list<br class="">
To (un)subscribe, modify options or view archives go to:<br class="">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">
Only members subscribed via the mailman list are allowed to post.</blockquote></div>
_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.</div></blockquote></div><br class=""></div></body></html>