
Thanks, RIchard!
I talked about your Stitch paper, not the thesis. But thanks for the
reference: the %format things from there are also useful to me.
The newcommands you gave almost worked for me. There are a couple of points:
- newcommand{\varid} → \renewcommand{\Varid}, and the same for conid
(thanks to Oleg again, for leading me to that); otherwise it does nothing;
- keyword: again, it does nothing to me as is given; I wasn't able to find
TeX'y way to do that, so I went to %subst:
%subst keyword a = "\textcolor{BlueViolet}{\textbf{" a "}}"
The resulting minimal-working-example is on this gist:
https://gist.github.com/ulysses4ever/c2374d35326b8644e27d0018b12d8ae3
Still, I would be happy to look at the whole preamble of Stitch: I believe,
there could be something more to steal :)
--
Best wishes,
Artem
On Sat, 23 Jun 2018 at 05:32 Richard Eisenberg
The source code for my thesis is public, and it includes this file: https://github.com/goldfirere/thesis/blob/master/tex/rae.fmt
But there weren't colors in my thesis. (Or, at least, the code wasn't syntax highlighted with colors.)
These days, I use that fmt file with these definitions in the tex file:
\newcommand{\keyword}[1]{\textcolor{BlueViolet}{\textbf{#1}}} \newcommand{\id}[1]{\textsf{\textsl{#1}}} \newcommand{\varid}[1]{\textcolor{Sepia}{\id{#1}}} \newcommand{\conid}[1]{\textcolor{OliveGreen}{\id{#1}}}
I hope this is helpful! Richard
On Jun 21, 2018, at 5:20 PM, Artem Pelenitsyn
wrote: Dear Oleg,
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:
https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2t...
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 :) -}
-- Best, Artem
On Thu, 21 Jun 2018 at 19:22 Oleg Grenrus
wrote: Hi Artem,
I answer with inline lhs2Tex file. Hopefully it helps in your typed-code type-settings!
cheers, Oleg.
\documentclass{article} %include polycode.fmt
\usepackage{hyperref} \hypersetup{pdfborder={0 0 0}}
% in lhs2TeX.style there are % % \newcommand{\Conid}[1]{{\mathit #1}} % \newcommand{\Varid}[1]{{\mathit #1}} % \newcommand{\anonymous}{\_} % % We can renew these
\usepackage{xcolor} \definecolor{darkred}{rgb}{.5,0,0} \definecolor{darkgreen}{rgb}{0,0.5,0} \definecolor{darkblue}{rgb}{0,0,.5} \definecolor{color4}{rgb}{0,.4,.4} \definecolor{color5}{rgb}{.4,.4,0}
\renewcommand{\Conid}[1]{{\color{darkblue}\mathit #1}}
% however types and constructors look the same, we can differentiate them though
%format Foo = "{\color{darkred}\mathit Foo}" %format MkFoo = "{\color{darkgreen}\mathit Foo}"
% Note how I "cheat" making MkFoo render as Foo!
% We can also highlight operators %format + = "\mathbin{\color{color4}+}"
% or symbols (note I also make thing look prettier)" %format plusFoo = "{\color{color5}\mathit plus_{Foo}}" %format ColorsInLhs2TeX = "{\text{Colors in lhs2\TeX}}"
\begin{document}
An example of colorful lhs2\TeX\ file. See the source at \url{ https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex}% \footnote{It's named tex to trick \emph{Pandoc} in my blog setup}, and the result PDF at \url{https://github.com/phadej/gists/blob/master/pdf/ColorsInLhs2TeX.pdf}
\begin{code} module ColorsInLhs2TeX where
newtype Foo = MkFoo Int
plusFoo :: Foo -> Foo -> Int plusFoo (MkFoo n) (MkFoo m) = n + m \end{code} \end{document}
On 21.06.2018 18:29, Artem Pelenitsyn wrote:
Dear Cafe,
In his recent Stitch manuscript, https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf https://cs.brynmawr.edu/%7Erae/papers/2018/stitch/stitch.pdf Richard Eisenberg mentions that he uses lhs2TeX to typeset Haskell listings, but I'm not aware of the support for colors in lhs2TeX. Can anyone suggest how to get such a nice code highlighting (presumably with lhs2TeX).
-- Best wishes, Artem
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.