X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo-listing.tex;h=ccd0d9cf0fb23aaf14f40177959df3a41ed95473;hb=66a672c6c1657ad96422fcdb4828bc5d9a108ab0;hp=fc9828cb9cd3302fb0dd83416c0c4c1bd904154c;hpb=6442db810af2ba37e6ff4f3639543510a79aafa3;p=mjotex.git diff --git a/mjo-listing.tex b/mjo-listing.tex index fc9828c..ccd0d9c 100644 --- a/mjo-listing.tex +++ b/mjo-listing.tex @@ -10,8 +10,17 @@ % x % \end{tcblisting} % -\usepackage{listings} -\usepackage{tcolorbox} +\ifx\havemjolisting\undefined +\def\havemjolisting{1} + + +\ifx\lstset\undefined + \usepackage{listings} +\fi + +\ifx\tcbuselibrary\undefined + \usepackage{tcolorbox} +\fi % Tell tcolorbox to use ``listings'' within the boxes. \tcbuselibrary{listings} @@ -20,12 +29,41 @@ \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/.listing". +\newtcbinputlisting{\sagelisting}[2][]{% + colback=codebg,% + coltext=codefg,% + enlarge bottom finally by=\baselineskip,% + enlarge top initially by=\baselineskip,% + left=2em,% + listing only,% + listing options={language=sage,style=sage},% + listing file=sage_listings/#2.listing,% + #1} + +\fi