Created
April 7, 2024 22:16
-
-
Save yangzhixuan/5e9074f8007da31654c407a19b445f0a to your computer and use it in GitHub Desktop.
Using lhs2tex code in mathmode
This file contains hidden or 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
\documentclass{article} | |
\usepackage{amsmath} | |
%include polycode.fmt | |
\newenvironment{autohscode}% | |
{\relax\ifmmode\expandafter\pmboxed\else\expandafter\plainhscode\fi}% | |
{\relax\ifmmode\expandafter\endpmboxed\else\expandafter\endplainhscode\fi} | |
\sethscode{autohscode} | |
\begin{document} | |
\begin{gather*} | |
\int_x{\left( | |
\begin{code} | |
foldr f z [] = z | |
foldr f z (x:xs) = f x (foldr f z xs) | |
\end{code} | |
\right)} | |
= \mathit{nonsense} | |
\end{gather*} | |
In text mode: | |
\begin{code} | |
foldl f z [] = z | |
foldl f z (x:xs) = foldl f (f z x) xs | |
\end{code} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment