summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/luacas/doc/appendix/latexcode.tex
blob: 1f8ccd7471079907f4d7da2bdc352b89b38310ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
\documentclass{article}

\usepackage{standalone}
\usepackage{luacas}
\usepackage{amsmath}
\usepackage{amssymb}

\usepackage[margin=1in]{geometry}
\usepackage[shortlabels]{enumitem}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{positioning,calc}
\usepackage{forest}
\usepackage{minted}
\usemintedstyle{pastie}
\usepackage[hidelinks]{hyperref}
\usepackage{parskip}
\usepackage{multicol}
\usepackage[most]{tcolorbox}
    \tcbuselibrary{xparse}
\usepackage{microtype}

\usepackage[
backend=biber,
style=numeric,
]{biblatex}
\addbibresource{sources.bib}

\newtcolorbox{codebox}[1][sidebyside]{
    enhanced,skin=bicolor,
    #1,
    arc=1pt,
    colframe=brown,
    colback=brown!15,colbacklower=white,
    boxrule=1pt,
    notitle
}

\definecolor{rose}{RGB}{128,0,0}
\definecolor{roseyellow}{RGB}{222,205,99}
\definecolor{roseblue}{RGB}{167,188,214}
\definecolor{rosenavy}{RGB}{79,117,139}
\definecolor{roseorange}{RGB}{232,119,34}
\definecolor{rosegreen}{RGB}{61,68,30}
\definecolor{rosewhite}{RGB}{223,209,167}
\definecolor{rosebrown}{RGB}{108,87,27}
\definecolor{rosegray}{RGB}{84,88,90}

\begin{document}

\section{The \LaTeX{} code}

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{}. 
\inputminted[
    firstline=12,
    lastline=14,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

We check to make sure the user is compiling with Lua\LaTeX{}; if not, an error message is printed and compilation is aborted. 

\inputminted[
    firstline=16,
    lastline=24,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

The following packages are required for various macros:

\inputminted[
    firstline=27,
    lastline=32,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

The files \verb|helper.lua| and \verb|parser.lua| help bridge the gap between the Lua program and \LaTeX{}. 

\inputminted[
    firstline=35,
    lastline=37,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

We now define the \mintinline{latex}{\begin{CAS}..\end{CAS}} environment:

\inputminted[
    firstline=39,
    lastline=42,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

{\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}:

\inputminted[
    firstline=44,
    lastline=67,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}
And now we define the printing macros \mintinline{latex}{\print}, \mintinline{latex}{\vprint}, and \mintinline{latex}{\lprint}:

\inputminted[
    firstline=75,
    lastline=128,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

And finally, we define the macros useful for printing expression trees:

\inputminted[
    firstline=130,
    lastline=230,
    breaklines,
    linenos,
    numbersep=5pt]
    {latex}
    {luacas.dat}

\end{document}