-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathximera.cls
More file actions
1265 lines (1122 loc) · 40.2 KB
/
ximera.cls
File metadata and controls
1265 lines (1122 loc) · 40.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%
%% This is file `ximera.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ximera.dtx (with options: `classXimera')
%% src/banner.dtx (with options: `classXimera')
%% src/options.dtx (with options: `classXimera')
%% src/packages.dtx (with options: `classXimera')
%% src/tikzexport.dtx (with options: `classXimera')
%% src/hyperref.dtx (with options: `classXimera')
%% src/suppress.dtx (with options: `classXimera')
%% src/makeCounter.dtx (with options: `classXimera')
%% src/pagesetup.dtx (with options: `classXimera')
%% src/metadata.dtx (with options: `classXimera')
%% src/macros.dtx (with options: `classXimera')
%% src/theorems.dtx (with options: `classXimera')
%% src/enumerate.dtx (with options: `classXimera')
%% src/proof.dtx (with options: `classXimera')
%% src/only.dtx (with options: `classXimera')
%% src/outcomes.dtx (with options: `classXimera')
%% src/problem.dtx (with options: `classXimera')
%% src/hints.dtx (with options: `classXimera')
%% src/abstract.dtx (with options: `classXimera')
%% src/title.dtx (with options: `classXimera')
%% src/image.dtx (with options: `classXimera')
%% src/interactives/javascript.dtx (with options: `classXimera')
%% src/interactives/include.dtx (with options: `classXimera')
%% src/interactives/geogebra.dtx (with options: `classXimera')
%% src/interactives/doenet.dtx (with options: `classXimera')
%% src/interactives/desmos.dtx (with options: `classXimera')
%% src/interactives/google.dtx (with options: `classXimera')
%% src/interactives/graph.dtx (with options: `classXimera')
%% src/link.dtx (with options: `classXimera')
%% src/interactives/video.dtx (with options: `classXimera')
%% src/answer.dtx (with options: `classXimera')
%% src/choice.dtx (with options: `classXimera')
%% src/solution.dtx (with options: `classXimera')
%% src/feedback.dtx (with options: `classXimera')
%% src/freeresponse.dtx (with options: `classXimera')
%% src/verbatim.dtx (with options: `classXimera')
%% src/dialogue.dtx (with options: `classXimera')
%% src/instructornotes.dtx (with options: `classXimera')
%% src/xkcd.dtx (with options: `classXimera')
%% src/foldable.dtx (with options: `classXimera')
%% src/leash.dtx (with options: `classXimera')
%% src/interactives/sagemath.dtx (with options: `classXimera')
%% src/jax.dtx (with options: `classXimera')
%% src/accordion.dtx (with options: `classXimera')
%% src/ungraded.dtx (with options: `classXimera')
%% src/clearEnv.dtx (with options: `classXimera')
%% src/hideEnv.dtx (with options: `classXimera')
%% src/localization.dtx (with options: `classXimera')
%% src/preamble.dtx (with options: `classXimera')
%% ------------:| ------------------------------------------------------------
%% ximera:| Simultaneously writing print and online interactive materials
%% Author:| Jim Fowler and Oscar Levin and Jason Nowell and Wim Obbels and Hans Parshall and Bart Snapp
%% E-mail:| bart.snapp@gmail.com
%% License:| Released under the LaTeX Project Public License v1.3c or later
%% See:| http://www.latex-project.org/lppl.txt
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesClass{ximera}
[2024/05/12 v1.5.1
Simultaneously write print and online interactive materials]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\let\m\message
\def\w{\m{::}}\def\t{\m{:::}}\def\s{\m{ }}\def\n{\m{^^J}}\def\u{::'}\def\d{'::}\def\v{:::::}
\n
\m{\d.}\s\m{.\u}\w\m{}\m{\v}\s\s\m{\v}\m{}\m{.\v\v\v::::.}\s\m{}\t\n
\s\m{\d.\u}\s\w\t\t\s\t\t\w\m{}\s\s\s\s\s\s\s\t\s\m{\u::}\n
\s\s\t\s\s\w\t\m{}\t\t\m{}\t\m{ ::::\v}\m{.\v:\u}\m{}\m{\u}\m{\d}\n
\s\m{.\u::.}\s\w\t\m{}\t\t\m{}\t\w\s\s\s\s\w\m{}\m{\d.}\s\m{\u}\s\m{\d}\n
\m{.\u}\s\m{\d.}\w\t\s\m{':\u}\s\t\m{\d\v::}\w\s\m{}\m{\d.\u}\s\s\m{\d}\n
\n
\let\w\undefined
\let\t\undefined
\let\s\undefined
\let\n\undefined
\let\u\undefined
\let\d\undefined
\let\v\undefined
\let\m\undefined
\newif\ifnumberedProblems
\numberedProblemsfalse% Default to no numbers, as that was previous behavior.
\DeclareOption{onlineProblemNumbers}{\numberedProblemstrue}
\newif\ifhandout
\handoutfalse
\DeclareOption{handout}{\handouttrue}
\newif\ifnoauthor
\noauthorfalse
\DeclareOption{noauthor}{\noauthortrue}
\newif\ifnooutcomes
\nooutcomesfalse
\DeclareOption{nooutcomes}{\nooutcomestrue}
\newif\ifinstructornotes
\instructornotesfalse
\DeclareOption{instructornotes}{\instructornotestrue}
\DeclareOption{noinstructornotes}{\instructornotestrue}
\newif\ifhints
\hintsfalse
\DeclareOption{hints}{\hintstrue}
\newif\ifnewpage
\newpagefalse
\DeclareOption{newpage}{\newpagetrue}
\newif\ifnumbers
\numbersfalse
\DeclareOption{numbers}{\numberstrue}
\newif\ifwordchoicegiven
\wordchoicegivenfalse
\DeclareOption{wordchoicegiven}{\wordchoicegiventrue}
\newif\iffirstinlinechoice% Support for other wordchoice command contents.
\firstinlinechoicetrue
\newif\ifxake
\xakefalse
\DeclareOption{xake}{\xaketrue}
\newif\iftikzexport
\tikzexportfalse
\DeclareOption{tikzexport}{%
\tikzexporttrue%
\handoutfalse%
\numbersfalse%
\newpagefalse%
\hintsfalse%
\nooutcomesfalse%
}
\DeclareOption*{%
\PassOptionsToClass{\CurrentOption}{article}%
}
\ProcessOptions\relax
\LoadClass{article}
\ifdefined\HCode
\xaketrue%
\tikzexporttrue%
\handoutfalse%
\numbersfalse%
\newpagefalse%
\hintsfalse%
\nooutcomesfalse%
\fi
\RequirePackage[makeroom]{cancel}
\RequirePackage[inline]{enumitem}
\RequirePackage[pagestyles]{titlesec}
\RequirePackage{titletoc}
\RequirePackage{titling}
\RequirePackage{url}
\RequirePackage[table]{xcolor}
\RequirePackage{tikz}
\RequirePackage{pgfplots}
\usepgfplotslibrary{groupplots}
\usetikzlibrary{calc}
\RequirePackage{fancyvrb}
\RequirePackage{forloop}
\RequirePackage{environ}% Included to allow saving of environment contents. This does *not* play well with various verbatem environments however and would be great to find a way around utilizing this package. One option is the "Suppress" command included below.
\RequirePackage{amssymb}% Included to have access to math typeset.
\RequirePackage{amsmath}% Included to have access to math typeset.
\RequirePackage{amsthm}% Included to have access to math typeset.
\RequirePackage{xifthen}% http://ctan.org/pkg/xifthen
\RequirePackage{multido}% http://ctan.org/pkg/multido
\RequirePackage{listings} %% is this required???
\RequirePackage{xkeyval}
\RequirePackage{currfile}
\RequirePackage{comment}
\RequirePackage{gettitlestring}
\RequirePackage{nameref}
\RequirePackage{epstopdf}
\ifdefined\reallyneverever
\ifdefined\HCode
\tikzexporttrue
\fi
\iftikzexport
\usetikzlibrary{external}
\ifdefined\HCode
% in htlatex, just include the svg files
\def\pgfsys@imagesuffixlist{.svg}
\tikzexternalize[prefix=./,mode=graphics if exists]
\else
% in pdflatex, actually generate the svg files
\tikzset{
/tikz/external/system call={
pdflatex \tikzexternalcheckshellescape
-halt-on-error -interaction=batchmode
-jobname "\image" "\\PassOptionsToClass{tikzexport}{ximera}\texsource";
mutool draw -F svg \image.pdf > \image.svg ; % mutool adds "1" to filename ????
mutool draw -o \image.svg \image.pdf ;
mutool draw -r 150 -c rgbalpha -o \image.png \image.pdf ;
ebb -x \image.png
}
}
\tikzexternalize[optimize=false,prefix=./]
\fi
\fi
\fi
\ifdefined\HCode
\RequirePackage{hyperref}
\else
\RequirePackage[pdfpagelabels,colorlinks=true,allcolors=blue!30!black]{hyperref}
\pdfstringdefDisableCommands{\def\hskip{}}%% quiets warning
\fi
\font\dummyft@=dummy \relax
\def\suppress{%
\begingroup\par
\parskip\z@
\offinterlineskip
\baselineskip=\z@skip
\lineskip=\z@skip
\lineskiplimit=\maxdimen
\dummyft@
\count@\sixt@@n
\loop\ifnum\count@ >\z@
\advance\count@\m@ne
\textfont\count@\dummyft@
\scriptfont\count@\dummyft@
\scriptscriptfont\count@\dummyft@
\repeat
\let\selectfont\relax
\let\mathversion\@gobble
\let\getanddefine@fonts\@gobbletwo
\tracinglostchars\z@
\frenchspacing
\hbadness\@M}
\def\endsuppress{\par\endgroup}
\newcommand{\Make@Counter}[1]{% This is an internal macro that should probably be depreciated for the below universal macro.
\@ifundefined{c@#1}% Check to see if counter exists
{ % If not, create it and set it to 0.
\newcounter{#1}
\setcounter{#1}{0}
}
{%If so, reset to 0.
\setcounter{#1}{0}
}
}
\newcommand{\MakeCounter}[1]{%% Code located in "Utilitymacros.dtx"
\@ifundefined{c@#1}% Check to see if counter exists
{ % If not, create it and set it to 0.
\newcounter{#1}
\setcounter{#1}{0}
}
{%If so, reset to 0.
\setcounter{#1}{0}
}
}
\setlength{\parindent}{0pt}
\setlength{\parskip}{5pt}
\oddsidemargin 62pt
\evensidemargin 62pt
\textwidth 345pt
\headheight 14pt
\newcommand{\license}{\excludecomment}
\newcommand{\acknowledgement}{\excludecomment}
\renewcommand{\tag}{\excludecomment}
\everymath{\displaystyle}
\let\prelim\lim
\renewcommand{\lim}{\displaystyle\prelim}
\theoremstyle{definition} % No italic (because this makes also text in TikZ italic !!!)
\newtheorem{theorem}{\GetTranslation{Theorem}}
\newtheorem{algorithm}{\GetTranslation{Algorithm}}
\newtheorem{axiom}{\GetTranslation{Axiom}}
\newtheorem{claim}{\GetTranslation{Claim}}
\newtheorem{conclusion}{\GetTranslation{Conclusion}}
\newtheorem{condition}{\GetTranslation{Condition}}
\newtheorem{conjecture}{\GetTranslation{Conjecture}}
\newtheorem{corollary}{\GetTranslation{Corollary}}
\newtheorem{criterion}{\GetTranslation{Criterion}}
\newtheorem{definition}{\GetTranslation{Definition}}
\newtheorem{example}{\GetTranslation{Example}}
\newtheorem*{explanation}{\GetTranslation{Explanation}}
\newtheorem{fact}{\GetTranslation{Fact}}
\newtheorem{lemma}{\GetTranslation{Lemma}}
\newtheorem{formula}{\GetTranslation{Formula}}
\newtheorem{idea}{\GetTranslation{Idea}}
\newtheorem{notation}{\GetTranslation{Notation}}
\newtheorem{model}{\GetTranslation{Model}}
\newtheorem{observation}{\GetTranslation{Observation}}
\newtheorem{proposition}{\GetTranslation{Proposition}}
\newtheorem{paradox}{\GetTranslation{Paradox}}
\newtheorem{procedure}{\GetTranslation{Procedure}}
\newtheorem{remark}{\GetTranslation{Remark}}
\newtheorem{summary}{\GetTranslation{Summary}}
\newtheorem{template}{\GetTranslation{Template}}
\newtheorem{warning}{\GetTranslation{Warning}}
\renewcommand{\theenumi}{\textup{(\alph{enumi})}}
\renewcommand{\labelenumi}{\theenumi}
\renewcommand{\theenumii}{\textup{(\roman{enumii})}}
\renewcommand{\labelenumii}{\theenumii}
\renewcommand{\qedsymbol}{$\blacksquare$}
\renewenvironment{proof}[1][\proofname]
{\begin{trivlist}\item[\hskip \labelsep \itshape \bfseries #1{}\hspace{2ex}]}
{\qed\end{trivlist}}
\ifxake
\newenvironment{prompt}{}{}
\else
\ifhandout
\NewEnviron{prompt}{}
% Breaks when put in mathmode ?
% \newenvironment{prompt}{\suppress}{\endsuppress}
\else
\newenvironment{prompt}{\bgroup\color{gray!50!black}}{\egroup}
\fi
\fi
\ifdefined\HCode
\newenvironment{onlyPdf}{\setbox0\vbox\bgroup}{\egroup}
\newenvironment{onlyHtml}{\bgroup}{\egroup}
\newenvironment{onlineOnly}{\bgroup}{\egroup}
\else
\newenvironment{onlyPdf}{\bgroup}{\egroup}
\ifdefined\xmPrintHtmlOnlyAlsoInPdf
\newenvironment{onlyHtml}{\bgroup\color{red!50!black}}{\egroup}
\newenvironment{onlineOnly}{\bgroup\color{red!50!black}}{\egroup}
\else
\newenvironment{onlyHtml}{\setbox0\vbox\bgroup}{\egroup}
\newenvironment{onlineOnly}{\setbox0\vbox\bgroup}{\egroup}
\fi
\fi
\ifdefined\HCode
\newcommand{\pdfOnly}[1]{}
\newcommand{\htmlOnly}[1]{#1}
\else
\ifdefined\xmPrintHtmlOnlyAlsoInPdf
\newcommand{\pdfOnly}[1]{#1}
\newcommand{\htmlOnly}[1]{\bgroup\color{red!50!black}#1\egroup}
\else
\newcommand{\pdfOnly}[1]{#1}
\newcommand{\htmlOnly}[1]{}
\fi
\fi
\providecommand{\ifonlineTF}[2]{\htmlOnly{#1}\pdfOnly{#2}}
\newif{\ifonline}
\ifdefined\HCode
\onlinetrue
\else
\onlinefalse
\fi
\newcommand{\preOutcomeLine}{\item }
\newcommand{\postOutcomeLine}{}
\newcommand{\preOutcomeBlock}{After completing this content, students should be able to: \begin{itemize}}
\newcommand{\postOutcomeBlock}{\end{itemize} So go forth and learn!}
\newcommand{\outcomeHeader}{Goals for this Section}
\htmlOnly{
\newcommand{\outcomeBlock}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="outcomeHead">} \outcomeHeader \ifvmode\IgnorePar\fi\EndP\HCode{</div>} \ifvmode\IgnorePar\fi\EndP\HCode{<div class="outcomeContent">}}
}
\newwrite\outcomefile
\immediate\openout\outcomefile=\jobname.oc
\newcommand{\outcome}[1]{%
\immediate\write\outcomefile{\expandafter\unexpanded\expandafter{\preOutcomeLine #1} \expandafter\unexpanded\expandafter{\postOutcomeLine}}
}
\newcommand{\displayOutcomes}[1][]{%
\immediate\closeout\outcomefile
\IfFileExists{\currfiledir\currfilebase.oc}{
\htmlOnly{\outcomeBlock}
\expandafter\preOutcomeBlock
\input{\currfiledir\currfilebase.oc}
\postOutcomeBlock
\htmlOnly{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
}
{
\IfFileExists{\currfilebase.oc}{
\htmlOnly{\outcomeBlock}
\expandafter\preOutcomeBlock
\input{\currfilebase.oc}
\postOutcomeBlock
\htmlOnly{\ifvmode\IgnorePar\fi\EndP\HCode{</div>}}
}
{
No outcome file found.
}
}
}
\newcommand{\hang}{% top theorem decoration
\begingroup%
\setlength{\unitlength}{.005\linewidth}% \linewidth/200
\begin{picture}(0,0)(1.5,0)%
\linethickness{1pt} \color{black!50}%
\put(-3,2){\line(1,0){206}}% Top line
\multido{\iA=2+-1,\iB=50+-10}{5}{% Top hangs
\color{black!\iB}%
\put(-3,\iA){\line(0,-1){1}}% Top left hang
}%
\end{picture}%
\endgroup%
}%
\newcommand{\hung}{% bottom theorem decoration
\nobreak
\begingroup%
\setlength{\unitlength}{.005\linewidth}% \linewidth/200
\begin{picture}(0,0)(1.5,0)%
\linethickness{1pt} \color{black!50}%
\put(60,0){\line(1,0){143}}% Bottom line
\multido{\iA=0+1,\iB=50+-10}{5}{% Bottom hangs
\color{black!\iB}%
\put(203,\iA){\line(0,1){1}}% Bottom right hang
\put(\iB,0){\line(60,0){10}}% Left fade out
}%
\end{picture}%
\endgroup%
}%
\MakeCounter{Iteration@probCnt}
\MakeCounter{problem}
\newcommand{\problemNumber}{
\ifcsname c@depth\Roman{problem@Depth}Count\endcsname% Check to see if counter exists
\else
\expandafter\newcounter{depth\Roman{problem@Depth}Count}
\expandafter\setcounter{depth\Roman{problem@Depth}Count}{0}
\fi
\expandafter\stepcounter{depth\Roman{problem@Depth}Count}
\arabic{depthICount}% The first problem depth, what use to be |\theproblem|.
\forloop{Iteration@probCnt}{2}{\arabic{Iteration@probCnt} < \numexpr \value{problem@Depth} + 1 \relax}{%
.\expandafter\arabic{depth\Roman{Iteration@probCnt}Count}% Get the problem number of the next depth level and append it with a ".".
}
}
%%%%%% Configure various problem environment commands
\Make@Counter{problem@Depth}
%%%% Configure environments start content
\newcommand{\problemEnvironmentStart}[2]{%
\stepcounter{problem@Depth}% Started a problem, so we've sunk another problem layer.
\def\spaceatend{#1}%
\begin{trivlist}%
\item[\hskip\labelsep\sffamily\bfseries\GetTranslation{#2} \problemNumber% Determine the correct number of the problem, and the format of that number.
]%
\slshape
}
%%%%% Configure environments end content %%%%%%
\newcommand{\problemEnvironmentEnd}{%This configures all the end content for a problem.
\stepcounter{problem@Depth}
\ifcsname c@depth\Roman{problem@Depth}Count\endcsname
\expandafter\ifnum\expandafter\value{depth\Roman{problem@Depth}Count}>0
\expandafter\setcounter{depth\Roman{problem@Depth}Count}{0}
\fi
\fi
\addtocounter{problem@Depth}{-2}% Exited a problem so we've exited a problem layer. Need -2 because we steppped once at the start to check for needing a depth-level count reset.
\ifhandout
\ifnewpage
\newpage
\fi
\fi
\end{trivlist}
}
%% Add a simple command that handles all the problem creation aspects:
\newcommand{\createProblemEnv}[2]{% This is a nice command to define a new problem-like environment for a content-author.
\newenvironment{#1}[1][2in]%
{%Env start code
\problemEnvironmentStart{#1}{#2}
}
{%Env end code
\problemEnvironmentEnd
}
}
%%%% Now populate the old environment names
\createProblemEnv{problem}{Problem}
\createProblemEnv{exercise}{Exercise}
\createProblemEnv{exploration}{Exploration}
\createProblemEnv{question}{Question}
\newcounter{hintLevel}
\setcounter{hintLevel}{0}
\newenvironment{hint}{}{}
\renewenvironment{hint}
{
\ifhandout
\setbox0\vbox\bgroup
\else
\begin{trivlist}\item[\hskip \labelsep\small\slshape\bfseries \GetTranslation{Hint}:\hspace{2ex}]
\small\slshape
\fi
\stepcounter{hintLevel}
}
{
\ifhandout
\egroup\ignorespacesafterend
\else
\end{trivlist}
\fi
\addtocounter{hintLevel}{-1}
}
\ifhints
\renewenvironment{hint}{
\begin{trivlist}\item[\hskip \labelsep\small\slshape\bfseries \GetTranslation{Hint}:\hspace{2ex}]
\small\slshape
}
{
\end{trivlist}
}
\fi
\let\abstract\relax
\let\endabstract\relax
\NewEnviron{abstract}{\protected@xdef\theabstract{\BODY}}
\let\@emptyauthor\@author
\def\@authorfootnote{\gdef\@thefnmark{}\@footnotetext}
\def\author#1{\gdef\@author{#1}}
\def\@author{\@latex@warning@no@line{No \noexpand\author given}}
\def\and{and }
\let\title\relax
\newcommand{\title}[1][]{{\protected@xdef\@pretitle{#1}}\protected@xdef\@title}
\title{}
\newcounter{titlenumber}
\renewcommand{\thetitlenumber}{\arabic{titlenumber}}
\setcounter{titlenumber}{0}
\newpagestyle{main}{
\sethead[\textsl{\ifnumbers\thetitlenumber\hspace{1em}\fi\@title}][][] % even
{}{}{\textsl{\ifnumbers\thetitlenumber\hspace{1em}\fi\@title}} % odd
\setfoot[\thepage][][] % even
{}{}{\thepage} % odd
}
\pagestyle{main}
\renewcommand\maketitle{%
\addtocounter{titlenumber}{1}%
{\flushleft\large\bfseries \@pretitle\par\vspace{-1em}}
{\flushleft\LARGE\bfseries {\ifnumbers\thetitlenumber\fi}{\ifnumbers\hspace{1em}\else\hspace{0em}\fi}\@title \par }
\phantomsection%
\ifnumbers\addcontentsline{toc}{section}{\thetitlenumber~\@title}\else\addcontentsline{toc}{section}{\@title}\fi
\vskip .6em\noindent\textit\theabstract\setcounter{problem}{0}\setcounter{section}{0}\setcounter{subsection}{0}\par\vspace{2em}
%\ifnooutcomes\else\let\thefootnote\relax\footnote{Learning outcomes: \theoutcomes}\fi% Depreciated with new outcome mechanism.
\ifnoauthor\else\@authorfootnote{Author(s):~\@author}\fi
\aftergroup\@afterindentfalse
\aftergroup\@afterheading}
\ifnumbers
\setcounter{secnumdepth}{2}
\renewcommand{\thesection}{\arabic{titlenumber}.\arabic{section}}
\renewcommand{\thesubsection}{\arabic{titlenumber}.\arabic{section}.\arabic{subsection}}
\else
\setcounter{secnumdepth}{-2}
\fi
\def\activitystyle{}
\newcounter{sectiontitlenumber}
\setcounter{secnumdepth}{2}
\setcounter{tocdepth}{2}
\newcommand\chapterstyle{%
\def\activitystyle{activity-chapter}
\def\maketitle{%
\addtocounter{titlenumber}{1}%
{\flushleft\small\sffamily\bfseries\@pretitle\par\vspace{-1.5em}}%
{\flushleft\LARGE\sffamily\bfseries\thetitlenumber\hspace{1em}\@title \par }%
{\vskip .6em\noindent\textit\theabstract\setcounter{problem}{0}\setcounter{section}{0}}%
\par\vspace{2em}
\phantomsection\addcontentsline{toc}{section}{\textbf{\thetitlenumber\hspace{1em}\@title}}%
}}
\newcommand\sectionstyle{%
\def\activitystyle{activity-section}
\def\maketitle{%
\addtocounter{section}{1}
\setcounter{sectiontitlenumber}{\value{section}}
{\flushleft\small\sffamily\bfseries\@pretitle\par\vspace{-1.5em}}%
{\flushleft\Large\sffamily\bfseries\thetitlenumber.\thesectiontitlenumber\hspace{1em}\@title \par}%
{\vskip .6em\noindent\textit\theabstract\setcounter{subsection}{0}}%
\par\vspace{2em}
\phantomsection\addcontentsline{toc}{section}{\thetitlenumber.\thesectiontitlenumber\hspace{1em}\@title}%
\renewcommand\section{\@startsection{subsection}{2}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\large\bfseries}}
\renewcommand\subsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
}}
\iftikzexport%% allows xake to handle \chapterstyle and \sectionstye
\renewcommand\chapterstyle{\def\activitystyle{chapter}}
\renewcommand\sectionstyle{\def\activitystyle{section}}
\else
\fi
\providecommand{\xmDefaultGraphicsPath}{/xmPictures}
\graphicspath{ %% When looking for images,
{./} %% look here first,
{.\xmDefaultGraphicsPath/} %% then look for a pictures folder,
{..\xmDefaultGraphicsPath/} %% then look for a pictures folder,
{../..\xmDefaultGraphicsPath/} %% then look for a pictures folder,
{../../..\xmDefaultGraphicsPath/} %% then look for a pictures folder,
}
\NewEnviron{image}[1][3in]{%
\begin{center}\resizebox{#1}{!}{\BODY}\end{center}% resize and center
}
\newcommand{\alt}[1]{} %% Deprecated
\providecommand\xmaltprint{}
%% use \undef\xmaltprint to NOT have \xmalt output in the PDF
\newcommand{\xmalt}[1]{% %% see infra for HTML implementation; 2026, J. Kuan
\ifdefined\xmaltprint%
{\footnotesize\color{gray}Alt text: #1}%
\fi%
}
\DefineVerbatimEnvironment{javascript}{Verbatim}{numbers=left,frame=lines,label=JavaScript,labelposition=topline}
\def\js#1{\mbox{\texttt{\detokenize{#1}}}}
\define@key{interactive}{id}{\def\interactive@id{#1}}
\setkeys{interactive}{id=}
\newcommand{\includeinteractive}[2][]{
\setkeys*{interactive}{#1}%
\ifthenelse{\equal{\interactive@id}{}}{}{\recordvariable{\interactive@id}}
Interactive
}
\newcommand{\geogebra}[3]{GeoGebra link: \url{https://www.geogebra.org/m/#1}}
\newcommand{\doenet}[3]{Doenet link: \url{https://beta.doenet.org/activityViewer/#1}}%
\newcommand{\desmos}[3]{Desmos link: \url{https://www.desmos.com/calculator/#1}}
\newcommand{\desmosThreeD}[3]{Desmos3D link: \url{https://www.desmos.com/3d/#1}}
\newcommand{\googleSheet}[5]{%
Google Spreadsheet link: \expandafter\url{\detokenize{https://docs.google.com/spreadsheets/d/#1}}%
}
\newcommand{\graph}[2][]{\text{Graph of $#2$}}
%% \link[name]{url} (opens in new tab)
%% \link*[name]{url} (opens in *same* tab) (this was default behaviour for \link till 2025/06))
%% In PDF \link[name]{url} uses \href but adds a Footnote with the url
%% The footnote is not added after \let\xmLinkHasFootnote\undefined
\def\xmLinkHasFootnote{1}
\NewDocumentCommand{\link}{s o m}%
{%
\ifdefined\HCode%
\IfBooleanTF{#1}%
{ % Starred version %
\IfNoValueTF{#2}%
{ \HCode{<a href="#3">}\Hurl{#3}\HCode{</a>}}%
{ \HCode{<a href="#3">}#2\HCode{</a>}}%
}%
{ % Unstarred version%
\IfNoValueTF{#2}%
{ \HCode{<a href="#3" target="_blank">}\Hurl{#3}\HCode{</a>}}%
{ \HCode{<a href="#3" target="_blank">}#2\HCode{</a>}}%
}%
\else % PDF %
\IfNoValueTF{#2}%
{\url{#3}}%
{\href{#3}{#2}\ifdefined\xmLinkHasFootnote\footnote{See #2 at \url{#3}}\fi}% SWITCH ARGS ... !%
\fi%
}%
\newcommand{\youtube}[1]{YouTube link: \url{https://www.youtube.com/watch?v=#1}}
\ifdefined\HCode
\newcommand{\recordvariable}[1]{}
\else
\newwrite\idfile
\immediate\openout\idfile=\jobname.ids
\newcommand{\recordvariable}[1]{\ifthenelse{\equal{#1}{}}{}{\immediate\write\idfile{var #1;}}}
\fi
\define@key{answer}{given}[true]{\def\ans@given{#1}}
\define@key{answer}{tolerance}{\def\ans@tol{#1}}
\define@key{answer}{validator}{}
\define@key{answer}{id}{\def\ans@id{#1}}
\define@key{answer}{format}{}
\define@key{answer}{onlinenoinput}[false]{}
\define@key{answer}{onlineshowanswerbutton}[false]{}
\setkeys{answer}{id=,given=false,onlinenoinput=false,onlineshowanswerbutton=false}
\newcommand{\answerFormatLength}{2cm}
\newcommand{\answerFormatDots}[1]{\ldots\ldots}
\newcommand{\answerFormatLine}[1]{\protect\rule{\answerFormatLength}{0.4pt}}
\newcommand{\answerFormatFlexibleLine}[1]{\protect\rule{\widthof{$#1$}*2}{0.4pt}}
\newcommand{\answerFormatFlexibleBox}[1]{\fbox{\scalebox{2}{\phantom{$#1$}}}}
\newcommand{\answerFormatPlain}[1]{\ensuremath{#1}}
\newcommand{\answerFormatBlue}[1]{\color{blue}\ensuremath{#1}}
\newcommand{\answerFormatBoxed}[1]{\fbox{\ensuremath{#1}}}
\newcommand{\answerFormatBoxedGiven}[1]{\underset{\scriptstyle\mathrm{given}}{\fbox{\ensuremath{#1}}}}
\let\handoutAnswerFormat\answerFormatDots
\let\defaultAnswerFormat\answerFormatBlue
\let\givenAnswerFormat\answerFormatBoxedGiven
\newcommand{\answer}[2][]{%
\ifmmode%
\setkeys{answer}{#1}%
\recordvariable{\ans@id}
\ifthenelse{\boolean{\ans@given}}
{% Start then statement
\ifhandout
#2
\else
\givenAnswerFormat{#2} %% in case the argument helps formatting
\fi
}% End then statement
{% Start else statement
\ifhandout
\handoutAnswerFormat{#2} %% in case the argument helps formatting
\else% show answer in box outside handout mode
\defaultAnswerFormat{#2} %% in case the argument helps formatting
\fi
}% End else statement
\else%
\GenericError{\space\space\space\space}% Throw an error based on... something? -- Jason
{Attempt to use \@backslashchar answer outside of math mode}
{See https://github.com/ximeraProject/ximeraLatex for explanation.}
{Need to use either inline or display math.}%
\fi
}
\define@key{choice}{value}[]{\def\choice@value{#1}}
\define@boolkey{choice}{correct}[true]{\def\choice@correct{#1}}
\define@key{multipleChoice}{id}{\def\mc@id{#1}}
\define@key{otherchoice}{value}[]{\def\otherchoice@value{#1}}
\define@boolkey{otherchoice}{correct}[true]{\def\otherchoice@correct{#1}}
\setkeys{choice}{correct=false,value=}
\setkeys{multipleChoice}{id=}
\setkeys{otherchoice}{correct=false,value=}
\newcommand{\choice}[2][]{%
\setkeys{choice}{#1}%
\item{#2}
\ifthenelse{\boolean{\choice@correct}}
{% Begin then result
\ifhandout% if it's a handout do nothing.
\else% otherwise place a checkmark when you select the "correct choice"... maybe? -- Jason
\,\checkmark\,\setkeys{choice}{correct=false}
\fi
}% End then result
{}% Begin/End else result.
}
\newcommand{\choiceEXP}[2][]{%
\expandafter\setkeys\expandafter{choice}{#1}%
\item{#2}
\ifthenelse{\boolean{\choice@correct}}
{% Begin then result
\ifhandout
\else
\,\checkmark\,\setkeys{choice}{correct=false}
\fi
}% End then result
{}% Begin/End else result.
} %% note all the {} are needed in case the choice has [] in it.
\newcommand{\otherchoice}[2][]{%
\ignorespaces%
\setkeys{otherchoice}{#1}%
\ifthenelse{\boolean{\otherchoice@correct}}%
{% Start then result
#2\ignorespaces\setkeys{otherchoice}{correct=false}\ignorespaces%
}% End then result
{}% Start/End else result
\ignorespaces%
}%
\newcommand{\inlinechoice}[2][]{%
\setkeys{choice}{#1}%
\iffirstinlinechoice
(\hspace{-.25em}
\firstinlinechoicefalse
\else
/
\fi
#2
\ifthenelse{\boolean{\choice@correct}}%
{% Start then result
\ifhandout\else\checkmark\ignorespaces\setkeys{choice}{correct=false}\ignorespaces\fi%
}% End then result
{}% Start/End else result
\hspace{-.25em}\ignorespaces%
}
\newenvironment{multipleChoice}[1][]
{% Environment Start Code
\setkeys{multipleChoice}{#1}%
\recordvariable{\mc@id}%
\begin{trivlist}
\item[\hskip \labelsep\small\bfseries \GetTranslation{Multiple Choice}:]\hfil
\begin{enumerate}
}% Note this means that \item has to be the first line after \begin{multipleChoice}.
{% Environment End Code
\end{enumerate}
\end{trivlist}
}
\newenvironment{multipleChoice@}[1][]{}{)}
\newcommand{\wordChoice}[1]{%
\let\choicetemp\choice% Assign a "choicetemp" command to duplicate choice.
\ifwordchoicegiven% If wordchoice option is on, we need to juggle around some definitions.
\let\choice\otherchoice%
#1
\else% If it isn't the regular "choice" command should work.
\let\choice\inlinechoice%
\begin{multipleChoice@}%
#1%
\end{multipleChoice@}%
\fi%
\let\choice\choicetemp% Now that choicetmp has been manipulated to what we want, replace choice with it.
}%
\newenvironment{selectAll}[1][]
{\begin{trivlist}\item[\hskip \labelsep\small\bfseries \GetTranslation{Select All Correct Answers}:]\hfil\begin{enumerate}}
{\end{enumerate}\end{trivlist}}
%% solution environment
\ifhandout % what follows is handout behavior
\newenvironment{solution}%
{%
\setbox0\vbox\bgroup
}
{%
\egroup
}
\else
\newenvironment{solution}%
{%
\begin{trivlist}
\item[\hskip \labelsep\bfseries \GetTranslation{Solution}:\hspace{2ex}]
}
% %% line at the bottom}
{
\end{trivlist}
% (202410: no longer \par\addvspace{.5ex}\nobreak\noindent\hung
}
\fi
\newcommand{\PH@Command}{}
\newenvironment{validator}[1][]{
\def\PH@Command{#1}% Use PH@Command to hold the content and be a target for "\expandafter" to expand once.
\mbox{\texttt{\detokenize\expandafter{\PH@Command}}}% Now expand PH@Command once and then detokenize.
}{}
\ifhandout%
\newenvironment{feedback}
{%
\setbox0\vbox\bgroup
}
{%
\egroup
}
\else
\newenvironment{feedback}[1][attempt]{
\edef\PH@Command{\GetTranslation{#1}}% Use PH@Command to hold the content and be a target for "\expandafter" to expand once.
\begin{trivlist}% Begin the trivlist to use formating of the "Feedback" label.
\item[\hskip \labelsep\small\slshape\bfseries \GetTranslation{Feedback}% Format the "Feedback" label. Don't forget the space.
\ifonlineTF{% If the feedback is on a pdf, we don't need to detokenize - which messes with the \MakeUppercase command anyway.
(\texttt{\expandafter\detokenize\expandafter{\PH@Command}})}% Keep the online version the same as before.
{(\expandafter\texttt{\PH@Command})}:% No need for detokenize in the pdf version
\hspace{2ex}]\small\slshape% Insert some space before the actual feedback given.
}{
\end{trivlist}
}
\fi
\newboolean{given} %% required for freeResponse
\setboolean{given}{true} %% could be replaced by a key=value pair later if needed
\ifhandout
\newenvironment{freeResponse}[1][false]%
{%
\def\givenatend{\boolean{#1}}
\ifthenelse{\boolean{#1}}
{% Begin then result
\begin{trivlist}
\item
}% End then result
{% Begin else result
\setbox0\vbox\bgroup
}% End else result
}
{%
\ifthenelse{\givenatend}
{% Begin then result
\end{trivlist}
}% End then result
{% Begin else result
\egroup
}% End else result
}
\else
\newenvironment{freeResponse}[1][false]%
{% Environment Beginning Code
\ifthenelse{\boolean{#1}}%% Could probably change this with just putting the (given) in the boolean?-- Jason
{% Begin then result
\begin{trivlist}
\item[\hskip \labelsep\bfseries \GetTranslation{Free Response (Given)}:\hspace{2ex}]
}% End then result
{% Begin else result
\begin{trivlist}
\item[\hskip \labelsep\bfseries \GetTranslation{Free Response}:\hspace{2ex}]
}% End else result
}
{% Environment Ending Code
\end{trivlist}
}
\fi
\DefineVerbatimEnvironment{code}{Verbatim}{numbers=left,frame=lines,label=Code,labelposition=topline}
\DefineVerbatimEnvironment{python}{Verbatim}{numbers=left,frame=lines,label=Python,labelposition=topline}
\DefineVerbatimEnvironment{javascriptCode}{Verbatim}{numbers=left,frame=lines,label=JavaScript,labelposition=topline}
%%% On the web, translate verbatim and lstlisting blocks into |<pre>|
%%% elements.
%%% \begin{macrocode}
%%%<*cfgXimera>
%%\ConfigureEnv{verbatim}{\ifvmode\IgnorePar\fi\EndP\HCode{<pre style="white-space: pre; background-color: lightgray;" >}}{\ifvmode\IgnorePar\fi\EndP\HCode{</pre>}}{}{}
%%\ConfigureEnv{lstlisting}{\ifvmode\IgnorePar\fi\EndP\HCode{<pre>}}{\ifvmode\IgnorePar\fi\EndP\HCode{</pre>}}{}{}
%%%</cfgXimera>
%%% \end{macrocode}
\newenvironment{dialogue}{%
\renewcommand\descriptionlabel[1]{\hspace{\labelsep}\textbf{##1:}}
\begin{description}%
}{%
\end{description}%
}
%% instructor intro/instructor notes
%%
\ifhandout % what follows is handout behavior
\ifinstructornotes
\newenvironment{instructorIntro}%
{%
\begin{trivlist}
\item[\hskip \labelsep\bfseries \GetTranslation{Instructor Introduction}:\hspace{2ex}]
}
% %% line at the bottom}
{
\end{trivlist}
\par\addvspace{.5ex}\nobreak\noindent\hung
}
\else
\newenvironment{instructorIntro}%