-
Notifications
You must be signed in to change notification settings - Fork 3
/
mainfile.tex
1419 lines (1302 loc) · 48 KB
/
mainfile.tex
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
% !arara: pdflatex
% !arara: pdflatex
% !arara: pdflatex
\documentclass[10pt,twoside]{report}
%\documentclass[10pt,twoside,draft]{report}
% Last edited: Jordan, March 1st, 2013
%====================================
% BEGIN PACKAGES
%====================================
\usepackage[left=6cm,right=1cm,showframe=false, % page settings (showframe is useful!)
top=1.5cm,bottom=1.5cm,asymmetric=true,bindingoffset=1cm]{geometry}
\usepackage{parskip}
\usepackage{lipsum}
\usepackage{amssymb} % mathematical content
\usepackage{mathtools} % math tools such as \mathrlap, \mathllap, \mathclap
\usepackage[amsmath,standard,thmmarks]{ntheorem} % custom enumerations *Needs to stay here, otherwise cross references can go wrong*
\usepackage{etoolbox} % for conditionals, and lots more
\usepackage{environ} % for help with environments
\usepackage{answers} % solutions to problems done *beautifully*
%\usepackage[nosolutionfiles]{answers}
\usepackage[framemethod=tikz]{mdframed} % needed for putting boxes round theorems, examples
\usepackage[explicit]{titlesec}
\usepackage{multicol} % multicols
\usepackage{changepage} % needed for widepage (for exercises)
\usepackage{fancyhdr} % headers & footers
\usepackage[small,bf]{caption} % figures/tables in margins, and not floating
\usepackage{subcaption} % subfigures, subtables (replaces subfig)
\usepackage{xstring} % needed to determine if problems are odd or even
\usepackage{makeidx} % make an index
\usepackage{enumitem} % enumerate & itemize
\usepackage{placeins} % FloatBarrier
\usepackage{varioref} % informative references (such as, 'on the next page')
\usepackage{multirow} % multirow in tables
\usepackage{minitoc} % mini-table of contents
\usepackage{marginfix} % fixes margin notes (otherwise they can cut through pages)
\usepackage{textcomp} % gives symbols like \textcent and \textdegree
\usepackage{nicefrac} % \nicefrac{a}{b}
\usepackage{siunitx} % \si{\meter\per\second}, \SI{1}{\kilo\gram}, much more
\sisetup{quotient-mode = fraction,per-mode=fraction,fraction-function = \nicefrac}
\usepackage[super]{nth} % \nth{17} for 17th
\usepackage{mleftright} % for \mleft and \mright, which fix spacing issue in \left and \right
\usepackage{needspace} % needed to keep problems looking good (stops ugly pagebreaks)
\usepackage{xargs} % helps with optional arguments for environments
\usepackage{array} % used with tables (allows \newcolumntype)
\usepackage{booktabs} % used with tables (allows \toprulewidth etc)
\usepackage{flafter} % ensures that floats don't appear until after their placement in the text
\usepackage{pgfplots} % graphs and graphics (loads tikz and xcolor)
\usetikzlibrary{backgrounds}
\usetikzlibrary{shadows}
\usetikzlibrary{mindmap}
\usetikzlibrary{backgrounds}
\usetikzlibrary{fit}
\usetikzlibrary{positioning}
\usepackage[charter]{mathdesign} % changes font
\usepackage[expansion=false,kerning=true]{microtype} % better kerning
\usepackage[T1]{fontenc} % More reliable copy-and-pasting
\input{glyphtounicode} \pdfgentounicode=1 % More reliable copy-and-pasting
\usepackage{adjustbox} % used to provide better vertical alignment within solutions
\usepackage{pdfpages}
% load the hyperref (nearly) last
\usepackage{hyperref} % to allow hyper refs in the final pdf document
% hyperref NEEDS TO STAY AT THE END!
\usepackage[all]{hypcap} % needed to help hyperlinks direct correctly;
% note that this needs to be loaded AFTER
% the hyperref package; the option [all]
% makes hyperlinks to figures & tables go
% to the top
\usepackage{cleveref} % needs to be loaded after hyperref
% hyperref settings- it seemed to work better here rather than
% as options to the \usepackage call above
%
% breaklinks=true is really important! otherwise the varioref makes
% them go over the paragraph boundary!
\hypersetup{colorlinks=true,
linkcolor=blue%,breaklinks=true
}
% really useful during hyperlink debugging
%\usepackage[left]{showlabels}
%\showlabels{hypertarget}
%\showlabels{hyperlink}
\makeindex
%\listfiles
%\show\section % really useful command!
%====================================
% END PACKAGES
%====================================
% ====================================
% BEGIN GRAPH SETTINGS
% ====================================
%\usetikzlibrary{external}
%\tikzexternalize[mode=list and make]
% cycle list- truly awesome; see section 4.6.7, pg 129 of pgfplots
\pgfplotscreateplotcyclelist{pccstylelist}{%
color=red,mark=none,line width=1pt,<->\\%
color=blue,mark=none,line width=1pt,<->\\%
color=gray,mark=none,line width=1pt,<->\\%
}
% axis style, ticks, etc
\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
xlabel={$x$}, % default put x on x-axis
ylabel={$y$}, % default put y on y-axis
scale only axis, % otherwise width won't be as intended: http://tex.stackexchange.com/questions/36297/pgfplots-how-can-i-scale-to-text-width
cycle list name=pccstylelist,
tick label style={font=\tiny},
label style={font=\small},
legend cell align=left,
legend style={font=\tiny},
width=\textwidth,
every node near coord/.append style={
font=\small},
}}
\tikzset{axisnode/.style={font=\tiny,text=black}}
% line style
\pgfplotsset{pccplot/.style={color=red,mark=none,line width=1pt,<->}} % this is pretty redundant in most cases now that cycle list is implemented
\pgfplotsset{asymptote/.style={color=red,mark=none,line width=1pt,dashed}}
\pgfplotsset{soldot/.style={color=red,only marks,mark=*}}
\pgfplotsset{holdot/.style={color=red,fill=white,only marks,mark=*}}
% bar chart style
\pgfplotsset{pccbar/.style={ybar,draw=blue,fill=blue!20}}
% arrow style
\tikzset{>=stealth}
% framing the graphs
\pgfplotsset{framed/.style={axis background/.style ={draw=gray}}}
% next line is a bit more colourful
%\pgfplotsset{framed/.style={axis background/.style ={draw=gray,fill=yellow!20,rounded corners=3ex}}}
% grid style
\pgfplotsset{grid style={dashed,gray}}
% if draft mode is specified then just draw a rectangle
% http://tex.stackexchange.com/questions/60434/draft-mode-for-pgfplots
\makeatletter
\@tempswafalse
\def\@tempa{draft}
\@for\next:=\@classoptionslist\do
{\ifx\next\@tempa\@tempswatrue\fi}
\if@tempswa % draft option is active
\let\tikz@@tikzpicture\tikzpicture
\let\tikz@@endtikzpicture\endtikzpicture
\patchcmd\tikz@opt{\tikzpicture}{\tikz@@tikzpicture}{}{}
\patchcmd\tikz@collectnormalsemicolon{\endtikzpicture}{\tikz@@endtikzpicture}{}{}
\chardef\@tempa=\catcode`\;
\catcode`\;=\active
\patchcmd\tikz@collectactivesemicolon{\endtikzpicture}{\tikz@@endtikzpicture}{}{}
\catcode`\;=\@tempa
\let\tikzpicture\relax
\let\endtikzpicture\relax
\NewEnviron{tikzpicture}{%
\begin{pgfpicture}
\pgfpathrectanglecorners{\pgfpointorigin}{\pgfpoint{3cm}{3cm}}%
\pgfusepath{stroke}
\end{pgfpicture}%
}
\fi
\makeatother
%Without the following, corves that are plotted using coordinates have arrow tips at the end that point in the wrong direction
\makeatletter
\def\pgf@plot@curveto@handler@finish{%
\ifpgf@plot@started%
\pgfpathcurvebetweentimecontinue{0}{0.995}{\pgf@plot@curveto@first}{\pgf@plot@curveto@first@support}{\pgf@plot@curveto@second}{\pgf@plot@curveto@second}%
\fi%
}
\makeatother
% ====================================
% END GRAPH SETTINGS
% ====================================
% figure width
\newlength{\figurewidth}
% set solution figure width
\newlength{\solutionfigurewidth}
\setlength{\solutionfigurewidth}{5cm}
% Figure 1.1, 1.2,... The figure, and table numbering inherits the section numbering
%\numberwithin{figure}{section}
%\numberwithin{table}{section}
% caption setup
\captionsetup[table]{skip=0pt}
\captionsetup[subfigure]{labelformat=parens,labelfont=normal}
\captionsetup[subtable]{labelformat=parens,labelfont=normal}
% itemize and enumerate settings
\setlist{itemsep=0.05em,topsep=0.01em}
\setlist[enumerate]{label*=(\alph*)}
% paragraph settings
%\setlength{\parskip}{3.0mm}
%\setlength{\parindent}{0.0mm}
% use left margin
\reversemarginpar
\setlength{\marginparwidth}{5cm}
% define own color
\definecolor{silver}{rgb}{0.95,0.95,0.95}
% wide page for side by side figures, tables, etc
\newlength{\offsetpage}
\setlength{\offsetpage}{4.0cm}
\newenvironment{widepage}{\begin{adjustwidth}{-\offsetpage}{}%
\addtolength{\textwidth}{\offsetpage}}%
{\end{adjustwidth}}
% Define fix command
% - it puts a comment in the margin
% - it writes to a file with a list of things that need fixing
\newcommand{\fixthis}[1]
{%
\marginpar{\huge \color{red} \framebox{FIX}}%
\typeout{FIXTHIS: p\thepage : #1^^J}%
}
% Define pccname command
% - it writes to the log file with a detail of the name-
% this is useful for tracking names for diversity purposes
\newcommand{\pccname}[1]
{%
#1%
\typeout{PCCNAME: p\thepage : #1}%
}
% steps environment
\newlist{steps}{enumerate}{3}
\setlist[steps]{label*=($S_\arabic*$)}
% we might want to change the steps as we proceed through
% the different topics- for example, in polynomial functions
% we may want P1, P2, ..., and in rational functions we
% might want R1, R2, ..., etc
%
% The following command should ease the process
\newcommand{\reformatstepslist}[1]{\setlist[steps]{label*=(${#1}_\arabic*$)}}
% properties (of exponentials, logarithms, etc) list
\newlist{props}{enumerate}{3}
\setlist[props]{label*=($L_\arabic*$)}
\newcommand{\reformatpropslist}[1]{\setlist[props]{label*=(${#1}_\arabic*$)}}
%====================================
% BEGIN CLEVEREF
%====================================
% each of the following has two versions
% \crefname{environmentname}{singular}{plural}, to be used mid-sentence
% \Crefname{environmentname}{singular}{plural}, to be used at the beginning of a sentence
% standard environments
\crefname{table}{Table}{Tables}
\Crefname{table}{Table}{Tables}
\crefname{figure}{Figure}{Figures}
\Crefname{figure}{Figure}{Figures}
\crefname{section}{Section}{Sections}
\Crefname{section}{Section}{Sections}
\crefname{equation}{Equation}{Equations}
\Crefname{equation}{Equation}{Equations}
% custom environments
\crefname{problem}{Problem}{Problems}
\Crefname{problem}{Problem}{Problems}
\crefname{pccdefinition}{Definition}{Definitions}
\Crefname{pccdefinition}{Definition}{Definitions}
\crefname{pccexample}{Example}{Examples}
\Crefname{pccexample}{Example}{Examples}
\crefname{worksheet}{Worksheet}{Worksheets}
\Crefname{worksheet}{Worksheet}{Worksheets}
\crefname{subprobenumi}{Problem}{Problems}
\Crefname{subprobenumi}{Problem}{Problems}
\crefname{stepsi}{step}{steps}
\Crefname{stepsi}{Step}{Steps}
\crefname{propsi}{property}{properties}
\Crefname{propsi}{Property}{Properties}
% conjunction between range; e.g Figures 1.2-1.3
\newcommand{\crefrangeconjunction}{--}
% Examples:
% \crefrange{exp:tab:findformula1}{exp:tab:findformula4}
% gives Tables 1-4
% \cref{exp:tab:findformula1,exp:tab:findformula4}
% gives Tables 1 and 4
%====================================
% END CLEVEREF
%====================================
%====================================
% BEGIN MARGIN ENVIRONMENTS (shamelessly copied from tufte documentclass)
%====================================
\makeatletter
% Margin float environment
\newsavebox{\@tufte@margin@floatbox}
\newenvironment{@tufte@margin@float}[2][-1.2ex]%
{\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begin{lrbox}{\@tufte@margin@floatbox}%
\begin{minipage}{\marginparwidth}%
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\noindent%
}
{\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\@tufte@margin@floatbox}}%
}
% Margin figure environment
\newenvironment{marginfigure}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{figure}%
\capstart\endgraf}% <-- Hyperlink jumps to start of 'marginfigure'
{\end{@tufte@margin@float}}
% Margin table environment
\newenvironment{margintable}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{table}%
\capstart\endgraf}% <-- Hyperlink jumps to start of 'margintable'
{\end{@tufte@margin@float}}
\makeatother
%====================================
% END MARGIN ENVIRONMENTS
%====================================
%====================================
% BEGIN SOLUTIONS TO PROBLEMS
%====================================
% open the answer files (short, long, and hints)
\Opensolutionfile{shortsolutions}
\Newassociation{shortsolution}{shortSoln}{shortsolutions}
\Opensolutionfile{longsolutions}
\Newassociation{longsolution}{longSoln}{longsolutions}
%\Opensolutionfile{hints}
%\Newassociation{hint}{hintSoln}{hints}
\newenvironment{hint}{\expandafter\comment}{\expandafter\endcomment}
% put titles in the solution files
\begin{Filesave}{shortsolutions}
% SHORT SOLUTIONS FILE
%
% This file is created automatically every time 111,112document.tex
% is compiled
%
% THERE IS NO POINT EDITING THIS FILE, AS IT CHANGES
% EVERY TIME YOU COMPILE!
%
% Begin by (re-)setting the chapter and section counters to 0
% which are used for hyperlinks from solutions to questions
%
% This allows us to put Problem 1, 2, 3, etc in every chapter
% as the hyperlinks have the form
%
% \hypertarget{soln:\theproblem:\thechapter:\thesection}{}
% \hypertarget{soln:\theproblem.\thesubproblem:\thechapter:\thesection}{}
%
\section*{Answers}
\setcounter{chapter}{0}
\setcounter{section}{0}
\end{Filesave}
\begin{Filesave}{longsolutions}
% LONG SOLUTIONS FILE
% Begin by (re-)setting the chapter counter to 0
% which is used for hyperlinks from solutions to questions
%
% This allows us to put Problem 1, 2, 3, etc in every chapter
% as the hyperlinks have the form \hypertarget{soln:#1\thechapter}{}
\section*{Answers (long)}
\setcounter{chapter}{0}
\setcounter{section}{0}
\end{Filesave}
%\Writetofile{hints}{\protect\section*{Hints}}
%====================================
% END SOLUTIONS TO PROBLEMS
%====================================
%====================================
% BEGIN php stuff
%====================================
\renewcommand{\solutionextension}{php}
\Opensolutionfile{crossrefsWEB}
\Writetofile{crossrefsWEB}{<?php}
\newcommand{\phpreference}[2]{%
\Writetofile{crossrefsWEB}{// page \thepage}%
\Writetofile{crossrefsWEB}{$#1=array("#2","\thepage");}%
%\marginpar{%
% \IfFileExists{geogebra-logo.eps}%
% {%
% \href{http://spot.pcc.edu/~chughes/}{\resizebox{2cm}{!}{\includegraphics{geogebra-logo.eps}}}%
% }%
% {%
% \href{http://spot.pcc.edu/~chughes/}{\fbox{\huge{www}}}%
% }%
%}%
}
%====================================
% END php stuff
%====================================
%====================================
% BEGIN CUSTOM THEOREMS (for problems, subproblems)
%====================================
% margin theorem
\makeatletter
\newtheoremstyle{marginpcc}%
{\item[\theorem@headerfont \llap{##1 ##2}]}%
{\item[\theorem@headerfont \llap{##1 ##2} -- ##3\theorem@separator\hskip\labelsep]}%
%{\item[\theorem@headerfont \llap{##1 ##2} -- ##3\IfEndWith{##3}{!}{}{\theorem@separator}\hskip\labelsep]}%
\newtheoremstyle{marginpccsoln}%
{\item[\theorem@headerfont \llap{##1}]}%
{\item[\theorem@headerfont \llap{##1} (##3): ]}%
\makeatother
% example (that uses an associated 'solution' )
\newcounter{pccexample}[section]
\theoremstyle{marginpcc}
\theorembodyfont{}
\theoremsymbol{\rlap{$\blacksquare$}}
\theoremprework{}
\theorempostwork{}
\theoremseparator{:}
\theorempreskip{\topskip}
\newtheorem{pccexample}{Example}%[chapter]
% associated solution for the example
\theoremstyle{marginpccsoln}
\theoremheaderfont{\itshape}
\theorembodyfont{}
\theorempostwork{}
\theoremseparator{}
\newtheorem{pccsolution}{Solution}
% make a nobreak \item, which won't allow a pagebreak
% to be put in. This is just a copy of \item and \@item
% from ltlists.dtx (texdoc source2e), with the \addpenalty\@itempenalty
% changed to \addpenalty\@M
%
% This is based on a question, answer, and comment discussion I had
% on tex exchange: http://tex.stackexchange.com/questions/47204/definitive-guide-to-trivlists/47586#47586
\makeatletter
\def\nobreakitem{%
\@inmatherr\nobreakitem
\@ifnextchar [\@nobreakitem{\@noitemargtrue \@nobreakitem[\@itemlabel]}}
\def\@nobreakitem[#1]{%
\if@noparitem
\@donoparitem
\else
\if@inlabel
\indent \par
\fi
\ifhmode
\unskip\unskip \par
\fi
\if@newlist
\if@nobreak
\@nbitem
\else
\addpenalty\@beginparpenalty
\addvspace\@topsep
\addvspace{-\parskip}%
\fi
\else
\addpenalty\@M
\addvspace\itemsep
\fi
\global\@inlabeltrue
\fi
\everypar{%
\@minipagefalse
\global\@newlistfalse
\if@inlabel
\global\@inlabelfalse
{\setbox\z@\lastbox
\ifvoid\z@
\kern-\itemindent
\fi}%
\box\@labels
\penalty\z@
\fi
\if@nobreak
\@nobreakfalse
\clubpenalty \@M
\else
\clubpenalty \@clubpenalty
\everypar{}%
\fi}%
\if@noitemarg
\@noitemargfalse
\if@nmbrlist
\refstepcounter\@listctr
\fi
\fi
\sbox\@tempboxa{\makelabel{#1}}%
\global\setbox\@labels\hbox{%
\unhbox\@labels
\hskip \itemindent
\hskip -\labelwidth
\hskip -\labelsep
\ifdim \wd\@tempboxa >\labelwidth
\box\@tempboxa
\else
\hbox to\labelwidth {\unhbox\@tempboxa}%
\fi
\hskip \labelsep}%
\ignorespaces}
\makeatother
% set up showoddsolns and showEVEN
\newbool{showoddsolns}
\setbool{showoddsolns}{true}
\newbool{showevensolns}
\setbool{showevensolns}{true}
% this boolean is used in the problem and subproblem definition (don't change)
\newbool{showSolution}
\setbool{showSolution}{true}
% boolean for core problem or not
\newbool{coreproblemYesNo}
\setbool{coreproblemYesNo}{false}
% boolean to detect if a solution has been written
\newbool{solutionpresent}
\setbool{solutionpresent}{false}
% PROBLEM environment
% \begin{problem}[1][2]
% ...
% \end{problem}
%
% [1]: description of the problem
% [2]: core
%
% Both arguments are optional; the second argument
% can be left off, empty, or core. If it is non-empty
% and anything other than core (case-sensitive), it
% will be ignored.
\newcounter{problem}[section]
\newcommand{\coresymbol}{$\bigstar$ }
\newlength{\coresymbollength}
\settowidth{\coresymbollength}{\coresymbol}
\newenvironmentx{problem}[2][1={},2={},usedefault]{%
\refstepcounter{problem}%
\Writetofile{shortsolutions}{\protect\hypertarget{soln:\theproblem:\thechapter:\thesection}{}}%
\global\setbool{solutionpresent}{false}% default: assume no solution
\needspace{\baselineskip}%
\ifnumodd{\theproblem}%
{%
\ifbool{showoddsolns}%
{}% true (by default)
{\setbool{showSolution}{false}}%
}%
{%
\ifbool{showevensolns}%
{}% true (by default)
{\setbool{showSolution}{false}}%
}%
% set up the Problem environment as a list
% the first argument of the list environment is the label,
% which for this environment is empty
\begin{list}{}{%
\setlength{\leftmargin}{0mm}%
\setlength{\rightmargin}{0mm}%
\setlength{\topsep}{0mm}%
\setlength{\partopsep}{0mm}%
\parsep\parskip%
\setlength{\itemsep}{-\parsep}%
}\item% Problem X [with possible description]
\ifstrempty{#2}{%
%NOT core problem
% if no second argument (core or not)
\ifstrempty{#1}{%
% Problem withOUT description
\ifbool{showSolution}%
{%
{\hypertarget{prob:\theproblem:\thechapter:\thesection}{}%
{{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter:\thesection}{\theproblem}}}}%
}%
{%
{\bfseries Problem \theproblem}%
}%
}%
{% Problem with description
\ifbool{showSolution}%
{%
{\hypertarget{prob:\theproblem:\thechapter:\thesection}{}%
{{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter:\thesection}{\theproblem} \,(#1)}}}%
}%
{%
{\bfseries Problem \theproblem\, (#1) }%
}%
}%
}%
{% core problem
\ifstrequal{#2}{core}{%
\setbool{coreproblemYesNo}{true}%
\Writetofile{shortsolutions}{\protect\setbool{coreproblemYesNo}{true}}%
% write problem number to corefile
\addcontentsline{prb}{}{\theproblem}%
\ifstrempty{#1}{%
% core problem with no description
\ifbool{showSolution}%
{%
{\hypertarget{prob:\theproblem:\thechapter:\thesection}{}%
{\hspace{-\coresymbollength}\coresymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter:\thesection}{\theproblem}}}}%
}%
{%
\hspace{-\coresymbollength}\coresymbol{\bfseries Problem \theproblem}%
}%
}%
{% core problem with description
\ifbool{showSolution}%
{% with links
{\hypertarget{prob:\theproblem:\thechapter:\thesection}{}%
{\hspace{-\coresymbollength}\coresymbol{\bfseries Problem \hypersetup{linkcolor=black}\hyperlink{soln:\theproblem:\thechapter:\thesection}{\theproblem} \,(#1)}}}%
}%
{% no links
\hspace{-\coresymbollength}\coresymbol{\bfseries Problem \theproblem\, (#1) }%
}%
}%
}{ \textbf{Problem} \theproblem \, (#1) {\bf\huge\color{red}core?}}%
}%
\nobreakitem% body of the environment
}%
{%
% check to see if a solution has been written
\ifbool{solutionpresent}%
{}% do nothing if a solution exitst
{\fixthis{Problem \theproblem: NEED SOLUTION}}% otherwise we need to write one
\end{list}%
% if this was a core problem, switch back the default
% in the solution file
\ifbool{coreproblemYesNo}%
{%
\Writetofile{shortsolutions}{\protect\setbool{coreproblemYesNo}{false}}%
}%
{}%
}%
% if there is a shortsolution, then toggle the boolean
\AfterEndEnvironment{shortsolution}{\global\setbool{solutionpresent}{true}}
% subproblem environment
\newcounter{subproblem}[problem]
\newlength{\subproblabel}
\newlist{subprobenum}{enumerate}{3}
\setlist[subprobenum]{leftmargin=0mm}%
\newenvironment{subproblem}[1][]{%
\refstepcounter{subproblem}%
\global\setbool{solutionpresent}{false}% default: assume no solution
\ifnumodd{\theproblem}%
{%
\ifbool{showoddsolns}%
{% true (by default), set hypertarget in solution file
\Writetofile{shortsolutions}{\protect\hypertarget{soln:{\theproblem.\thesubproblem}:\thechapter:\thesection}{}}%
}%
{\setbool{showSolution}{false}}%
}%
{%
\ifbool{showevensolns}%
{% true (by default), set hypertarget in solution file
\Writetofile{shortsolutions}{\protect\hypertarget{soln:{\theproblem.\thesubproblem}:\thechapter:\thesection}{}}%
}%
{\setbool{showSolution}{false}}%
}%
\ifstrequal{#1}{core}{%
\setbool{coreproblemYesNo}{true}%
}%
{%
\setbool{coreproblemYesNo}{false}%
}%
\settowidth{\subproblabel}{\bfseries{\theproblem.\thesubproblem}}%
\ifbool{coreproblemYesNo}%
{% core problem
% set boolean in the solutions file
\Writetofile{shortsolutions}{\protect\setbool{coreproblemYesNo}{true}}%
% add to list of problems per section
\addcontentsline{prb}{}{\theproblem.\thesubproblem}%
\ifbool{showSolution}%
{% hyperlink to solution
\hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter:\thesection}{}%
\hypersetup{linkcolor=black}%
\begin{subprobenum}[labelwidth=\subproblabel,label=\llap{$\bigstar$ }\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter:\thesection}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem]
\item% body of the environment
}%
{% no hyperlink
\begin{subprobenum}[labelwidth=\subproblabel,label=\llap{$\bigstar$ }\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem]
\item% body of the environment
}%
}%
{% NOT core problem
\ifbool{showSolution}%
{% hyperlink to solution
\hypertarget{prob:{\theproblem.\thesubproblem}:\thechapter:\thesection}{}%
\hypersetup{linkcolor=black}%
\begin{subprobenum}[labelwidth=\subproblabel,label=\bfseries\protect\hyperlink{soln:{\theproblem.\thesubproblem}:\thechapter:\thesection}{\theproblem.\thesubproblem},ref=\theproblem.\thesubproblem]
\item% body of the environment
}%
{% no hyperlink
\begin{subprobenum}[labelwidth=\subproblabel,label=\bfseries\theproblem.\thesubproblem,ref=\theproblem.\thesubproblem]
\item% body of the environment
}%
}%
\hypersetup{linkcolor=blue}%
}%
{%
% check to see if a solution has been written
\ifbool{solutionpresent}%
{}% do nothing if a solution exitst
{\fixthis{Problem \theproblem.\thesubproblem: NEED SOLUTION}}% otherwise we need to write one
% if this was a core problem, switch back the default
% in the solution file
\ifbool{coreproblemYesNo}%
{%
\Writetofile{shortsolutions}{\protect\setbool{coreproblemYesNo}{false}}%
}%
{}%
\end{subprobenum}}
% another type of theorem-break environment
% this one is very similar to the break environment, except
% it removes the () from the statement
\makeatletter
\newtheoremstyle{pccbreak}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont%
##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
{\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont%
##3\theorem@separator}\hbox{\strut}}}]}
\makeatother
% special comment
\theoremstyle{pccbreak}
\theoremheaderfont{\bfseries}
\theoremsymbol{}
\theoremseparator{}
\theoremprework{}
%\setlength{\theorempreskipamount}{0pt}
%\setlength{\theorempostskipamount}{0pt}
\theorempostwork{}
\makeatletter
\if@tempswa % draft option is active
% make the specialcomment environment without colour, no frame
\newtheorem{pccspecialcomment}{}%
\else%
\newmdtheoremenv[outerlinewidth=3,
innerlinewidth=2,linecolor=gray,
backgroundcolor=blue!20,%
innerlinecolor=blue!50,outerlinecolor=red!50,innertopmargin=0pt,%
splittopskip=\topskip,skipbelow=0pt,%
]{pccspecialcomment}{}%[chapter]
\fi
\makeatother
% definition
\theoremstyle{break}
\theoremsymbol{}
\theoremheaderfont{\bfseries}
\theoremprework{}
\theorempostwork{}
\theoremseparator{}
\makeatletter
\if@tempswa % draft option is active
% make the Definition environment without colour, no frame
\newtheorem{pccdefinition}{Definition}%
\else%
\newmdtheoremenv[outerlinewidth=3,
innerlinewidth=2,linecolor=gray,leftmargin=60,%
rightmargin=40,
backgroundcolor=yellow!40,%
innerlinecolor=blue!50,outerlinecolor=red!50,innertopmargin=0pt,%
splittopskip=\topskip,%skipbelow=\baselineskip,%
skipabove=\baselineskip,ntheorem]{pccdefinition}{Definition}%[chapter]
\fi
\makeatother
%====================================
% END CUSTOM THEOREMS (for examples, problems)
%====================================
%====================================
% BEGIN CORE PROBLEMS
%====================================
\newcounter{probSectCounter}
\setcounter{probSectCounter}{-1}
\newcounter{probCounter}
\setcounter{probCounter}{0}%
\newcounter{echo}
\newread\File
\makeatletter
% need a command to bring the \contentsline
% into the problemlist environment
\let\pcc@contentslist\contentsline%
\newenvironment{problemlist}%
{%
% renew the \contentsline command so that it just gives
% the problem number as a hyperlink (and no page number)
%
% if we renewed the command outside of the environment, it would
% affect \tableofcontents, \minitoc, and perhaps more- bad!
\let\contentsline\pcc@contentslist%
\let\Contentsline\contentsline%
\renewcommand\contentsline[4]{%
\StrCount{##2}{heading}[\heading]%
\ifnumcomp{\heading}{>}{0}%
{%
\StrCount{##2}{heading\theprobSectCounter}[\heading]%
\ifnumcomp{\heading}{>}{0}%
{%
\setcounter{echo}{1}%
\setcounter{probCounter}{0}%
}%
{%
\setcounter{echo}{0}%
}%
}%
{%
\ifnumequal{\theecho}{1}%
{%
\stepcounter{probCounter}%
\ifnumequal{\theprobCounter}{1}%
{%
% if we're at the beginning, no comma
Core problems in this section (\coresymbol\unskip): \Contentsline{##1}{##2}{}{##4}%
}%
{%
% otherwise put a comma and a space
\unskip, \Contentsline{##1}{##2}{}{##4}%
}%
}%
{}%
}%
}%
}%
{}
\def\listcoreproblems{%
% open the appropriate file do everything in a
% new environment so that we can renew the
% \contentsline command locally
\begin{problemlist}
\par%
\openin\File=\jobname.prb%
\loop\unless\ifeof\File%
\read\File to\fileline%
\fileline%
\repeat%
\closein\File%
\end{problemlist}
}%
% enable the \jobname.prb file
% (hacked from the ntheorem package)
\def\prb@enablelistofproblems{%
\begingroup%
\makeatletter%
\if@filesw%
\expandafter\newwrite\csname tf@prb\endcsname%
\immediate\openout \csname tf@prb\endcsname \jobname.prb\relax%
\fi%
\@nobreakfalse%
\endgroup}%
% enable the \jobname.prb<counter> files at the end
% of the document
\AtEndDocument{\prb@enablelistofproblems}
\makeatother
%====================================
% END CORE PROBLEMS
%====================================
%====================================
% BEGIN OUTCOMES
%====================================
\newenvironment{outcomes}%
{%
\itshape%
% define a new environment local to outcomes- the outcomelist
% environment will not work outside of outcomes!
\newenvironment{outcomelist}{\begin{itemize}[topsep=-2mm]}{\end{itemize}}%
%[label=$\triangleright$]
{Section Themes, Concepts, Issues, Competencies, and Skills:}%
}%
{%
\listcoreproblems%
%\hfill\rule{0.5\textwidth}{1pt}\needspace{\baselineskip}%
%\needspace{\baselineskip}%
%\hfill $\Box$\needspace{\baselineskip}%
%\end{framed}%
}%
%====================================
% END OUTCOMES
%====================================
%====================================
% BEGIN TABLE STYLES
%====================================
\renewcommand{\heavyrulewidth}{0.2em}
\renewcommand{\lightrulewidth}{0.1em}
\renewcommand{\cmidrulewidth}{0.1em}
% horizontal lines
\renewcommand{\aboverulesep}{0cm}
\renewcommand{\belowrulesep}{0cm}
\newcommand*\heading[1]{\multicolumn{1}{c}{#1}}
\newcommand*\beforeheading{\toprule}
\newcommand*\afterheading{\midrule}
%\newcommand*\normalline{\hline}
\newcommand*\normalline{}
\newcommand*\lastline{\bottomrule}
%====================================
% END TABLE STYLES
%====================================
%====================================
% BEGIN essentialskills, tryityourself, exercises
%====================================
\newenvironment{doyouunderstand}%
{\FloatBarrier\setlist[subprobenum]{align=left,leftmargin=!}%
\begin{list}{}{% the first argument of the list environment is the label
\setlength{\leftmargin}{0mm}%
\setlength{\rightmargin}{0mm}%
\setlength{\topsep}{0mm}%
\setlength{\partopsep}{0mm}%
\parsep\parskip%
\setlength{\itemsep}{-\parsep}%
}%
\needspace{4\baselineskip}\item\llap{\large\textbf{$\bigstar$ try it yourself $\bigstar$} }%
\vskip-1.8\baselineskip\rule{\textwidth}{2pt}\vskip-16pt\rule{\textwidth}{0.5pt}\vskip-5pt%
\nobreakitem% body of the environment
}%
{\nobreakitem \hfill \itshape{make sure you try it!}\nobreakitem\vskip-9pt\rule{\textwidth}{0.5pt}\vskip-15pt\rule{\textwidth}{2pt}\end{list}}%
\newenvironment{essentialskills}%
{%
\begin{list}{}{% the first argument of the list environment is the label
\setlength{\leftmargin}{0cm}%
\setlength{\rightmargin}{0mm}%
\setlength{\topsep}{0mm}%
\setlength{\partopsep}{0mm}%
\parsep\parskip%
\setlength{\itemsep}{-\parsep}%
}%
\item[\llap{\textbf{\large essential skills} }]\raisebox{3pt}{\rule{\textwidth}{2pt}}%
\nobreakitem {\itshape{The following problems contain prerequisite skills that are essential for success. Make sure that you
can complete them before moving on!}}%
\item% body of the environment
\setlist[subprobenum]{align=left}}%
{\nobreakitem \raisebox{3pt}{\rule{\textwidth}{2pt}}%
\end{list}}%
\newenvironment{exercises}%
{\FloatBarrier\setlist[subprobenum]{align=left,leftmargin=!}%
\begin{adjustwidth}{-4cm}{0cm}%
\needspace{4\baselineskip}\colorbox{gray!80}{\begin{minipage}{\linewidth-6pt}\bfseries\Large Exercises\end{minipage}}}%
{\end{adjustwidth}}
%====================================
% END essentialskills, doyouunderstand, exercises
%====================================
%====================================
% BEGIN CUSTOMIZE SECTIONS
%====================================
% useful link: http://tex.stackexchange.com/questions/32495/linking-the-section-text-to-the-toc
% custom chapter
\titleformat{\chapter}[display]
{\normalfont\Large\filcenter\bf}
{\titlerule[1pt]%
\vspace{1pt}%
\titlerule
\typeout{PCCNAME: Chapter \thechapter: #1^^J}% for use with PCCNAME (diversity)
\LARGE\MakeUppercase{#1} {\LARGE\thechapter}%
}
{1pc}