| 1 |
% \subsection{Activities} |
| 2 |
% The core of the |xourse| system. It works by redefining the |
| 3 |
% |document| environment, thus making the |\begin| and |
| 4 |
% |\end{document}| of the subfile `transparent' to the |
| 5 |
% inclusion. The redefinition of |\documentclass| is analogous, just |
| 6 |
% having a required and an optional arguments which mean nothing to |
| 7 |
% |\subfile|. |
| 8 |
% \begin{macrocode} |
| 9 |
%<*classXourse> |
| 10 |
\newcommand{\skip@preamble}{% |
| 11 |
\let\document\relax\let\enddocument\relax% |
| 12 |
\newenvironment{document}{\let\input\otherinput}{}% |
| 13 |
\renewcommand{\documentclass}[2][subfiles]{}} |
| 14 |
% \end{macrocode} |
| 15 |
% Note that the new command |\subfile| calls for |\skip@preamble| \emph{within a group}. The changes to |document| and |\documentclass| are undone after the inclusion of the subfile. |
| 16 |
% |
| 17 |
% Numbering starts a page too soon without this: |
| 18 |
% \begin{macrocode} |
| 19 |
\let\otherinput\input |
| 20 |
% \end{macrocode} |
| 21 |
% Store usual |\maketitle| as |\othermaketitle| |
| 22 |
% \begin{macrocode} |
| 23 |
\let\othermaketitle\maketitle |
| 24 |
% \end{macrocode} |
| 25 |
% \DescribeMacro{\maketitle}{In a \textsf{xourse} file, |\maketitle| is redefined to give course packet title page and toc.} |
| 26 |
% \begin{macrocode} |
| 27 |
\renewcommand{\maketitle}{ % |
| 28 |
\pagestyle{empty} |
| 29 |
\begin{center} |
| 30 |
~\\ %puts space at top of page to move title down. |
| 31 |
\vskip .25\textheight |
| 32 |
\hrulefill\\ |
| 33 |
\vskip 1em |
| 34 |
\bfseries{\Huge \@title} \\ |
| 35 |
\hrulefill\\ |
| 36 |
\vskip 3em |
| 37 |
{\Large \@author} |
| 38 |
\vskip 2em |
| 39 |
{\large \@date} |
| 40 |
\end{center} |
| 41 |
\clearpage |
| 42 |
% \end{macrocode} |
| 43 |
% When |notoc| option is used, we do not include a table of contents. |
| 44 |
% Otherwise we include a table of contents in every course packet. |
| 45 |
% \begin{macrocode} |
| 46 |
\ifnotoc |
| 47 |
\else |
| 48 |
\tableofcontents\clearpage |
| 49 |
\clearpage |
| 50 |
\fi |
| 51 |
% \end{macrocode} |
| 52 |
% Switch to main pagestyle, just like a document with documentclass \textsf{ximera}. |
| 53 |
% \begin{macrocode} |
| 54 |
\pagestyle{main} |
| 55 |
% \end{macrocode} |
| 56 |
% Renew maketitle to usual definition. |
| 57 |
% \begin{macrocode} |
| 58 |
\let\maketitle\othermaketitle |
| 59 |
% \end{macrocode} |
| 60 |
% And we finish with our redefinition of |\maketitle|. |
| 61 |
% \begin{macrocode} |
| 62 |
} |
| 63 |
\relax |
| 64 |
%</classXourse> |
| 65 |
% \end{macrocode} |
| 66 |
|
| 67 |
% \subsubsection{Regular activities} |
| 68 |
% \DescribeMacro{\activity}{Documents included with |\activity| will |
| 69 |
% be included in the body of the xourse document. Any |\input| |
| 70 |
% commands within included \textsf{ximera} documents will be ignored. |
| 71 |
% Any |\usepackage| commands within included ximera documents will |
| 72 |
% cause an error. Overlapping |\newcommand| definitions within |
| 73 |
% multiple ximera documents included simultaneously will cause an |
| 74 |
% error.} The |\activity| command inputs the file name provided |
| 75 |
% without |\documentclass|, without |
| 76 |
% |\begin{document}|/|\end{document}| and without any inputs in the |
| 77 |
% preamble of the included file. |
| 78 |
% \begin{macrocode} |
| 79 |
%<*classXourse> |
| 80 |
\ifnonewpage |
| 81 |
\newcommand{\activity}[2][]{% |
| 82 |
\setkeys{activity}{#1} |
| 83 |
\renewcommand{\input}[1]{} |
| 84 |
\begingroup\skip@preamble\otherinput{#2}\endgroup\par\vspace{\topsep} |
| 85 |
\let\input\otherinput} |
| 86 |
\else |
| 87 |
\newcommand{\activity}[2][]{% |
| 88 |
\setkeys{activity}{#1} |
| 89 |
\renewcommand{\input}[1]{} |
| 90 |
\begingroup\skip@preamble\otherinput{#2}\endgroup\clearpage |
| 91 |
\let\input\otherinput} |
| 92 |
\fi |
| 93 |
\relax |
| 94 |
%</classXourse> |
| 95 |
% \end{macrocode} |
| 96 |
|
| 97 |
% \begin{macrocode} |
| 98 |
%<*htXourse> |
| 99 |
\renewcommand\activity[2][]{% |
| 100 |
\ifvmode \IgnorePar\fi \EndP\HCode{<a class="activity card \activitystyle" href="#2" data-options="#1">#2</a>}\IgnoreIndent% |
| 101 |
} |
| 102 |
%</htXourse> |
| 103 |
% \end{macrocode} |
| 104 |
|
| 105 |
% When running xake, we can just ignore activities |
| 106 |
% \begin{macrocode} |
| 107 |
%<*classXourse> |
| 108 |
\ifxake |
| 109 |
\renewcommand\activity[2][]{} |
| 110 |
\fi |
| 111 |
%</classXourse> |
| 112 |
% \end{macrocode} |
| 113 |
|
| 114 |
|
| 115 |
% \subsubsection{Practice activities} |
| 116 |
% \DescribeMacro{\practice}{Like |\activity| but not expecting a title.} |
| 117 |
% \begin{macrocode} |
| 118 |
%<*classXourse> |
| 119 |
\ifhandout |
| 120 |
\newcommand{\practice}[2][]{ |
| 121 |
\setkeys{practice}{#1}%!!!!! |
| 122 |
\renewcommand{\input}[1]{} |
| 123 |
\begingroup\skip@preamble\otherinput{#2}\endgroup |
| 124 |
\let\input\otherinput} |
| 125 |
\else |
| 126 |
\newcommand{\practice}[2][]{\texttt{\detokenize{#2}}%% gives file name for practice |
| 127 |
\setkeys{practice}{#1}%!!!!! |
| 128 |
\renewcommand{\input}[1]{} |
| 129 |
\begingroup\skip@preamble\otherinput{#2}\endgroup |
| 130 |
\let\input\otherinput} |
| 131 |
\fi |
| 132 |
\relax |
| 133 |
%</classXourse> |
| 134 |
% \end{macrocode} |
| 135 |
|
| 136 |
% The practice environment does nothing, but will eventually produce |
| 137 |
% exercises at the end of an activity |
| 138 |
% \begin{macrocode} |
| 139 |
%<*classXourse> |
| 140 |
\ifxake |
| 141 |
\renewcommand\practice[2][]{} |
| 142 |
\fi |
| 143 |
%</classXourse> |
| 144 |
% \end{macrocode} |
| 145 |
|
| 146 |
% I suppose it is reasonable for practice cards to NOT have an activitystyle, since the activitystyle is basically PRACTICE. |
| 147 |
% \begin{macrocode} |
| 148 |
%<*htXourse> |
| 149 |
\renewcommand\practice[2][]{% |
| 150 |
\ifvmode\IgnorePar\fi\EndP% |
| 151 |
\HCode{<a class="activity card practice" href="#2" data-options="#1">#2</a>}% |
| 152 |
\IgnoreIndent% |
| 153 |
} |
| 154 |
%</htXourse> |
| 155 |
% \end{macrocode} |
| 156 |
|
| 157 |
|
| 158 |
|