mjo-hurwitz.tex: new file for Hurwitz algebras (quaternions and octonions).
[mjotex.git] / mjo-listing.tex
1 %
2 % Code listing support, in particular, for the SageMath interactive
3 % prompt. You can create a box thingy for displaying code like,
4 %
5 % \begin{tcblisting}{listing only,
6 % colback=codebg,
7 % coltext=codefg,
8 % listing options={language=sage,style=sage}}
9 % sage: x
10 % x
11 % \end{tcblisting}
12 %
13 \ifx\havemjolisting\undefined
14 \def\havemjolisting{1}
15
16
17 \ifx\lstset\undefined
18 \usepackage{listings}
19 \fi
20
21 \ifx\tcbuselibrary\undefined
22 \usepackage{tcolorbox}
23 \fi
24
25 % Tell tcolorbox to use ``listings'' within the boxes.
26 \tcbuselibrary{listings}
27
28 % Define the colors that we'll use in our listings.
29 \definecolor{codefg}{rgb}{0.9, 0.9, 0.9}
30 \definecolor{codebg}{rgb}{0.16, 0.16, 0.16}
31 \definecolor{brilliantlavender}{rgb}{0.96, 0.73, 1.0}
32 \definecolor{brilliantgreen}{rgb}{0.7, 0.9, 0.7}
33 \definecolor{brown}{rgb}{0.75, 0.4, 0.4}
34
35 % General listing settings.
36 \lstset{%
37 basicstyle=\ttfamily\small,
38 columns=fullflexible,
39 keepspaces=true,
40 showstringspaces=false
41 }
42
43 % Define a style for interactive sage prompt listings.
44 \lstdefinelanguage{sage}{ keywords={sage} }
45 \lstdefinestyle{sage}{
46 commentstyle=\color{brown},
47 keywordstyle=\color{brilliantlavender},
48 stringstyle=\color{brilliantgreen}
49 }
50
51
52 % Input a SageMath example code listing from a file. You generally
53 % want these to be in separate files so that the build system can test
54 % them automatically.
55 %
56 % The sole argument is the "name" of the listing, which ultimately
57 % just identifies a file named "sage_listings/<name>.listing".
58 \newtcbinputlisting{\sagelisting}[2][]{%
59 colback=codebg,%
60 coltext=codefg,%
61 enlarge bottom finally by=\baselineskip,%
62 enlarge top initially by=\baselineskip,%
63 left=2em,%
64 listing only,%
65 listing options={language=sage,style=sage},%
66 listing file=sage_listings/#2.listing,%
67 #1}
68
69 \fi