Last active
June 23, 2018 11:28
-
-
Save ulysses4ever/c2374d35326b8644e27d0018b12d8ae3 to your computer and use it in GitHub Desktop.
Typeset Haskell code in LaTeX: an example of colorful lhs2TeX
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Build main.pdf: | |
% lhs2TeX main.lhs -o main.tex | |
% pdflatex main.tex | |
\documentclass{article} | |
%%%%%%%%%%%%%% Color-related things %%%%%%%%%%%%%% | |
\usepackage[dvipsnames]{xcolor} | |
%include polycode.fmt | |
%subst keyword a = "\textcolor{BlueViolet}{\textbf{" a "}}" | |
\newcommand{\id}[1]{\textsf{\textsl{#1}}} | |
\renewcommand{\Varid}[1]{\textcolor{Sepia}{\id{#1}}} | |
\renewcommand{\Conid}[1]{\textcolor{OliveGreen}{\id{#1}}} | |
%%%%%%%%%%%% End of Color-related things %%%%%%%%%%%% | |
% It might make sence to add pretty formating of individual things | |
% like "forall", cf. | |
% https://github.com/goldfirere/thesis/blob/master/tex/rae.fmt | |
\begin{document} | |
\begin{code} | |
module ColorsInLhs2TeX where | |
newtype Foo = MkFoo Int | |
plusFoo :: Foo -> Foo -> Int | |
plusFoo (MkFoo n) (MkFoo m) = n + m | |
\end{code} | |
\end{document} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result: