-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathORCCA.pl
More file actions
186 lines (182 loc) · 10.2 KB
/
ORCCA.pl
File metadata and controls
186 lines (182 loc) · 10.2 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#############################################################################
# This macro library supports WeBWorK problems from the PreTeXt project named
# Open Resources for Community College Algebra
#############################################################################
# Return a string containing the latex-image-preamble contents.
# To be used by LaTeXImage objects as in:
# $image->addToPreamble(latexImagePreamble())
sub latexImagePreamble {
return <<'END_LATEX_IMAGE_PREAMBLE'
\newlength{\orccaprintwidth}
\setlength{\orccaprintwidth}{350pt}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{pifont} %needed for symbols, s.a. airplane symbol
\usetikzlibrary{positioning,fit,backgrounds} %needed for nested diagrams
\usetikzlibrary{calc,trees,positioning,arrows,fit,shapes} %needed for set diagrams
\usetikzlibrary{decorations.text} %needed for text following a curve
\usetikzlibrary{arrows,arrows.meta} %needed for open/closed intervals
\usetikzlibrary{positioning,3d,shapes.geometric} %needed for 3d number sets tower
\usepackage{tikz-3dplot}
\usepackage{tkz-euclide} %needed for triangle diagrams
\usepgfplotslibrary{fillbetween} %shade regions of a plot
\usetikzlibrary{shadows} %function diagrams
\usetikzlibrary{positioning} %function diagrams
\usetikzlibrary{shapes} %function diagrams
%%% global colors from https://www.pcc.edu/web-services/style-guide/basics/color/ %%%
\definecolor{ruby}{HTML}{9e0c0f}
\definecolor{turquoise}{HTML}{008099}
\definecolor{emerald}{HTML}{1c8464}
\definecolor{lightemerald}{HTML}{12A983} %(lightened to contrast ratio just above 7 with black)
\definecolor{sapphire}{HTML}{3b5a7d}
\definecolor{lightsapphire}{HTML}{7898bf} %(lightened to contrast ratio just above 7 with black)
\definecolor{amber}{HTML}{c7502a}
\definecolor{amethyst}{HTML}{70485b}
\colorlet{firstcolor}{ruby}
\colorlet{secondcolor}{turquoise}
\colorlet{thirdcolor}{emerald}
\colorlet{fourthcolor}{amber}
\colorlet{fifthcolor}{amethyst}
\colorlet{sixthcolor}{sapphire}
\colorlet{highlightcolor}{green!50!black}
\colorlet{graphbackground}{yellow!30}
\colorlet{wood}{brown!60!white}
%%% curve, dot, and graph custom styles %%%
\pgfplotsset{firstcurve/.style = {color=firstcolor, mark=none, line width=1pt, {Kite}-{Kite}, solid}}
\pgfplotsset{secondcurve/.style = {color=secondcolor, mark=none, line width=1pt, {Kite}-{Kite}, solid}}
\pgfplotsset{thirdcurve/.style = {color=thirdcolor, mark=none, line width=1pt, {Kite}-{Kite}, solid}}
\pgfplotsset{fourthcurve/.style = {color=fourthcolor, mark=none, line width=1pt, {Kite}-{Kite}, solid}}
\pgfplotsset{fifthcurve/.style = {color=fifthcolor, mark=none, line width=1pt, {Kite}-{Kite}, solid}}
\pgfplotsset{highlightcurve/.style = {color=highlightcolor, mark=none, line width=5pt, -, opacity=0.3}} % thick, opaque curve for highlighting
\pgfplotsset{asymptote/.style = {color=gray, mark=none, line width=1pt, <->, dashed}}
\pgfplotsset{symmetryaxis/.style = {color=gray, mark=none, line width=1pt, <->, dashed}}
\pgfplotsset{guideline/.style = {color=gray, mark=none, line width=1pt, -}}
\tikzset{guideline/.style = {color=gray, mark=none, line width=1pt, -}}
\pgfplotsset{altitude/.style = {dashed, color=gray, thick, mark=none, -}}
\tikzset{altitude/.style = {dashed, color=gray, thick, mark=none, -}}
\pgfplotsset{radius/.style = {dashed, thick, mark=none, -}}
\tikzset{radius/.style = {dashed, thick, mark=none, -}}
\pgfplotsset{rightangle/.style = {color=gray, mark=none, -}}
\tikzset{rightangle/.style = {color=gray, mark=none, -}}
\pgfplotsset{closedboundary/.style = {color=black, mark=none, line width=1pt, {Kite}-{Kite},solid}}
\tikzset{closedboundary/.style = {color=black, mark=none, line width=1pt, {Kite}-{Kite},solid}}
\pgfplotsset{openboundary/.style = {color=black, mark=none, line width=1pt, {Kite}-{Kite},dashed}}
\tikzset{openboundary/.style = {color=black, mark=none, line width=1pt, {Kite}-{Kite},dashed}}
\tikzset{verticallinetest/.style = {color=gray, mark=none, line width=1pt, <->,dashed}}
\pgfplotsset{soliddot/.style = {color=firstcolor, mark=*, only marks}}
\pgfplotsset{hollowdot/.style = {color=firstcolor, mark=*, only marks, fill=graphbackground}}
\pgfplotsset{blankgraph/.style = {xmin=-10, xmax=10,
ymin=-10, ymax=10,
axis line style={-, draw opacity=0 },
axis lines=box,
major tick length=0mm,
xtick={-10,-9,...,10},
ytick={-10,-9,...,10},
grid=major,
grid style={solid,gray!40},
xticklabels={,,},
yticklabels={,,},
minor xtick=,
minor ytick=,
xlabel={},ylabel={},
width=0.75\textwidth,
}
}
\pgfplotsset{numberline/.style = {xmin=-10,xmax=10,
minor xtick={-11,-10,...,11},
xtick={-10,-5,...,10},
every tick/.append style={thick},
axis y line=none,
axis lines=middle,
enlarge x limits,
grid=none,
clip=false,
y=1cm,
ymin = -1,ymax = 1,
axis background/.style={},
width=\orccaprintwidth,
after end axis/.code={
\path (axis cs:0,0)
node [anchor=north,yshift=-0.075cm] {\footnotesize 0};
},
every axis x label/.style={at={(current axis.right of origin)},anchor=north},
}
}
\pgfplotsset{openinterval/.style={color=firstcolor,mark=none,ultra thick,{Parenthesis}-{Parenthesis}}}
\pgfplotsset{openclosedinterval/.style={color=firstcolor,mark=none,ultra thick,{Parenthesis}-{Bracket}}}
\pgfplotsset{closedinterval/.style={color=firstcolor,mark=none,ultra thick,{Bracket}-{Bracket}}}
\pgfplotsset{closedopeninterval/.style={color=firstcolor,mark=none,ultra thick,{Bracket}-{Parenthesis}}}
\pgfplotsset{infiniteopeninterval/.style={color=firstcolor,mark=none,ultra thick,{Kite}-{Parenthesis}}}
\pgfplotsset{openinfiniteinterval/.style={color=firstcolor,mark=none,ultra thick,{Parenthesis}-{Kite}}}
\pgfplotsset{infiniteclosedinterval/.style={color=firstcolor,mark=none,ultra thick,{Kite}-{Bracket}}}
\pgfplotsset{closedinfiniteinterval/.style={color=firstcolor,mark=none,ultra thick,{Bracket}-{Kite}}}
\pgfplotsset{infiniteinterval/.style={color=firstcolor,mark=none,ultra thick,{Kite}-{Kite}}}
\pgfplotsset{interval/.style= {ultra thick, -}}
%%% cycle list of plot styles for graphs with multiple plots %%%
\pgfplotscreateplotcyclelist{pccstylelist}{%
firstcurve\\%
secondcurve\\%
thirdcurve\\%
fourthcurve\\%
fifthcurve\\%
}
%%% default plot settings %%%
\pgfplotsset{every axis/.append style={
axis x line=middle, % put the x axis in the middle
axis y line=middle, % put the y axis in the middle
axis line style={<->}, % arrows on the axis
scaled ticks=false,
tick label style={/pgf/number format/fixed},
xlabel={\(x\)}, % default put x on x-axis
ylabel={\(y\)}, % default put y on y-axis
xmin = -7,xmax = 7, % most graphs have this window
ymin = -7,ymax = 7, % most graphs have this window
domain = -7:7,
xtick = {-6,-4,...,6}, % label these ticks
ytick = {-6,-4,...,6}, % label these ticks
yticklabel style={inner sep=0.333ex},
minor xtick = {-7,-6,...,7}, % include these ticks, some without label
minor ytick = {-7,-6,...,7}, % include these ticks, some without label
scale only axis, % don't consider axis and tick labels for width and height calculation
cycle list name=pccstylelist,
tick label style={font=\footnotesize},
legend cell align=left,
grid = both,
grid style = {solid,gray!40},
axis background/.style={fill=graphbackground},
}}
\pgfplotsset{framed/.style={axis background/.style ={draw=gray}}}
%\pgfplotsset{framed/.style={axis background/.style ={draw=gray,fill=graphbackground,rounded corners=3ex}}}
%%% other tikz (not pgfplots) settings %%%
%\tikzset{axisnode/.style={font=\scriptsize,text=black}}
\tikzset{>=stealth}
%%% for nested diagram in types of numbers section %%%
\newcommand\drawnestedsets[4]{
\def\position{#1} % initial position
\def\nbsets{#2} % number of sets
\def\listofnestedsets{#3} % list of sets
\def\reversedlistofcolors{#4} % reversed list of colors
% position and draw labels of sets
\coordinate (circle-0) at (#1);
\coordinate (set-0) at (#1);
\foreach \set [count=\c] in \listofnestedsets {
\pgfmathtruncatemacro{\cminusone}{\c - 1}
% label of current set (below previous nested set)
\node[below=3pt of circle-\cminusone,inner sep=0]
(set-\c) {\set};
% current set (fit current label and previous set)
\node[circle,inner sep=0,fit=(circle-\cminusone)(set-\c)]
(circle-\c) {};
}
% draw and fill sets in reverse order
\begin{scope}[on background layer]
\foreach \col[count=\c] in \reversedlistofcolors {
\pgfmathtruncatemacro{\invc}{\nbsets-\c}
\pgfmathtruncatemacro{\invcplusone}{\invc+1}
\node[circle,draw,fill=\col,inner sep=0,
fit=(circle-\invc)(set-\invcplusone)] {};
}
\end{scope}
}
END_LATEX_IMAGE_PREAMBLE
}