]> gitweb.michael.orlitzky.com - mjotex.git/blobdiff - mjo-listing.tex
Replace all uses of \providecommand with \newcommand.
[mjotex.git] / mjo-listing.tex
index fc9828cb9cd3302fb0dd83416c0c4c1bd904154c..f898aba13ea886be03258fea0bfc61dd1ee72dd9 100644 (file)
 %   x
 %   \end{tcblisting}
 %
+\ifx\havemjolisting\undefined
+\def\havemjolisting{1}
+
+
 \usepackage{listings}
 \usepackage{tcolorbox}
 
 \definecolor{codefg}{rgb}{0.9, 0.9, 0.9}
 \definecolor{codebg}{rgb}{0.16, 0.16, 0.16}
 \definecolor{brilliantlavender}{rgb}{0.96, 0.73, 1.0}
+\definecolor{brilliantgreen}{rgb}{0.7, 0.9, 0.7}
+\definecolor{brown}{rgb}{0.75, 0.4, 0.4}
 
-% Define a style for interactive sage prompt listings.
-\lstdefinelanguage{sage}{ keywords={sage} }
-\lstdefinestyle{sage}{ keywordstyle=\color{brilliantlavender} }
+% General listing settings.
 \lstset{%
   basicstyle=\ttfamily\small,
   columns=fullflexible,
-  keepspaces=true
+  keepspaces=true,
+  showstringspaces=false
 }
+
+% Define a style for interactive sage prompt listings.
+\lstdefinelanguage{sage}{ keywords={sage} }
+\lstdefinestyle{sage}{
+  commentstyle=\color{brown},
+  keywordstyle=\color{brilliantlavender},
+  stringstyle=\color{brilliantgreen}
+}
+
+
+% Input a SageMath example code listing from a file. You generally
+% want these to be in separate files so that the build system can test
+% them automatically.
+%
+% The sole argument is the "name" of the listing, which ultimately
+% just identifies a file named "sage_listings/<name>.listing".
+\newcommand*{\sagelisting}[1]{\tcbinputlisting{listing only,%
+               colback=codebg,%
+               coltext=codefg,%
+               left=2em,%
+               listing options={language=sage,style=sage},%
+               listing file=sage_listings/#1.listing}}
+
+
+\fi