| 1 |
\documentclass{article} |
| 2 |
|
| 3 |
\usepackage{standalone} |
| 4 |
\usepackage{luacas} |
| 5 |
\usepackage{amsmath} |
| 6 |
\usepackage{amssymb} |
| 7 |
|
| 8 |
\usepackage[margin=1in]{geometry} |
| 9 |
\usepackage[shortlabels]{enumitem} |
| 10 |
|
| 11 |
\usepackage{pgfplots} |
| 12 |
\pgfplotsset{compat=1.18} |
| 13 |
\usetikzlibrary{positioning,calc} |
| 14 |
\usepackage{forest} |
| 15 |
\usepackage{minted} |
| 16 |
\usemintedstyle{pastie} |
| 17 |
\usepackage[hidelinks]{hyperref} |
| 18 |
\usepackage{parskip} |
| 19 |
\usepackage{multicol} |
| 20 |
\usepackage[most]{tcolorbox} |
| 21 |
\tcbuselibrary{xparse} |
| 22 |
\usepackage{microtype} |
| 23 |
|
| 24 |
\usepackage[ |
| 25 |
backend=biber, |
| 26 |
style=numeric, |
| 27 |
]{biblatex} |
| 28 |
\addbibresource{sources.bib} |
| 29 |
|
| 30 |
\newtcolorbox{codebox}[1][sidebyside]{ |
| 31 |
enhanced,skin=bicolor, |
| 32 |
#1, |
| 33 |
arc=1pt, |
| 34 |
colframe=brown, |
| 35 |
colback=brown!15,colbacklower=white, |
| 36 |
boxrule=1pt, |
| 37 |
notitle |
| 38 |
} |
| 39 |
|
| 40 |
\definecolor{rose}{RGB}{128,0,0} |
| 41 |
\definecolor{roseyellow}{RGB}{222,205,99} |
| 42 |
\definecolor{roseblue}{RGB}{167,188,214} |
| 43 |
\definecolor{rosenavy}{RGB}{79,117,139} |
| 44 |
\definecolor{roseorange}{RGB}{232,119,34} |
| 45 |
\definecolor{rosegreen}{RGB}{61,68,30} |
| 46 |
\definecolor{rosewhite}{RGB}{223,209,167} |
| 47 |
\definecolor{rosebrown}{RGB}{108,87,27} |
| 48 |
\definecolor{rosegray}{RGB}{84,88,90} |
| 49 |
|
| 50 |
\begin{document} |
| 51 |
|
| 52 |
\section{The \LaTeX{} code} |
| 53 |
|
| 54 |
As noted above, this package is really a Lua program; the package {\ttfamily luacas.sty} is merely a shell to make accessing that Lua program easy and manageable from within \LaTeX{}. |
| 55 |
\inputminted[ |
| 56 |
firstline=12, |
| 57 |
lastline=14, |
| 58 |
breaklines, |
| 59 |
linenos, |
| 60 |
numbersep=5pt] |
| 61 |
{latex} |
| 62 |
{luacas.dat} |
| 63 |
|
| 64 |
We check to make sure the user is compiling with Lua\LaTeX{}; if not, an error message is printed and compilation is aborted. |
| 65 |
|
| 66 |
\inputminted[ |
| 67 |
firstline=16, |
| 68 |
lastline=24, |
| 69 |
breaklines, |
| 70 |
linenos, |
| 71 |
numbersep=5pt] |
| 72 |
{latex} |
| 73 |
{luacas.dat} |
| 74 |
|
| 75 |
The following packages are required for various macros: |
| 76 |
|
| 77 |
\inputminted[ |
| 78 |
firstline=27, |
| 79 |
lastline=32, |
| 80 |
breaklines, |
| 81 |
linenos, |
| 82 |
numbersep=5pt] |
| 83 |
{latex} |
| 84 |
{luacas.dat} |
| 85 |
|
| 86 |
The files \verb|helper.lua| and \verb|parser.lua| help bridge the gap between the Lua program and \LaTeX{}. |
| 87 |
|
| 88 |
\inputminted[ |
| 89 |
firstline=35, |
| 90 |
lastline=37, |
| 91 |
breaklines, |
| 92 |
linenos, |
| 93 |
numbersep=5pt] |
| 94 |
{latex} |
| 95 |
{luacas.dat} |
| 96 |
|
| 97 |
We now define the \mintinline{latex}{\begin{CAS}..\end{CAS}} environment: |
| 98 |
|
| 99 |
\inputminted[ |
| 100 |
firstline=39, |
| 101 |
lastline=42, |
| 102 |
breaklines, |
| 103 |
linenos, |
| 104 |
numbersep=5pt] |
| 105 |
{latex} |
| 106 |
{luacas.dat} |
| 107 |
|
| 108 |
{\bf Note:} The contents are wrapped in the function \mintinline{lua}{CASparse()}. We now define the retrieving macros \mintinline{latex}{\get}, \mintinline{latex}{\fetch}, and \mintinline{latex}{\store}: |
| 109 |
|
| 110 |
\inputminted[ |
| 111 |
firstline=44, |
| 112 |
lastline=67, |
| 113 |
breaklines, |
| 114 |
linenos, |
| 115 |
numbersep=5pt] |
| 116 |
{latex} |
| 117 |
{luacas.dat} |
| 118 |
And now we define the printing macros \mintinline{latex}{\print}, \mintinline{latex}{\vprint}, and \mintinline{latex}{\lprint}: |
| 119 |
|
| 120 |
\inputminted[ |
| 121 |
firstline=75, |
| 122 |
lastline=128, |
| 123 |
breaklines, |
| 124 |
linenos, |
| 125 |
numbersep=5pt] |
| 126 |
{latex} |
| 127 |
{luacas.dat} |
| 128 |
|
| 129 |
And finally, we define the macros useful for printing expression trees: |
| 130 |
|
| 131 |
\inputminted[ |
| 132 |
firstline=130, |
| 133 |
lastline=230, |
| 134 |
breaklines, |
| 135 |
linenos, |
| 136 |
numbersep=5pt] |
| 137 |
{latex} |
| 138 |
{luacas.dat} |
| 139 |
|
| 140 |
\end{document} |