summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ximera/src/activity.dtx
blob: 647be0565d8c5f442e2932bd243534f0aaac7458 (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
% \subsection{Activities}
% The core of the |xourse| system. It works by redefining the
% |document| environment, thus making the |\begin| and
%   |\end{document}| of the subfile `transparent' to the
% inclusion. The redefinition of |\documentclass| is analogous, just
% having a required and an optional arguments which mean nothing to
% |\subfile|.
%    \begin{macrocode}
%<*classXourse>
\newcommand{\skip@preamble}{%
    \let\document\relax\let\enddocument\relax%
    \newenvironment{document}{\let\input\otherinput}{}%
    \renewcommand{\documentclass}[2][subfiles]{}}
%    \end{macrocode}
% 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.
%
% Numbering starts a page too soon without this:
%    \begin{macrocode}
\let\otherinput\input 
%    \end{macrocode}
% Store usual |\maketitle| as |\othermaketitle|
%    \begin{macrocode}
\let\othermaketitle\maketitle
%    \end{macrocode}
% \DescribeMacro{\maketitle}{In a \textsf{xourse} file, |\maketitle| is redefined to give course packet title page and toc.}
%    \begin{macrocode}
\renewcommand{\maketitle}{ %
\pagestyle{empty}
\begin{center}
~\\ %puts space at top of page to move title down.
\vskip .25\textheight
\hrulefill\\
\vskip 1em
\bfseries{\Huge \@title} \\
\hrulefill\\
\vskip 3em
{\Large \@author}
\vskip 2em
{\large \@date}
\end{center}
\clearpage
%    \end{macrocode}
% When |notoc| option is used, we do not include a table of contents.
% Otherwise we include a table of contents in every course packet.
%    \begin{macrocode}
\ifnotoc
\else
  \tableofcontents\clearpage
  \clearpage
\fi
%    \end{macrocode}        
% Switch to main pagestyle, just like a document with documentclass \textsf{ximera}.
%    \begin{macrocode}
\pagestyle{main}
%    \end{macrocode}
% Renew maketitle to usual definition.
%    \begin{macrocode}
\let\maketitle\othermaketitle
%    \end{macrocode}
% And we finish with our redefinition of |\maketitle|.
%    \begin{macrocode}
}
\relax
%</classXourse>
%    \end{macrocode}

% \subsubsection{Regular activities}
% \DescribeMacro{\activity}{Documents included with |\activity| will
% be included in the body of the xourse document. Any |\input|
% commands within included \textsf{ximera} documents will be ignored.
% Any |\usepackage| commands within included ximera documents will
% cause an error.  Overlapping |\newcommand| definitions within
% multiple ximera documents included simultaneously will cause an
% error.}  The |\activity| command inputs the file name provided
% without |\documentclass|, without
% |\begin{document}|/|\end{document}| and without any inputs in the
% preamble of the included file.
%    \begin{macrocode}
%<*classXourse>
\ifnonewpage
\newcommand{\activity}[2][]{%
	\setkeys{activity}{#1}
  \renewcommand{\input}[1]{}
  \begingroup\skip@preamble\otherinput{#2}\endgroup\par\vspace{\topsep}
  \let\input\otherinput}
\else
\newcommand{\activity}[2][]{%
	\setkeys{activity}{#1}
  \renewcommand{\input}[1]{}
  \begingroup\skip@preamble\otherinput{#2}\endgroup\clearpage
  \let\input\otherinput}
\fi
\relax
%</classXourse>
%    \end{macrocode}

%    \begin{macrocode}
%<*htXourse>
\renewcommand\activity[2][]{%
\ifvmode \IgnorePar\fi \EndP\HCode{<a class="activity card \activitystyle" href="#2" data-options="#1">#2</a>}\IgnoreIndent%
}
%</htXourse>
%    \end{macrocode}

% When running xake, we can just ignore activities
%    \begin{macrocode}
%<*classXourse>
\ifxake
\renewcommand\activity[2][]{}
\fi
%</classXourse>
%    \end{macrocode}


% \subsubsection{Practice activities}
% \DescribeMacro{\practice}{Like |\activity| but not expecting a title.}
%    \begin{macrocode}
%<*classXourse>
\ifhandout
\newcommand{\practice}[2][]{
	\setkeys{practice}{#1}%!!!!!
  \renewcommand{\input}[1]{}
  \begingroup\skip@preamble\otherinput{#2}\endgroup
  \let\input\otherinput}
\else
\newcommand{\practice}[2][]{\texttt{\detokenize{#2}}%% gives file name for practice
	\setkeys{practice}{#1}%!!!!!
  \renewcommand{\input}[1]{}
  \begingroup\skip@preamble\otherinput{#2}\endgroup
  \let\input\otherinput}
\fi
\relax
%</classXourse>
%    \end{macrocode}

% The practice environment does nothing, but will eventually produce
% exercises at the end of an activity
%    \begin{macrocode}
%<*classXourse>
\ifxake
\renewcommand\practice[2][]{}
\fi
%</classXourse>
%    \end{macrocode}

% I suppose it is reasonable for practice cards to NOT have an activitystyle, since the activitystyle is basically PRACTICE.
%    \begin{macrocode}
%<*htXourse>
\renewcommand\practice[2][]{%
  \ifvmode\IgnorePar\fi\EndP%
  \HCode{<a class="activity card practice" href="#2" data-options="#1">#2</a>}%
  \IgnoreIndent%
}
%</htXourse>
%    \end{macrocode}