Created
August 21, 2025 15:40
-
-
Save matthewfl/c5b6f7a55bbd75c45729df761ba97f2f to your computer and use it in GitHub Desktop.
Matthew Francis-Landau dissertation configuration for lstlisting
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
| \usepackage{listings} | |
| %\usepackage{fancyvrb} % because everything sucks sometimes | |
| \usepackage{fvextra} | |
| \usepackage{longtable} | |
| \usepackage{multirow} | |
| % \usepackage{multicol} | |
| \usepackage{framed} | |
| \usepackage{mdframed} | |
| \lstdefinelanguage{dyna}{ | |
| morekeywords={with\_key,arg,$arg}, % $ | |
| sensitive=true, | |
| morecomment=[l]{\%}, | |
| morestring=[b]", | |
| literate= | |
| %{.}{{{\color{aggblue}.}}}2 | |
| {:-}{{{\color{aggblue}:-}}}2 | |
| {for}{{{\bfseries for}}}3 | |
| {=}{{{\color{aggblue}=}}}1 % this is causing >= to make the equals sign blue without being an aggregator. Would maybe just include the other | |
| {min=}{{{\color{aggblue}min=}}}4 | |
| {max=}{{{\color{aggblue}max=}}}4 | |
| {+=}{{{\color{aggblue}+=}}}2 | |
| {|=}{{{\color{aggblue}|=}}}2 | |
| {&=}{{{\color{aggblue}\&=}}}2 | |
| {?=}{{{\color{aggblue}?=}}}2 | |
| {cdots}{{\ensuremath{\cdots}}}2 | |
| {dot}{{\ensuremath{\cdot}}}1 | |
| } | |
| \lstdefinelanguage{clojure}{ | |
| morekeywords={def,defn,def-base-rexpr,def-rewrite,def-builtin-rexpr,let,try,catch,fn,do,simplify,throw,def-user-term}, | |
| sensitive=true, | |
| morecomment=[l]{;}, | |
| morestring=[b]{"}, | |
| alsoletter=- | |
| } | |
| \lstset{ | |
| basicstyle=\fontsize{11.5pt}{14pt}\ttfamily,%{\ttfamily\small}, % the default font size is HUGE | |
| xleftmargin={0.75cm}, | |
| numbers=left, | |
| frame=l, | |
| stepnumber=1, | |
| firstnumber=1, | |
| numberfirstline=true, | |
| tabsize=2, | |
| showtabs=false, | |
| showspaces=false, | |
| showstringspaces=false, | |
| extendedchars=true, | |
| breaklines=true, | |
| columns=fullflexible, | |
| keepspaces=true, | |
| escapeinside={@}{@}, | |
| firstnumber=last, | |
| commentstyle=\color{black!65}, | |
| numberstyle=\tiny\color{black!65} | |
| } | |
| % emph={proc,retp,endp,local}, emphstyle={\color{blue}\textbf}, | |
| % {*}{{{\color{red}*}}}1 | |
| % {-}{{{\color{red}-}}}4 | |
| % {+}{{{\color{red}+}}}1 | |
| % {^}{{{\color{red}\textasciicircum}}}2 | |
| \newcounter{clojureGlobalLineNumber} | |
| \setcounter{clojureGlobalLineNumber}{10000} | |
| \lstnewenvironment{clojureex}[1][] | |
| {% | |
| %\setcounter{dynaGlobalLineNumber}{\the\value{lstnumber}}% | |
| %\setcounter{lstnumber}{\the\value{clojureGlobalLineNumber}}% | |
| \lstset{ | |
| numbers=left, | |
| language={clojure}, | |
| %mathescape=true, | |
| xleftmargin={1.5cm}, | |
| frame=l, | |
| #1 | |
| }% | |
| %\vspace{-2pt} | |
| }{ | |
| %\setcounter{clojureGlobalLineNumber}{\the\value{lstnumber}}% | |
| %\setcounter{lstnumber}{\the\value{dynaGlobalLineNumber}}% | |
| \vspace{-2pt} | |
| } | |
| \lstnewenvironment{abstractex}[1][] | |
| {% | |
| \renewcommand{\ttdefault}{zi4} % make this the inconsolata font | |
| \setcounter{dynaGlobalLineNumber}{\the\value{lstnumber}}% | |
| \lstset{ | |
| numbers=none, | |
| language={}, | |
| mathescape=true, | |
| xleftmargin={0cm}, | |
| frame=none, | |
| #1 | |
| }% | |
| %\vspace{-2pt} | |
| }{ | |
| \setcounter{lstnumber}{\the\value{dynaGlobalLineNumber}}% | |
| \vspace{-2pt} | |
| } | |
| \lstnewenvironment{dynaex}[2][] | |
| {% | |
| \lstset{ | |
| language={dyna}, | |
| morekeywords={$self,new,for,with\_key,arg,assert}, | |
| classoffset=2, | |
| morekeywords={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Xs,Ys,Zs,HX,HY,DX,DY,DZ,XX,YY,Property,Prop,Arg1,Arg2,Result,Val1,Val2,ValN,Dynabase,SuperDynabase,As,Bs,Out,X1,X2,X3,X4,X5,,X6,Xn,#2}, | |
| keywordstyle=\color{vargreen}, | |
| #1 | |
| } | |
| %\vspace{2pt} | |
| %\begin{minipage}[c]{\textwidth} | |
| } | |
| {% | |
| %\end{minipage} | |
| \vspace{-2pt} | |
| } | |
| \lstnewenvironment{prologex}[2][] | |
| { | |
| \lstset{ | |
| language={prolog}, | |
| } | |
| %\vspace{-2pt} | |
| } | |
| { | |
| \vspace{-2pt} | |
| } | |
| \lstnewenvironment{termex}[2][] | |
| {% | |
| \renewcommand{\ttdefault}{zi4} % make this the inconsolata font | |
| \setcounter{dynaGlobalLineNumber}{\the\value{lstnumber}}% | |
| \lstset{ % this should match the \rterm configuration below | |
| language={}, | |
| mathescape=true, | |
| numbers=none, | |
| classoffset=1, | |
| morekeywords={when,if,where,and,or}, | |
| keywordstyle=\rm\bfseries, | |
| xleftmargin={0cm}, | |
| frame=none, | |
| classoffset=2, | |
| morekeywords={G,H,P,A,B,C,D,E,F,I,J,K,O,T,U,V,W,X,Y,Z,Xs,Ys,Zs,HX,HY,DX,DY,DZ,Key,Val,Val1,Result,Temp,Temp1,Temp2,T1,Tn,Xn,X1,Arg1,Arg2,XX,YY,Property,Prop,IS_SAT,#2}, | |
| keywordstyle=\color{vargreen}, | |
| classoffset=3, | |
| morekeywords={R,S,Q,R2,R3,R4,R5,R6,R7,R0,R1,Q2,Q1,S1,S2,S0,RSum,RMin,REq,Rn,R1new,R2new}, | |
| keywordstyle=\color{termvar}, | |
| % classoffset=4, | |
| % morekeywords={}, | |
| % keywordstyle=\color{termground}, | |
| classoffset=5, | |
| morekeywords={L,M,N}, | |
| keywordstyle=\color{termmul}, | |
| #1 | |
| } | |
| %\vspace{-2pt} | |
| %\begin{minipage}[c]{\textwidth} | |
| } | |
| {% | |
| %\end{minipage} | |
| \setcounter{lstnumber}{\the\value{dynaGlobalLineNumber}}% | |
| \vspace{-2pt} | |
| } | |
| \lstnewenvironment{generatedlog}[2][] | |
| {% | |
| \lstset{ | |
| language={}, | |
| firstnumber=1, | |
| numberfirstline=true | |
| } | |
| %\vspace{-2pt} | |
| %\begin{minipage}[c]{\textwidth} | |
| } | |
| {% | |
| %\end{minipage} | |
| \vspace{-2pt} | |
| } | |
| \lstdefinelanguage{rexpr}{ | |
| mathescape=true, | |
| numbers=none, | |
| classoffset=1, | |
| morekeywords={}, | |
| keywordstyle=\tt\bfseries, | |
| xleftmargin={0cm}, | |
| frame=none, | |
| classoffset=2, | |
| morekeywords={T,G,H,P,A,B,C,D,E,F,I,J,K,O,U,V,W,X,Y,Z,Xs,Ys,Zs,HX,HY,DX,DY,DZ,Key,Val,Val1,Result,T1,Tn,Xn,X1,Temp,Arg1,Arg2,Out,Tmp,Tmp1,Tmp2,NewTmp,Temp1,Temp2,Temp,AR,BR,Var1,Var2,VarN,SuperDynabase,Dynabase,X1,X2,X3,X4,Xn}, | |
| keywordstyle=\color{vargreen}, | |
| classoffset=3, | |
| morekeywords={R,S,Q,R2,R3,R4,R5,R6,R7,Rn,R0,R1,Q2,Q1,Q0,S0,S1,S2,ShouldReadMemos,Memos,MemoR,RMemo,RMemoNew,RMemoExisting,Compute,Ret,True,False,NewMemo,NewQ,RSum,RMin,REq,BigComplicatedRexpr,ObviouslyFalseRexpr,AnotherBigComplicatedRexpr,TrueRexpr,FalseRexpr,Memo,OriginalRexpr,R2new,Ropt,Sopt}, | |
| keywordstyle=\color{termvar}, | |
| %classoffset=4, | |
| % morekeywords={T}, | |
| % keywordstyle=\color{termground}, | |
| classoffset=5, | |
| morekeywords={L,M,N}, | |
| keywordstyle=\color{termmul}, | |
| literate= | |
| {_{10}}{{\ensuremath{_{10}}}}3 | |
| {_{11}}{{\ensuremath{_{11}}}}3 | |
| {_{12}}{{\ensuremath{_{12}}}}3 | |
| {_{13}}{{\ensuremath{_{13}}}}3 | |
| {_{14}}{{\ensuremath{_{14}}}}3 | |
| {_0}{{\ensuremath{_0}}}2 | |
| {_1}{{\ensuremath{_1}}}2 | |
| {_2}{{\ensuremath{_2}}}2 | |
| {_3}{{\ensuremath{_3}}}2 | |
| {_4}{{\ensuremath{_4}}}2 | |
| {_5}{{\ensuremath{_5}}}2 | |
| {_6}{{\ensuremath{_6}}}2 | |
| {_7}{{\ensuremath{_7}}}2 | |
| {_8}{{\ensuremath{_8}}}2 | |
| {_9}{{\ensuremath{_9}}}2 | |
| {agg_null}{{agg\_null}}8 | |
| {_n}{{\ensuremath{_n}}}2 | |
| {_m}{{\ensuremath{_m}}}2 | |
| {_i}{{\ensuremath{_i}}}2 | |
| {->*}{{\ensuremath{\mathrel{\to^*}}}}3 % TODO: this needs some rel stack or something? | |
| {->}{{\ensuremath{\to}}}2 | |
| {<->}{{\ensuremath{\xleftrightarrow}}}2 | |
| {cdots}{{\ensuremath{\cdots}}}2 | |
| {dot}{{\ensuremath{\cdot}}}1 | |
| % {,}{{,\allowbreak}}1 | |
| % {*}{{\allowbreak*\allowbreak}}1 | |
| } | |
| \newcommand{\rterm}[2][]{% | |
| \renewcommand{\ttdefault}{zi4}% make this the inconsolata font | |
| \text{\lstinline[language={rexpr}, | |
| % breaklines=true, % did not seem to do anything | |
| classoffset=6, | |
| morekeywords={#1}, | |
| keywordstyle=\color{vargreen}]{#2}}\xspace% | |
| } | |
| \newcommand{\rtermnocolor}[1]{% | |
| \renewcommand{\ttdefault}{zi4}% make this the inconsolata font | |
| \text{\texttt{#1}}\xspace | |
| } | |
| \newcommand{\dynainline}[2][]{% | |
| \text{\lstinline[language={dyna}, | |
| morekeywords={for,with\_key,arg,assert,$self,new}, % $ | |
| classoffset=2, | |
| morekeywords={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,Xs,Ys,Zs,HX,HY,DX,DY,DZ,Start,Arg1,Arg2,Result,End,XX,YY,Property,Prop,Argument1,Argument2,Argument3,ArgumentN,Var1,Var2,VarN,Dynabase,SuperDynabase,As,Rs,Bs,Out,X1,X2,X3,X4,X5,X6,Xn,#1}, | |
| keywordstyle=\color{vargreen} | |
| ]{#2}}\xspace} | |
| \definecolor{aggblue}{rgb}{0,0,.65} | |
| \newcommand{\codeagg}[1]{\textbf{\color{aggblue} #1}} | |
| \definecolor{vargreen}{rgb}{0,.50,.18} | |
| \newcommand{\codevar}[1]{\color{vargreen} #1} | |
| % http://latexcolor.com/ | |
| % useful https://denbeke.be/blog/programming/syntax-highlighting-in-latex/ | |
| \definecolor{termvar}{rgb}{0.0,.55,.55} % blue-ish | |
| %\definecolor{termground}{rgb}{0.91, 0.41, 0.17} % orange | |
| %\definecolor{termground}{rgb}{0.8, 0.5, 0.2} | |
| %\definecolor{termground}{rgb}{0.20, 0.61, 1.00} % orange | |
| \definecolor{termmul}{rgb}{0.03, 0.27, 0.49} % darker blue | |
| %0, 40, 60, 0 | |
| % use the same global listing environment, but stash the global counter and then reset it at the end | |
| \newcounter{dynaGlobalLineNumber} | |
| \newcommand{\var}[1]{{\renewcommand{\ttdefault}{zi4} | |
| \texttt{{\color{vargreen} #1}}}} | |
| \newcommand{\functor}[1]{{\tt\bf #1}} | |
| \newcommand{\term}[2]{\ensuremath{\functor{#1}\langle #2\rangle}} | |
| \newcommand{\dnull}{\textsf{null}\xspace} | |
| \newcommand{\isop}{\texttt{\textbf{\tt is}}\xspace} | |
| \newcommand{\vA}{\var{A}\xspace} | |
| \newcommand{\vB}{\var{B}\xspace} | |
| \newcommand{\vC}{\var{C}\xspace} | |
| \newcommand{\vD}{\var{D}\xspace} | |
| \newcommand{\vE}{\var{E}\xspace} | |
| \newcommand{\vF}{\var{F}\xspace} | |
| \newcommand{\vG}{\var{G}\xspace} | |
| \newcommand{\vH}{\var{H}\xspace} | |
| \newcommand{\vI}{\var{I}\xspace} | |
| \newcommand{\vJ}{\var{J}\xspace} | |
| \newcommand{\vK}{\var{K}\xspace} | |
| \newcommand{\vL}{\var{L}\xspace} | |
| \newcommand{\vM}{\var{M}\xspace} | |
| \newcommand{\vN}{\var{N}\xspace} | |
| \newcommand{\vO}{\var{O}\xspace} | |
| \newcommand{\vP}{\var{P}\xspace} | |
| \newcommand{\vQ}{\var{Q}\xspace} | |
| \newcommand{\vR}{\var{R}\xspace} | |
| \newcommand{\vS}{\var{S}\xspace} | |
| \newcommand{\vT}{\var{T}\xspace} | |
| \newcommand{\vU}{\var{U}\xspace} | |
| \newcommand{\vV}{\var{V}\xspace} | |
| \newcommand{\vW}{\var{W}\xspace} | |
| \newcommand{\vX}{\var{X}\xspace} | |
| \newcommand{\vXone}{\var{X}\mbox{$_1$}\xspace} | |
| \newcommand{\vXtwo}{\var{X}\mbox{$_2$}\xspace} | |
| \newcommand{\vY}{\var{Y}\xspace} | |
| \newcommand{\vZ}{\var{Z}\xspace} | |
| \newcommand{\colondash}{\codeagg{:-}} | |
| \newcommand{\eor}{\codeagg{.}} | |
| \newcommand{\opluseq}{\ensuremath{\,\oplus\!\!=}} | |
| \newcommand{\pluseq}{{\tt \,+\!\!=\,}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment