% 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}
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