X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=mjo-listing.tex;h=bcfe25f4af5673bfbcd9bf6ab58094fae5343f6a;hb=a331ae0b381e9b3a0fa68d3ef42e7fac42dbb471;hp=aa24b5cc5cadda0490b34277afc43ccb9f9cbe7a;hpb=049c836f042cd24d586e35b2d214b8ac00e2e215;p=mjotex.git diff --git a/mjo-listing.tex b/mjo-listing.tex index aa24b5c..bcfe25f 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} @@ -27,7 +36,8 @@ \lstset{% basicstyle=\ttfamily\small, columns=fullflexible, - keepspaces=true + keepspaces=true, + showstringspaces=false } % Define a style for interactive sage prompt listings. @@ -37,3 +47,22 @@ 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". +\newcommand*{\sagelisting}[1]{\tcbinputlisting{listing only,% + colback=codebg,% + coltext=codefg,% + enlarge bottom finally by=\baselineskip,% + enlarge top initially by=\baselineskip,% + left=2em,% + listing options={language=sage,style=sage},% + listing file=sage_listings/#1.listing}} + + +\fi