% \iffalse meta-comment % % Copyright (C) 2025-2026 by G. I. Riley % --------------------------------------------------------------------------- % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained.' % % The Current Maintainer of this work is Geoff Riley. % % This work consists of the files ou-tma.dtx and ou-tma.ins % and the derived filebase ou-tma.sty, ou-tma-sup.sty and % doc-changes.sty. % % \fi % % \iffalse %<*driver> \ProvidesFile{ou-tma.dtx} % %\NeedsTeXFormat{LaTeX2e}[2023-11-01] %\ProvidesExplPackage{ou-tma} % {2026-11-16} {v1.22} {OU-TMA package} %\ProvidesExplPackage{ou-tma-sup} % {2025-12-29} {v0.15} {OU-TMA-SUP package} %\ProvidesExplPackage{doc-changes} % {2025-11-19} {v0.4} {Split change logs to per-stream doc glossaries (single column printing)} %<*driver> \documentclass[a4paper,11pt]{ltxdoc} \usepackage[T1]{fontenc} \AtBeginDocument{ \IfPackageLoadedTF{makeidx}{}{ \IfPackageLoadedTF{splitidx}{}{ \RequirePackage{makeidx} \makeindex } } } \usepackage{dtxdescribe} \usepackage{expl3,xparse} % \OnlyDescription \listfiles \EnableCrossrefs % \DisableCrossrefs \CodelineIndex % \SetupDoc{reportchangedates} \setlength\hfuzz{15pt} % don't show so many \hbadness=7000 % over- and underfull box warnings \usepackage{ou-tma} \usepackage{ou-tma-sup} \usepackage{doc-changes} \geometry{left=1mm,marginparwidth=40mm,marginparsep=1mm} \fancyhf{} % Clear all headers and footers \fancyhead[L]{\textsf{ou-tma}\ and \textsf{ou-tma-sup}} \fancyhead[R]{\textrm{\thepage}} \RenewDocumentCommand{\headrulewidth}{}{1pt} % Remove header rule % Refine MakePrivateLetters to allow documenting of expl3 macros \def\MakePrivateLetters{% \makeatletter \catcode`\_11 \catcode`\:11} \def\ClearPrivateLetters{% \makeatother \catcode`\_8 \catcode`\:12} \makeatletter \DocChangeDeclareStreams{ chg-tma , chg-sup, chg-chg } \NewDocumentCommand{\changesTMA}{mmm}{ \DocChangeSet{chg-tma} \changes{#1}{#2}{#3} } \NewDocumentCommand{\changesSUP}{mmm}{ \DocChangeSet{chg-sup} \changes{#1}{#2}{#3} } \NewDocumentCommand{\changesCHG}{mmm}{ \DocChangeSet{chg-chg} \changes{#1}{#2}{#3} } \NewDocumentCommand{\printchangesTMA}{}{ \section*{Changes for \textsf{ou-tma}} \DocChangePrint{chg-tma} } \NewDocumentCommand{\printchangesSUP}{}{ \section*{Changes for \textsf{ou-tma-sup}} \DocChangePrint{chg-sup} } \NewDocumentCommand{\printchangesCHG}{}{ \section*{Changes for \textsf{doc-changes}} \DocChangePrint{chg-chg} } \makeatother \begin{document} \DocInput{ou-tma.dtx} \end{document} % % \fi % % \makeatletter % \GetFileInfo{ou-tma.sty} % \edef\outmadate{\filedate} % \edef\outmaversion{\fileversion} % \GetFileInfo{ou-tma-sup.sty} % \edef\outmasupdate{\filedate} % \edef\outmasupversion{\fileversion} % \IfPackageLoadedTF{doc}{ ^^A doc % \NewDocElement[ % macrolike=false, % toplevel=true, % idxtype=variable, % idxgroup=Variable, % printtype=\textit{Var} % ]{Variable}{variable} % }{^^A not doc % \newcommand*{\DescribeVariable}[2][]{% % \DTXD@filemaXD@filemarginparindex{#1}{#2}{Var}{variable}{usage}% % } % }^^A not doc % \newcommand{\ItemDescribeVariable}[2][]{% % \item[\texttt{#2}:]% % \setlength{\parskip}{1.5ex}% % \DescribeVariable[#1]{#2}% % } % % \makeatother % %^^A Shorthand for package names % \newcommand{\stma}{\pkg{ou-tma}} % \newcommand{\stmas}{\pkg{ou-tma-sup}} % \newcommand{\schg}{\pkg{doc-changes}} % \newcommand{\TMA}{\acro{tma}} % \newcommand{\OU}{\acro{ou}} % % \MakePrivateLetters % \DoNotIndex{\!,\@ifpackageloaded,\ ,\AtBeginDocument,\author,\crefname,\else} % \DoNotIndex{\endinput,\ensuremath,\ExplSyntaxOff,\ExplSyntaxOn,\fancyhead} % \DoNotIndex{\fancyhf,\fi,\frac,\g,\geometry,\headrulewidth,\hspace,\ifthenelse} % \DoNotIndex{\large,\makebox,\mathbb,\mathcal,\mathop,\mathrm,\newcommand} % \DoNotIndex{\newcounter,\NewDocumentCommand,\NewDocumentEnvironment,\newif} % \DoNotIndex{\newtheorem,\numberwithin,\overrightarrow,\PackageWarning} % \DoNotIndex{\par,\parindent,\parskip,\ProcessOptions,\ProvideDocumentCommand} % \DoNotIndex{\refstepcounter,\relax,\renewcommand,\RenewDocumentCommand} % \DoNotIndex{\RequirePackage,\setcounter,\setlength,\space,\sqsubset,\sqsupset} % \DoNotIndex{\setcounter,\textbf,\textrm,\textsuperscript,\tl,\typeout} % \DoNotIndex{\unicode,\vspace,\DeclareMathOperator,\DeclareOption,\l,\cs,\doc} % \DoNotIndex{\,,\-,\.,\;,\arabic,\begingroup,\endgroup,\bigskip,\def,\draw} % \DoNotIndex{\emph,\startcsname,\endcsname,\expandafter,\hangindent} % \DoNotIndex{\IfNoValueF,\ifstrequal,\InputIfFileExists,\jobname,\footnotesize} % \DoNotIndex{\label,\left,\right,\node,\pageref,\pagestyle,\protected@write} % \DoNotIndex{\providecommand,\ProvidesExplPackage,\thepage,\theglossary} % \DoNotIndex{\tikzset,\regex,\section,\SetupDoc,\stepcounter,\sisetup,\string} % \DoNotIndex{\subitem,\subsubitem,\text,\textemdash,\textit,\the,\thefootnote} % \DoNotIndex{\usepgfplotslibrary,\usetikzlibrary,\vskip,\Wnd,\XGap} % \DoNotIndex{\cs_new:Npn} % \ClearPrivateLetters % \title{The \stma\ and \stmas\ Packages\thanks{This document % corresponds to \stma\ \outmaversion, dated~\outmadate, and \stmas\ \outmasupversion, dated~\outmasupdate.}} % \author{Geoff Riley \\ \href{mailto:geoffr@adaso.com}{geoffr@adaso.com}} % \date{\outmadate\ (\outmaversion)} % \RecordChanges % \renewcommand\code[1]{\mbox{$\ell$-#1}} % \renewcommand\main[1]{\underline{\mbox{$\ell$-#1}}} % \setcounter{IndexColumns}{2} % \setcounter{GlossaryColumns}{2} % \maketitle % % \begin{abstract} % \noindent The \stma\ package provides macros and environments to assist in writing Tutor % Marked Assessments (\TMA s) for Open University courses. The companion file \stmas\ % package provides a number of extra macros that may be useful for some modules. % \end{abstract} % % \makeatletter % \renewcommand\tableofcontents{% % \section*{\contentsname % \@mkboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% % \begingroup % \setlength{\parskip}{0pt}% % \setlength{\parindent}{0pt}% % \begin{multicols}{2}% % \@starttoc{toc}% % \end{multicols}% % \endgroup % } % \makeatother % % \tableofcontents % % \section{Introduction} % % The \stma\ package simplifies the creation of \TMA s by providing an environment % to encompass answers to questions commands to enumerate parts and subparts of those % questions, and a set of macros facilitating mathematical entry based on the styles % used by the Open University (\OU). % % \section{Compiling and installing \stma} % % To compile the \stma\ package (extract the \filenm{.sty} files): % % \userentry{pdflatex tma.ins} % % To compile the \stma\ documentation: % % \userentry{pdflatex ou-tma.dtx} % \fqquad(several times) % \userentry{makeindex -s gglo.ist -o ou-tma-chg-tma.gls ou-tma-chg-tma.glo} % \userentry{makeindex -s gglo.ist -o ou-tma-chg-sup.gls ou-tma-chg-sup.glo} % \userentry{makeindex -s gglo.ist -o ou-tma-chg-chg.gls ou-tma-chg-chg.glo} % \userentry{makeindex -s gind.ist ou-tma} % \userentry{pdflatex ou-tma.dtx} % \fqquad(several times) % % The files \filenm{ou-tma.sty} and \filenm{ou-tma-sup.sty} should be placed in an appropriate location within the \TeX\ directory structure. For example in a directory such as \filenm{tex/latex/ou-tma}. The file \filenm{doc-changes.sty} is only used for formatting this documentation and may safely be ignored thereafter. % % \section{Usage} % % To use the \stma\ package, in its most basic form, it should be included in the preamble % of your \LaTeX\ document: % \begin{quote} % \cs{documentclass}|[a4paper,11pt]{article}|\\ % \cs{usepackage}\oarg{options}|{ou-tma}|\\ % \cs{usepackage}|{ou-tma-sup}| \qquad |% if required| \\ % \vdots\\ % \cs{begin}|{document}|\\ % \vdots\\ % \cs{end}|{document}| % \end{quote} % \changesTMA{v1.21}{2025-09-30}{ Documentation error spotted and corrected in very first % example. A couple of other occurances also corrected in less conspicuous places.} % % \subsection{Options} % % A number of options are available to modify the results of using the \stma\ package. These should be included within the \cs{usepackage} declaration: % \begin{quote} % |\usepackage|\oarg{option,\dots}|{ou-tma}| % \end{quote} % The following options are available: % \begin{description} % \ItemDescribeOption[c=package options]{alph} (default) question numbering as 1(b)(iii); % \ItemDescribeOption[c=package options]{roman} varies question numbering to sequence used by M381 i.e. 1(ii)(c); % \ItemDescribeOption[c=package options]{cleveref} question numbering creates automatic referencing for use with cleveref package; % \ItemDescribeOption[c=package options]{pdfbookmark} add PDF bookmarks for each question using hyperref package; and % \ItemDescribeOption[c=package options]{legacy} enables old definitions of |\vec| and |\C| for backward compatibility. % \end{description} % % \subsection{Macros and environments} % % The \stma\ package provides several valuable macros and environments, most are documented here. % % \subsubsection{Document level commands} % % The document-level commands are intended for use within the document's preamble. They generally affect what appears on the title page and the headers/footers. % % The most essential part of an assignment is to identify who it has been written by and what it has been written for. To this end, the \DescribeMacro[c=header]{\myname}\cs{myname} macro is used to specify your name: this should be your name as recorded with the University. As names are not unique, the \OU\ allocates a Personal Identification Number (or \acro{pin}) as a unique identifier for each student; this should be declared with the \DescribeMacro[c=header]{\mypin}\cs{mypin} macro. It is formed by a letter, followed by seven digits---or six digits and a letter \texttt{X}. This is distinct from the \acro{oucu}, or \OU\ Computer User identifier that is used to log in to the \OU\ website. % % Once the personal identification has been done, the module being worked needs to be declared, the course code of your module should be given with the \DescribeMacro[c=header]{\mycourse}\cs{mycourse} macro and the number of the assignment using the \DescribeMacro[c=header]{\mytma}\cs{mytma} macro. Note that this is just the assignment number; there is no need to include the characters |TMA|. % % The final document level command is used if you wish to set a specific date that will be displayed on the compiled document title page; you may use \DescribeMacro[c=header]{\setdate}\cs{setdate}. This will override the default of using the compile date. % % Example: % \begin{sourceverb} % \myname{Anthony Neil Other} % \mypin{A1234567} % \mycourse{M101} % The original Maths introduction module % \mytma{02} % TMA02 % \setdate{March 2025} % \end{sourceverb} % % \subsubsection{Question environment commands} % % These commands are the ones that, though few, comprise the bulk of the body of the \TMA\ answer content of a paper. % % \changesTMA{v1.21.1}{2025-10-10}{Typo notified just after previous errors corrected. % Minor error in \cs{setquestionstri\textbf{m}g} instead of \cs{setquestionstring}.} % \changesTMA{v1.21.2}{2025-10-28}{Added alignment variation for question string, suggested by Bruce Ramsey.} % Within a \TMA, each answer should be placed in a \DescribeEnv[c=question]{question}\env{question} environment. The question number is printed across the left margin, preceded by the question string which defaults to `Q' but may be redefined by use of the command \DescribeMacro[c=question]{\setquestionstring}\cs{setquestionstring}\oarg{alignment}\marg{required question number introduction}. By setting \emph{alignment} to `\texttt{l}' it is possible to left align the question string and number from the margin rather than into it, this is particularly useful for languages where the translation of `Question' is long enough to disappear past the left hand edge of the page: the default is `\texttt{r}' for right aligned. The question number itself is automatically incremented unless one is specified in the optional parameter. Since the question is presented as an environment, it may be convenient to place each question in a separate file to be included in the main paper. % % Often questions are comprised of multiple parts, therefore, \DescribeMacro[c=question]{\qpart}\cs{qpart} indicates the start of a question part. It will set the part identifier within the left-hand margin space. Normally, the parts are lettered as |a|, |b|, |c|\dots unless the option \optn{roman} has been given to the \stma\ package when the parts are numbered as |i|, |ii|, |iii|\dots % As with the actual questions, this is an auto-incrementing value unless an optional value is given. % Note that the value should be numerical even if the parts are lettered or in Roman numerals. Each new question restarts the numbering at $1$, which will be rendered as |a| or |i| as dictated by the options in effect. % % There are frequent occasions that the parts of questions may be further divided into sub-parts; these may be declared using the \DescribeMacro[c=question]{\qsubpart}\cs{qsubpart} macro. As with \cs{qpart}, this is set in the left margin and automatically incremented: an option to choose the sub-part number is also available. If a \cs{qsubpart} immediately follows a \cs{qpart}, both marginal markers will be set on the same line. % % Infrequetly, there may arise the need for alternative questioning paths. This is most frequetly the case when there has been some form of practical that may not be feasible for all students to take part in. Under these circumstances questions get issued with tracking version, so there with be a question line `1' and a question line `2', to accomodate these the \DescribeMacro[c=question]{\qsubparte}\cs{qsubparte} macro is made available. As with the standard \cs{qsubpart} macro, it may be followed by an optional number to restart the sequence, but it has, in addition, a required parameter to give the track number. \emph{This is included in the \stmas\ package.} % % Note that \env{question} is an environment to be used with the \cs{begin}\thinbrspace\dots\cs{end} structure, \cs{qpart}, \cs{qsubpart} and \cs{qsubparte} are all macros that lay down markers in the margin, and are designed to be used within the \env{question} environment on their own. % % Example: % \begin{quote} % |\begin{question}|\oarg{question number}\\ % \vdots\\ % |\qpart|\oarg{part number}\\ % \vdots\\ % |\qsubpart|\oarg{sub-part number}\\ % \vdots\\ % |\qsubparte|\oarg{sub-part number}\marg{postfix track number}\\ % \vdots\\ % |\end{question}| % \end{quote} % % \subsubsection{Mathematical symbology} % % Various mathematical symbols and elements are defined for convenience, working from the normal suggested formats used within Open University courses. These are mostly as proscribed by the various standards bodies too, for reference see ``Quantities and units - Part 2: Mathematics'' ISO 80000‑2:2019\footnote{Available from British Standards Online as BS EN ISO-2:2019 (ISBN 978 0 539 23108 3), The European Standards Agency and The International Standard Organisetion. All are purchasable publications.} % % These commands are created in such a manner that they will work correctly in both text and maths modes. % % \begin{description} % \item[Differential operators] \DescribeMacro{\dd}\DescribeMacro{\e}\DescribeMacro{\ii}The general advise for most \OU\ modules is to use an upright letter `d' when specifying differential variables, thus \cs{dd} is provided to allow simple accomodation of this. Similarly, Euler's number and the imaginary unit representation of $\sqrt{-1}$ are both usually given upright letters of `e', (\cs{e}), and `i', (\cs{ii}), respectively. % % \begin{docsidebar}[Note] % Remember that it is the exception that proves the rule: always follow the the module guidebook for course being completed. % \end{docsidebar} % \begin{dtxexample}*{Differential} % In display mode, compare \dd\ with $d$: % \[ % \frac{\dd^2 y}{\dd x^2} + x\frac{\dd y}{\dd x} + y = 2\sin(x)\\ % \] % and in line mode $\e^{\ii x} = \cos(x) + \ii\sin(x)$ % \end{dtxexample} % % \item[Number sets] Standard `black-board' fonts are used to indicate a number of frequently designated groups of numbers. % % \begin{description} % \ItemDescribeMacro{\N} \N\ represents all natural numbers; % \ItemDescribeMacro{\Z} \Z\ represents all integers; % \ItemDescribeMacro{\Q} \Q\ represents all rational numbers; % \ItemDescribeMacro{\R} \R\ represents all real numbers; and % \ItemDescribeMacro{\Complex} \Complex\ represents all complex numbers. % \end{description} % % \begin{dtxexample}*{Number sets} % The relationship between number sets: % \begin{itemize} % \item \N\ (Natural numbers) $\subseteq \Z$ (Integers); % every natural number is also an integer. % \item \Z\ (Integers) $\subseteq \Q$ (Rational numbers); % every integer is also a rational number. % \item \Q\ (Rational numbers) $\subseteq \R$ (Real % numbers); every rational number is also a real % number. % \item \Complex\ (Complex numbers) $\supseteq \R$ (Real % number); complex numbers include real numbers as % a subset, since they can be represented by % $a+\ii b$ where $a$ and $b$ are real numbers. % \end{itemize} % \end{dtxexample} % % \item[Vector notation] \DescribeMacro{\vect}\DescribeMacro{\ve}\DescribeMacro{\vi}\DescribeMacro{\vj}\DescribeMacro{\vk}\DescribeMacro{\Mag}Two different vector representations are typically used on \OU\ modules, there is the two, or more, letter with an over arrow version given with \cs{vect}; and the emboldened upright letter version \cs{ve}---the latter is commonly handwritten as an underlined letter. % % The three vectors \vi, \vj and \vk are usually reserved to indicate the unit vectors within a system. % % The magnitude of a vector is the scalar length of that vector, irrespective of direction. This is commonly represented by the use of vertical bars, \Mag{\ve{vector}}, using this command automatically resizes the vertical bars to accomodate the contents. % % \begin{dtxexample}*{Vectors} % Given a point $A$ at the co-ordinate $(6, 3)$ and a % point $B$ at the co-ordinate $(-4, 8)$, the vector % $\vect{AB}$ has a gradient of $\frac{8-3}{-4-6} = % \frac{5}{-10} = -\frac{1}{2}$, and a magnitude of % \Mag{\vect{AB}}. % The standard unit vectors in 2-D space are \vi and \vj. % They are usually at right angles to each other. % The vector $\vect{AB}$ may be represented by a bold % letter such as \ve{v}. %\end{dtxexample} % % \item[Ordinal indicators] \DescribeMacro{\st}\DescribeMacro{\nd}\DescribeMacro{\rd}\DescribeMacro{\nth}The use of ordinal indicators is not specific to \OU\ modules, but frequently is a useful element that is just inconvenient to produce. % % So the standard four English ordinals are provided \cs{st}, \cs{nd}, \cs{rd}, and \cs{nth}, e.g. 1\st, 2\nd, 3\rd, and 4\nth. % % Note that the last ordinal is \cs{nth} not \cs{th}, the latter produces a thorn character, \th, and that only works if you have other than the default 7-bit font encoding (\acro{OT1}). % % \item[Combinatoral notations] There are two combinatoral forms that are commonly used in \OU\ modules, the combination selecting $r$ out of a total of $n$ items where order does not matter, and the permutations of $r$ out of $n$ items were order matters. % \begin{description} % \ItemDescribeMacro{\comb}\marg{n}\marg{r}. This is equivelent to \[ % \comb{n}{r} = \frac{n!}{r!(n-r)!} % \] % \ItemDescribeMacro{\perm}\marg{n}\marg{r}. This is equivalent to \[ % \perm{n}{r} = \frac{n!}{(n-r)!} % \] % \end{description} % % \item[Group theory] Some awkward to enter elements are defined here to help typeset various group notations. % \changesTMA{v1.21.6}{2025-12-15}{Added group theory notation for generators and order.} % % \begin{description} % \ItemDescribeMacro{\gen}\marg{x}. This represents a cyclic group generated by $x$. Rendered as \gen{x}. % \ItemDescribeMacro{\Ord}\marg{G}. This represents the order of group $G$. Rendered as \Ord{G}. % \end{description} % % \item[Mathematical operators] Additional mathematical operators are defined, again for convenience of entry. % \begin{description} % \ItemDescribeMacro{\re} $\mapsto \re$ % \ItemDescribeMacro{\im} $\mapsto \im$ % \ItemDescribeMacro{\Log} $\mapsto \Log$ % \ItemDescribeMacro{\Arg} $\mapsto \Arg$ % \ItemDescribeMacro{\Wnd} $\mapsto \Wnd$ % \ItemDescribeMacro{\Res} $\mapsto \Res$ % \ItemDescribeMacro{\Ker} $\mapsto \Ker$ % \ItemDescribeMacro{\Orb} $\mapsto \Orb$ % \ItemDescribeMacro{\Stab} $\mapsto \Stab$ % \ItemDescribeMacro{\Fix} $\mapsto \Fix$ % \end{description} % % \item[Derivatives] There are three derivative forms defined specifically for % speeding calculas entry and accuracy. One used the $\dd x$ form, with an % optional variant to specify the degree, and two use % the partial, $\partial x$, form. % % \changesTMA{v1.22}{2026-11-16}{Allow optional argument to be added to the \cs{deriv}\ command specifying the degree of the derivation.} % \begin{description} % \ItemDescribeMacro{\deriv}\marg{y}\marg{x} $\mapsto \deriv{y}{x}$ % \ItemDescribeMacro{\deriv}\oarg{degree}\marg{y}\marg{x} $\mapsto \deriv[2]{y}{x}$ % \ItemDescribeMacro{\pderiv}\marg{y}\marg{x} $\mapsto \pderiv{y}{x}$ % \ItemDescribeMacro{\psderiv}\marg{y}\marg{x}\marg{z} $\mapsto \psderiv{y}{x}{z}$ % \end{description} % % \item[Additional symbols] A couple of additional symbols are available for use in different modules, or purely for convenience. % % \begin{description} % \ItemDescribeMacro{\rect} \cs{rect}, \rect, is defined particularly for the % use of \acro{M208} people although others may find it useful. % \ItemDescribeMacro{\ld} \cs{ld}, \ld, is another useful definition for \acro{M208} % student who may be taxed by the number of times they need to type, and then % correct their spelling of, \cs{lambda}. The macro will work correctly in both % text and maths mode. \emph{This is an \stmas\ macro.} % \ItemDescribeMacro{\Pounds}\marg{value} \cs{Pounds} displays a Pound Sterling % amount in the appropriate format with two decimal places (rounded as necessary). % For example |\Pounds{2.56}| renders as \Pounds{2.56}. \emph{This is an \stmas\ macro.} % \end{description} % % \item[Statistics devices] A common device in statistics is the `Five value statistic summary', it is communicated via a standardised graphic. % % \DescribeMacro{\FiveStats}\oarg{n}\marg{min}\marg{max}\marg{median}\marg{Q1}\marg{Q3} % \cs{FiveStats} uses \TikZ\ to draw the appropriate diagram. For example:\\ % |\FiveStats[30]{1}{10}{5.5}{3}{8}| results in \FiveStats[30]{1}{10}{5.5}{3}{8} % % The count of values, $n$, is optional. \emph{This is part of the \stmas\ package.} % % \item[Supplementary commands] Extra commands supporting specific tasks. % % \changesSUP{v0.15}{2025-12-29}{Added \cs{AugMatrix} command for augmented matrix typesetting.} % \DescribeMacro{\AugMatrix} % \cs{AugMatrix} typesets an augmented matrix (using \cs{pmatrix}) with % optional material to the left and/or right of the matrix. % % \medskip % \noindent % \textbf{Syntax} % \begin{quote} % \cs{AugMatrix}\oarg{colspec}\marg{body}\\ % \cs{AugMatrix}\oarg{colspec}\marg{body}\oarg{left}\oarg{right}\\ % \cs{AugMatrix*}\oarg{colspec}\marg{body}\oarg{left}\oarg{right}\\ % \end{quote} % % \medskip % \noindent % \textbf{Arguments} % \begin{description} % \item[\meta{colspec}] The array preamble used for the matrix body, % e.g.\ |rrr|, |r r r|, or |rr| \verb+|+ |r| % to indicate an augmented column. The default is |c| \verb+|+ |c|. % \item[\meta{body}] The matrix rows, using |&| and |\\| as usual. % \item[\meta{left}] Optional material to be placed to the left of the matrix. % \item[\meta{right}] Optional material to be placed to the right of the matrix. % \end{description} % % \medskip % \noindent % \textbf{Starred vs.\ unstarred} % % In the unstarred form, the left and right arguments (if non-empty) are % typeset as single-column arrays so that their rows align with the rows of % the matrix. The left column is centred (|c|) and the right column is % left-aligned (|l|). % % In the starred form, the left and right arguments are inserted \emph{raw} % (no automatic alignment structure is added). This is useful if you want % complete control, for example to insert your own alignment, delimiters, % or multi-line constructions. % % \medskip % \noindent % \textbf{Examples} % \begin{quote} % \verb+\AugMatrix[rr|r]{1 & 2 & 3\\4 & 5 & 6}+ \\ % produces an augmented matrix with a vertical rule between the second and % third columns. % % \medskip % \verb+\AugMatrix[rr|r]{1 & 2 & 3\\4 & 5 & 6}[R_1\\R_2][\text{pivot}\\\text{row}]+ \\ % places row labels on the left and annotations on the right, aligned to the % matrix rows. % % \medskip % \verb+\AugMatrix*[rr|r]{1 & 2 & 3\\4 & 5 & 6}[\left\{][\right\}]+ \\ % inserts the braces raw (starred form), allowing custom structures not % constrained to row alignment. % \end{quote} % % \medskip % \noindent % Internally, \cs{AugMatrix} uses an outer three-column \texttt{array} to position % left material, the matrix, and right material with compact spacing. % % % \changesSUP{v0.15}{2025-12-29}{Added shortcut for module handbook references.} % \DescribeMacro{\HB} % % \cs{HB} typesets a compact reference to the \emph{Handbook}, with optional % page and section references. % % \medskip % \noindent % \textbf{Syntax} % \begin{quote} % |\HB| \\ % |\HB|\oarg{page} \\ % |\HB|\oarg{page}\oarg{section} % \end{quote} % % \medskip % \noindent % \textbf{Description} % % The command produces the small-caps text \textsc{hb}, followed by % optional page and section qualifiers. The first optional argument % specifies a page number or page range; the second optional argument % specifies a section or section range. % % \medskip % \noindent % \textbf{Examples} % \begin{quote} % \verb|\HB| \quad produces \textsc{hb} \\ % \verb|\HB[23]| \quad produces \textsc{hb}\,p23 \\ % \verb|\HB[23][4]| \quad produces \textsc{hb}\,p23\,\S4 % \end{quote} % % \medskip % \noindent % The command is robust and implemented using \texttt{expl3} conventions. % % \item[Legacy elements] There are a couple of macros which become enabled when % using the \optn{legacy} option. These are now deprecated and may be removed % from a future version. There are name clashes with standard \LaTeX\ commands, % so please be aware of this if used. % % \begin{description} % \ItemDescribeMacro[c=legacy]{\C} is the original version of \cs{Complex} % \ItemDescribeMacro[c=legacy]{\vec} is the original version of \cs{vect} % \end{description} % % \end{description} % % \MaybeStop{ % \clearpage % \printchangesTMA % \bigskip % \printchangesSUP % \bigskip % \printchangesCHG % \clearpage % \PrintIndex %} % % \section{Implementation of \stma} % % \iffalse %<*ou-tma.sty> % \fi % From this point, where you see the double ``at'' symbol, you should read it as though it is `tma'.\\ %<@@=tma> % \begin{macrocode} %% ou-tma.sty %% Copyright 2025-2026 G. I. Riley % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005-12-01 or later. % % This work has the LPPL maintenance status `maintained.' % % The Current Maintainer of this work is Geoff Riley. % %% This package may be freely used, especially by, but not limited to, %% students, lecturers and staff of the Open University. It was created %% by the efforts of many who are now or have been connected with the %% Open University Students Association. No acknowledgement is %% _required_ for using this package within the production of a _Tutor %% Marked Assessment._ % \end{macrocode} % % Adapted by Peter McFarlane from various sources. % All errors of style or content are mine or subsequent contributors. % Acknowledgements to Bob Margolis and Rob Lynas (from whom some macros % are plagiarised). % Further contributions from Steve Mayer and Tim Dale. % Annotations, in part, and further modification by Geoff Riley. % % % Package Options % \begin{itemize} % \item[\cs{[alph]}] (default) question numbering as 1(b)(iii) % \item[\cs{[roman]}] varies question numbering to sequence used by M381 % i.e. 1(ii)(c) % \item[\cs{[cleveref]}] question numbering creates automatic referencing for % use with cleveref package % \item[\cs{[pdfbookmark]}] add PDF bookmarks for each question using hyperref package % \item[\cs{[legacy]}] enables old definitions of |\vec| and |\C| for backward % compatibility % \end{itemize} % % To use a package option, place the option(s) before the package name:\\\nopagebreak % \fqquad\cs{usepackage}|[roman,cleveref]{ou-tma}| % % \changesTMA{v1.21.5}{2025-11-19}{ % Started updating code to use the double-at prefixes to the localised code.} % \changesTMA{v1.21.4}{2025-11-17}{ % Added functions \cs{MakePrivateLetters} and \cs{ClearPrivateLetters} to allow % \pkg{expl3} elements to be indexed.} % \changesTMA{v1.20}{2025-04-07}{ % Package name changed from `tma' to `ou-tma' to become a % little more descriptive and to abide by the minimum package % name length suggested by \CTAN.} % \changesTMA{v1.19}{2025-02-18}{ % PDF metadata (apparently) was solved with help from Steve Mayers; all down % to the use of commands as string containers. New (\LaTeX3) commands % are robust and fail to expand within the context of the metadata and % bookmarks; old (\LaTeX2e) commands are fragile and correctly expanded. I % have a mix of old commands and new variables now.} % \changesTMA{v1.18}{2025-02-16}{ % PDF metadata doesn't set correctly so I have removed it: the cause is an % incompatibility between \LaTeX\ unicode and the PDF restricted character % allowance.} % \changesTMA{v1.17}{2025-02-13}{ % Rewritten with \LaTeX3\ syntax from the `xparse' package to make commands % less fragile. % Finally, I got the alignment of part and subpart numbering to line up correctly.} % \changesTMA{v1.16}{2024-11-22}{ % Added File Properties to pdf files using the hyperref setup system when % in pdfbookmark mode.} % \changesTMA{v1.15}{2024-11-21}{ % Define \cs{setdate} and \cs{thedate} to allow the header date to be used within % the document, eg header and footer.} % \changesTMA{v1.14}{2024-11-17}{ % Allow replacement of Question marker tag using \cs{setquestionstring}. % References with cleveref not working. % Replaced my attempts at keeping \cs{qpart} and \cs{qsubpart} on the same line with % Steve Mayers contribution.} % \changesTMA{v1.13}{2024-11-16}{ % Arranged for \cs{qsubpart} to go on the same line as the \cs{qpart} when % there is no intervening text % \cs{qsubpart} indents further than \cs{qpart}.} % \changesTMA{v1.12}{2024-11-08}{ % Standardized package name to 'tma' to make it compatible with \CTAN. % Avoided redefining standard \LaTeX\ commands. % Consolidated geometry settings. % Adjusted loading order of packages. % Improved code readability and comments. % Added 'legacy' option to allow old definitions of \cs{vec} and \cs{C}.} % % Before getting into the main package, it is necessary to ensure that the \LaTeX3\ extensions are loaded. Most modern versions of the \LaTeX\ core have this rolled in as standard, but as a belt and braces approach, inclusion here does no harm. % \begin{macrocode} \RequirePackage{expl3} % LaTeX3 "experimental" % \end{macrocode} % % \subsection{Package Initialisation} % % We are starting off using the \cs{ExplSyntaxOn} command to enable the \LaTeX3\ extensions before declaring a set of `constants' that will be used by our package. Working with the established conventions the constants are declared as variables are named to reflect their ownership and function. These are all declared as `token lists' so that they may, effectively, hold string elements. % \begingroup % \catcode`_=11 % Make the underscore character a letter! % \begin{description} % \ItemDescribeVariable{g_@@_constant_name} holds the students personal name % \ItemDescribeVariable{g_@@_constant_tma} holds the number of the \TMA\ being answered % \ItemDescribeVariable{g_@@_constant_course} holds the \OU\ course code for the module being studied % \ItemDescribeVariable{g_@@_constant_pin} holds the students personal identification number % \ItemDescribeVariable{g_@@_constant_thedate} holds the date to be printed on the front page of the \TMA % \end{description} % \endgroup % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%% %% Package Initialization % %%%%%%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOn \tl_new:N \g_@@_constant_name \tl_new:N \g_@@_constant_tma \tl_new:N \g_@@_constant_course \tl_new:N \g_@@_constant_pin \tl_new:N \g_@@_constant_thedate % \end{macrocode} % These `constants' are given initial generic values. % \begin{macrocode} \tl_gset:Nn \g_@@_constant_name {name} \tl_gset:Nn \g_@@_constant_tma {tma} \tl_gset:Nn \g_@@_constant_course {course} \tl_gset:Nn \g_@@_constant_pin {pin} \tl_gset:Nn \g_@@_constant_thedate {the~date} % \end{macrocode} % Then commands are provided to retrieve the values when required. % \begin{description} % \ItemDescribeMacro{\name} returns the students name % \ItemDescribeMacro{\tma} returns the working \TMA\ number % \ItemDescribeMacro{\course} returns the \OU\ course reference % \ItemDescribeMacro{\pin} returns the students personal identification number % \ItemDescribeMacro{\thedate} returns the date to be printed on the title page of the \TMA % \end{description} % \begin{macrocode} \newcommand{\name}{\g_@@_constant_name} \newcommand{\tma}{\g_@@_constant_tma} \newcommand{\course}{\g_@@_constant_course} \newcommand{\pin}{\g_@@_constant_pin} \newcommand{\thedate}{\g_@@_constant_thedate} % \end{macrocode} % Finally, macros are provided to set the values of the `constants': these should only be used within the preamble. Use within the body of the text is unpredicable. % \begin{description} % \ItemDescribeMacro{\myname}\marg{name} Set the students name % \ItemDescribeMacro{\mytma}\marg{\TMA\ number} Set the \TMA\ number % \ItemDescribeMacro{\mycourse}\marg{course code} Set the \OU\ course code for the module % \ItemDescribeMacro{\mypin}\marg{pin} Set the students personal identification number % \ItemDescribeMacro{\setdate}\marg{the date} Set the required date to display on the title page, default is the date of report generation % \end{description} % \begin{macrocode} \NewDocumentCommand{\myname}{m}{% \tl_gset:Nn \g_@@_constant_name{#1}} \NewDocumentCommand{\mytma}{m}{% \tl_gset:Nn \g_@@_constant_tma{#1}} \NewDocumentCommand{\mycourse}{m}{% \tl_gset:Nn \g_@@_constant_course{#1}} \NewDocumentCommand{\mypin}{m}{% \tl_gset:Nn \g_@@_constant_pin{#1}} \NewDocumentCommand{\setdate}{m}{% \date{#1}\tl_gset:Nn \g_@@_constant_thedate{#1}} % \end{macrocode} % That's the end of the \LaTeX3\ extensions requiring the extension switch, so it can be turned off. % \begin{macrocode} \ExplSyntaxOff % \end{macrocode} % Set the \cs{title} and \cs{author} ready for use by the \cs{maketitle} macro at the start of the main document. They use the constants defined above so that changes are automatically reflected. They may be redefined by the user if required. % \begin{macrocode} \title{\textbf{TMA: \course-\tma}} \author{\textbf{\name\space\pin}} % \end{macrocode} % % \makeatletter % In order to allow the question introduction string to be modified, a general \LaTeX\ string is created along with a macro to set it. % \begin{description} % \ItemDescribeMacro{\tma@questionalignment} Holds the string alignment to the left margin, the default is `r'. This is particularly useful for question strings that might otherwise extend beyond the left hand reach of the left hand page border. % \changesTMA{v1.21.2}{2025-10-28}{Added alignment variation for question string, suggested by Bruce Ramsey.} % \ItemDescribeMacro{\tma@questionstring} Hold the string to be printed before the question number, the default is `Q'. % \ItemDescribeMacro{\setquestionstring}\oarg{char}\marg{string} Set the string to precede the question number % \end{description} % \makeatother % % \begin{macrocode} \NewDocumentCommand{\tma@questionalignment}{}{r} \NewDocumentCommand{\tma@questionstring}{}{\relax} \NewDocumentCommand{\setquestionstring}{O{r} m}{% \RenewDocumentCommand{\tma@questionalignment}{}{#1}% \RenewDocumentCommand{\tma@questionstring}{}{#2}% } % \end{macrocode} % Set the default date to `today'. % \begin{macrocode} \setdate{\today} % \end{macrocode} % % \subsection{Package Loading} % % Here we load the useful packages that have proven their worth for \OU\ students over the years. Many have properties that are utilised by the rest of the \stma\ package. % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Package Loading % %%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{amsmath} \RequirePackage{amssymb} \RequirePackage{amsthm} \RequirePackage{wasysym} \RequirePackage{bm} \RequirePackage{upgreek} \RequirePackage{graphicx} \RequirePackage{lastpage} \RequirePackage{xifthen} \RequirePackage{verbatim} \RequirePackage{fancyhdr} \RequirePackage{geometry} \RequirePackage{calc} \RequirePackage{etoolbox} \RequirePackage{xspace} \RequirePackage[UKenglish]{isodate} % use UK format for date \cleanlookdateon % remove th,st, rd from date % \end{macrocode} % % \subsection{Geometry Settings} % % An important part of \TMA\ answering is providing a consistent output, to this end the following page geometry has been brought together as a compromise suitable for most modules. % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Geometry Settings % %%%%%%%%%%%%%%%%%%%%%%%%%%% \geometry{ headheight=10mm, headsep=5mm, bottom=25mm, footskip=15mm, left=30mm, right=30mm, marginparwidth=0mm, marginparsep=0mm, includemp } % \end{macrocode} % % \subsection{Margin Notes} % % By default, no margin notes are assumed to be required, however, if one is wanted, the \DescribeMacro{\marginnotes}\cs{marginnotes} command will set up the side margin ready to accept notes using the \DescribeMacro{\marginnote}\cs{marginnote}\marg{note} command. % % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Margin Notes % %%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\marginnote}{m}{\marginpar{#1}} \NewDocumentCommand{\marginnotes}{}{ \geometry{ marginparwidth=40mm, marginparsep=5mm, left=20mm, right=15mm } } % \end{macrocode} % % \subsection{Question Numbering} % % We set up three counters to keep track of the question number along with associated parts and subparts. % \begin{description} % \ItemDescribeCounter{question} Holds the current question number, when a new question is started this value is used unless one is provided, in either case the used value is incremented as saved back here. When used, the \cs{qpart} is automatically reset so that the first part will be part 1. % \ItemDescribeCounter{qpart} Holds the current part number as a numeric value, as with the question number this may be overridden and is incremented after being used. When used, the \cs{qsubpart} is automatically reset so that the first subpart will be sub-part 1. % \ItemDescribeCounter{qsubpart} Holds the current sub-part number as a numeric value, again, the value may be overridden and is incremented after being used. % \end{description} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Question Numbering % %%%%%%%%%%%%%%%%%%%%%%%%%%% \newcounter{question} \newcounter{qpart}[question] \newcounter{qsubpart}[qpart] % \end{macrocode} % The question number is set to print as arabic digits, % \begin{macrocode} \renewcommand{\thequestion}{\arabic{question}} % \end{macrocode} % % \subsection{Option Handling} % \makeatletter % In order to handle the incoming options for the \stma\ package, we create a set of four new boolean tokens. % \begin{description} % \ItemDescribeBoolean{tma@roman} False indicates `alph' numbering, true indicates `roman' numbering of parts and subpart. % \ItemDescribeBoolean{tma@usecleveref} True indicates that the \pkg{cleveref} package is requested. % \ItemDescribeBoolean{tma@usepdfbookmark} True indicated that the \pkg{pdfbookmark} package is requested. % \ItemDescribeBoolean{tma@legacy} True indicted that the commands \cs{Complex} and \cs{vect} will be redefined to the legacy commands \cs{C} and \cs{vec}. % \end{description} % \makeatother % % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Option Handling % %%%%%%%%%%%%%%%%%%%%%%%%%%% % Define boolean flags \newif\iftma@roman \newif\iftma@usecleveref \newif\iftma@usepdfbookmark \newif\iftma@legacy % Set default options \tma@romanfalse % Default numbering is `alph' \tma@useclevereffalse % Default is not to use cleveref \tma@usepdfbookmarkfalse % Default is not to use pdfbookmark \tma@legacyfalse % Default is not to use legacy definitions % \end{macrocode} % % \makeatletter % We now set up the default states and commands for the \stma\ package operation. % \begin{description} % \ItemDescribeMacro{\theqpart} returns the current question part number as either an alpha or roman index. % \ItemDescribeMacro{\theqsubpart} returns the current question subpart number as either a roman or an alpha index. % \ItemDescribeMacro{\tma@crefname}\marg{label type}\marg{singular name}\marg{plural name} Declares a label with singular and plural spellings for the \pkg{cleveref} package. % \ItemDescribeMacro{\tma@stepcounter}\marg{counter name} Increments the named counter by one. % \ItemDescribeMacro{\tma@bookmark}\oarg{level}\marg{text}\marg{name} The level is optional, numerical, the default is zero, the top level. The text is what will appear in the bookmark panel, and the name is what may be used as a reference to the location from other parts of the document. % \ItemDescribeMacro{\tma@pageref}\marg{name} returns the page number, if known, that contains the bookmark with the label name. % \end{description} % \makeatother % % \begin{macrocode} % Define commands with default values \renewcommand{\theqpart}{\alph{qpart}} \renewcommand{\theqsubpart}{\roman{qsubpart}} \NewDocumentCommand{\tma@crefname}{mmm}{\relax} \NewDocumentCommand{\tma@stepcounter}{m}{\stepcounter{#1}} \NewDocumentCommand{\tma@bookmark}{O{0}mm}{\relax} \NewDocumentCommand{\tma@pageref}{m}{\pageref{#1}} % \end{macrocode} % % Declare each of the valid options for the option processing system. In each case, the action is to set the appropriate boolean to true or false. % % \begin{macrocode} % Declare options \DeclareOption{roman}{% \tma@romantrue% } \DeclareOption{alph}{% \tma@romanfalse% } \DeclareOption{cleveref}{% \tma@useclevereftrue% } \DeclareOption{pdfbookmark}{% \tma@usepdfbookmarktrue% } \DeclareOption{legacy}{% \tma@legacytrue% } \DeclareOption*{% \PackageWarning{ou-tma}{Unknown option `\CurrentOption'}% } % \end{macrocode} % Go ahead, process those options! % \begin{macrocode} % Process options \ProcessOptions\relax % \end{macrocode} % % \subsection{Debugging Options} % % A short section of code outputting to the log the state of the four main options that may be passed to the \stma\ package. % % \begin{macrocode} \typeout{**************** OPTION RESULTS **********} \iftma@usepdfbookmark \typeout{pdfbookmark is TRUE} \else \typeout{pdfbookmark is FALSE} \fi \iftma@roman \typeout{roman is TRUE} \else \typeout{roman is FALSE} \fi \iftma@usecleveref \typeout{cleveref is TRUE} \else \typeout{cleveref is FALSE} \fi \iftma@legacy \typeout{legacy is TRUE} \else \typeout{legacy is FALSE} \fi \typeout{************* END OPTION RESULTS **********} % \end{macrocode} % % \subsection{Package adjustments based on Options} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Set Up Package Based on Options % %%%%%%%%%%%%%%%%%%%%%%%%%%% % Set question numbering \iftma@roman \renewcommand{\theqpart}{\roman{qpart}} \renewcommand{\theqsubpart}{\alph{qsubpart}} \else \renewcommand{\theqpart}{\alph{qpart}} \renewcommand{\theqsubpart}{\roman{qsubpart}} \fi % Load hyperref if necessary \iftma@usepdfbookmark \AtBeginDocument{% \hypersetup{% colorlinks=true,% linkcolor=blue,% urlcolor=blue,% pdfstartview=FitH,% pdftitle={TMA~\tma}, % pdfauthor={\name~\textemdash~\pin}, % pdfkeywords={OUCU:~\pin, TMA~\tma}, % pdfsubject=\course% }% } \RequirePackage[hyperindex=false,pdfencoding=unicode,psdextra]{hyperref} \fi % Load cleveref if necessary \iftma@usecleveref % Ensure hyperref is loaded before cleveref \@ifpackageloaded{hyperref}% {}% {\RequirePackage[hyperindex=false,pdfencoding=unicode,psdextra]{hyperref}} \RequirePackage{cleveref} % Redefine commands for cleveref \RenewDocumentCommand{\tma@crefname}{mmm}{\crefname{#1}{#2}{#3}} \RenewDocumentCommand{\tma@stepcounter}{m}{\refstepcounter{#1}} \fi % Redefine commands for pdfbookmark \iftma@usepdfbookmark \RenewDocumentCommand{\tma@pageref}{m}{\pageref*{#1}} \RenewDocumentCommand{\tma@bookmark}{O{0} +m +m}{% \pdfbookmark[#1]{#2}{#3}% } \fi \setquestionstring{Q} % \end{macrocode} % % \subsection{Question Environment} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Question Environment % %%%%%%%%%%%%%%%%%%%%%%%%%%% % Set up cref names if cleveref is used \iftma@usecleveref \tma@crefname{question}{question}{questions} \tma@crefname{qpart}{part}{parts} \tma@crefname{qsubpart}{section}{sections} \fi % \end{macrocode} % % Commands to introduce Questions, parts and subparts. % % In each case, an optional argument allows a fixed starting `number' to be included to override the default of using the next. % \changesTMA{v1.21.2}{2025-10-28}{Added alignment variation for question string, suggested by Bruce Ramsey.} % \begin{macrocode} \NewDocumentEnvironment{question}{O{0}}{% \ifthenelse{#1>0}{\setcounter{question}{#1-1}}{\relax}% \tma@stepcounter{question}% \tma@bookmark{Question \thequestion}% {question\thequestion}% \makebox[0em][\tma@questionalignment]{\large{\tma@questionstring~\thequestion% \hspace{0.3em}}}\par% }{% \par \vspace{3em}% } \NewDocumentCommand{\qpart}{O{0}}{% \ifthenelse{#1>0}{\setcounter{qpart}{#1-1}}{\relax}% \tma@stepcounter{qpart}% \tma@bookmark[1]{\thequestion.\theqpart}% {qpart.\thequestion.\theqpart}% \par% \makebox[0pt][r]{\large{(\theqpart)\hspace{1.5em} }}% } \NewDocumentCommand{\qsubpart}{O{0}}{% \ifthenelse{#1>0}{\setcounter{qsubpart}{#1-1}}{\relax}% \tma@stepcounter{qsubpart}% \tma@bookmark[2]{\thequestion.\theqpart.\theqsubpart}% {qsubpart.\thequestion.\theqpart.\theqsubpart}% \ifthenelse{\value{qsubpart}>1}% {\par}{}% \hspace{-2em}\makebox[2em][l]{\large{(\theqsubpart)}}% } % \end{macrocode} % % \subsection{Mathematical commands} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Mathematical Commands % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Differential Operators \NewDocumentCommand{\dd}{}{\ensuremath{\mathop{}\!\mathrm{d}}} \NewDocumentCommand{\e}{}{\ensuremath{\mathrm{e}}} \NewDocumentCommand{\ii}{}{\ensuremath{\mathrm{i}}} %% Number Sets \NewDocumentCommand{\N}{}{\ensuremath{\mathbb{N}}} \NewDocumentCommand{\Z}{}{\ensuremath{\mathbb{Z}}} \NewDocumentCommand{\Q}{}{\ensuremath{\mathbb{Q}}} \NewDocumentCommand{\R}{}{\ensuremath{\mathbb{R}}} \NewDocumentCommand{\Complex}{}{% \ensuremath{\mathbb{C}}} % Changed from \C to \Complex \NewDocumentCommand{\Rr}{}{\ensuremath{\mathcal{R}}} %% Vector Notation \NewDocumentCommand{\vect}{m}{% \ensuremath{\overrightarrow{#1}}} % Changed from \vec to \vect % \end{macrocode} % \changesTMA{v1.22}{2026-11-16}{Changed \cs{ve}\ command to use \cs{mathbf}\ rather than \cs{textbf}\ in order to allow maths characters to be represented as vectors.} % \changesTMA{v1.22}{2026-11-16}{Added \cs{vi}, \cs{vj}, \cs{vk}\ and \cs{Mag}\ to set the three main unit vectors plus the vertical bar representation of a vector magnitude, bars auto-resize.} % \begin{macrocode} \NewDocumentCommand{\ve}{m}{\ensuremath{\mathbf{#1}}} \NewDocumentCommand{\vi}{}{\ve{i}\ifmmode\else\xspace\fi} \NewDocumentCommand{\vj}{}{\ve{j}\ifmmode\else\xspace\fi} \NewDocumentCommand{\vk}{}{\ve{k}\ifmmode\else\xspace\fi} \NewDocumentCommand{\Mag}{m}{\ensuremath{\left\lvert{#1}\right\rvert}} %% Ordinal Indicators \NewDocumentCommand{\st}{}{\textsuperscript{st}} \NewDocumentCommand{\nd}{}{\textsuperscript{nd}} \NewDocumentCommand{\rd}{}{\textsuperscript{rd}} \NewDocumentCommand{\nth}{}{\textsuperscript{th}} %% Additional Symbols \NewDocumentCommand{\rect}{}{\ensuremath{\sqsubset\!\!\sqsupset}} %% Combinatorial Notations \NewDocumentCommand{\comb}{mm}{\ensuremath{{}^{#1}C_{#2}}} % \end{macrocode} % \changesTMA{v1.21.1}{2025-10-10}{Adjustment of kerning in \cs{perm} suggested by Peter Osment} % \begin{macrocode} \NewDocumentCommand{\perm}{mm}{\ensuremath{{}^{#1}\!P_{#2}}} % \end{macrocode} % \changesTMA{v1.21.6}{2025-12-15}{Added group theory notation for generators and order.} % \begin{macrocode} %% Group Theory Notation \NewDocumentCommand{\gen}{m}{\ensuremath{\langle #1\rangle}} \NewDocumentCommand{\Ord}{m}{\ensuremath{\left\lvert{#1}\right\rvert}} %% Mathematical Operators \DeclareMathOperator{\re}{Re} \DeclareMathOperator{\im}{Im} \DeclareMathOperator{\Log}{Log} \DeclareMathOperator{\Arg}{Arg} \DeclareMathOperator{\Wnd}{Wnd} \DeclareMathOperator{\Res}{Res} \DeclareMathOperator{\Ker}{Ker} \DeclareMathOperator{\Orb}{Orb} \DeclareMathOperator{\Stab}{Stab} \DeclareMathOperator{\Fix}{Fix} % \end{macrocode} % \changesTMA{v1.22}{2026-11-16}{Allow optional argument to be added to the \cs{deriv}\ command specifying the degree of the derivation.} % \begin{macrocode} %% Derivatives \NewDocumentCommand{\deriv}{O{1}mm}{% \frac{\dd{}% \ifthenelse{#1>1}{^{#1}}{}% #2}{\dd{}#3% \ifthenelse{#1>1}{^{#1}}{}% }} \NewDocumentCommand{\pderiv}{mm}{% \frac{\partial #1}{\partial #2}} \NewDocumentCommand{\psderiv}{mmm}{% \frac{\partial^2 #1}{\partial #2 \partial #3}} % Legacy Definitions \iftma@legacy % Redefine \vec to old definition \RenewDocumentCommand{\vec}{m}{\ensuremath{\overrightarrow{#1}}} % Redefine \C to old definition \ProvideDocumentCommand{\C}{}{\ensuremath{\mathbb{C}}} \RenewDocumentCommand{\C}{}{\ensuremath{\mathbb{C}}} \fi % \end{macrocode} % % \subsection{Theorem Environment} % \changesTMA{v1.21.3}{2025-11-12}{Experimental extentions to theorem code allowing a name to override the given number, and for an automatic label to be appllied using the name.} % \changesTMA{v1.21.6}{2025-12-15}{Removed experimental theorem code returning the original AMS theorem, lemma and corollary definitions.} % Theorems, Lemmas and Corrolaries. Predefined environments for setting\dots the obvious. % \begin{description} % \ItemDescribeEnv{Theory}\oarg{title} If a title is given, then it will placed in parentheses following the theorem number. % \ItemDescribeEnv{Lemma}\oarg{title} As with `Theory' above, specifying a title will place such in parentheses following the lemma number. % \ItemDescribeEnv{Corollary}\oarg{title} Ditto. % \end{description} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Theorem Environment % %%%%%%%%%%%%%%%%%%%%%%%%%%% \newtheorem{lemma}{Lemma} \newtheorem{theorem}{Theorem} \newtheorem{corollary}{Corollary} % Define \blacksmiley without loading wasysym \ProvideDocumentCommand{\blacksmiley}{}{% \ensuremath{\unicode{263B}}} % Unicode for blacksmiley emoji \RenewDocumentCommand{\qedsymbol}{}{\blacksmiley} % \end{macrocode} % % \subsection{Miscellaneous Settings} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Miscellaneous Settings % %%%%%%%%%%%%%%%%%%%%%%%%%%% \RenewDocumentCommand{\thefootnote}{}{\fnsymbol{footnote}} \numberwithin{equation}{question} \setlength{\parindent}{0pt} \setlength{\parskip}{2ex plus 0.3ex minus 0.2ex} % \end{macrocode} % % \subsection{Header and Footer Settings} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Header and Footer Settings % %%%%%%%%%%%%%%%%%%%%%%%%%%% \pagestyle{fancy} \fancyhf{} % Clear all headers and footers \fancyhead[L]{\textrm{\name\ \pin}} \fancyhead[C]{\textrm{\course\ TMA-\tma}} \fancyhead[R]{\textrm{Page \thepage\ of \tma@pageref{LastPage}}} \RenewDocumentCommand{\headrulewidth}{}{0pt} % Remove header rule % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% End of Package ou-tma % %%%%%%%%%%%%%%%%%%%%%%%%%%% %\endinput % \end{macrocode} % \iffalse % % \fi % % \setcounter{CodelineNo}{0} % \section{Implementation of \stmas} % % \iffalse %<*ou-tma-sup.sty> % \fi % From this point, where you see the double ``at'' symbol, you should read it as though it is `tmasup'.\\ %<@@=tmasup> % \begin{macrocode} %% ou-tma-sup.sty %% Copyright 2025-2026 G. I. Riley %% This package may be freely used, especially by, but not limited to, %% students, lecturers and staff of the Open University. It was created %% by the efforts of many who are now or have been connected with the %% Open University Students Association. No acknowledgement is %% _required_ for using this package within the production of a _Tutor %% Marked Assessment._ % \end{macrocode} % % This is the \OU\ \TMA\ supplementary file. It's purpose is to contain commands % that are less commonly used, probably used by only one or two modules; and % for experimental commands that may be included for testing by a wider % audience but may be deemed unnecessary in the long run. % % \begin{macrocode} % \RequirePackage{expl3} % Automatically loaded with the \ProvidesExplPackage \RequirePackage{ou-tma} % main ou-tma package \ExplSyntaxOn % \end{macrocode} %^^A ------------------------------------------------------------------------------ %^^A README / Package Summary %^^A ------------------------------------------------------------------------------ % This package provides macros for formatting numeric approximations, probability % expressions, monetary values, and statistical diagrams, using expl3 and siunitx. % It is intended for typesetting mathematics and statistics answers in OU TMAs. % %^^A ---------------------- % \subsection{Main formatting commands} %^^A ---------------------- % \DescribeMacro{\tmadp}\oarg{options}\marg{value(s)}\oarg{units}: Round to decimal places % % \DescribeMacro{\tmasf}\oarg{options}\marg{value(s)}\oarg{units}: Round to significant figures % % \DescribeArgument[c=rounding]{value(s)}: should be a comma separated lists giving either two or three numbers: % \begin{itemize} % \item |{x, n}| for one value to n dp/sf % \item |{x, y, n}| for a range from x to y to n dp/sf % \end{itemize} % % \DescribeArgument[c=rounding]{options}: may be one or more pairs of strings joined by an equals sign. Currently defined are the mutually exclusive: % \begin{itemize} % \item |style=bracket| for bracketed range: (x, y) % \item |style=to| (default) for range using: `x to y' % \end{itemize} % %^^A ---------------------- % \subsection{Other useful commands} %^^A ---------------------- % \DescribeMacro{\prob}\marg{event}: Formats $\prob{event}$ when in maths mode. The event may contain logically connecting commands, |\and|, |\or|, |\bar| and |\not|, to build probability expressions so that expressions like \\ % |$\prob{(Journey A \or Journey B) \and Bus}$| % may be set:\\ % $\prob{(Journey A \or Journey B) \and Bus}$. % % \DescribeMacro{\Pounds}\marg{amount}: Formats an amount in pounds sterling with two dp, e.g. \Pounds{3.45} % % \DescribeMacro{\FiveStats}\oarg{n}\marg{min}\marg{max}\marg{med}\marg{Q1}\marg{Q3}: % Draws a 5-number summary diagram using \TikZ. % % \begin{description} % \ItemDescribeArgument[c=fivestats]{n}: (Optional) number of samples % \ItemDescribeArgument[c=fivestats]{min}: Extreme minimum value % \ItemDescribeArgument[c=fivestats]{max}: Extreme Maximum value % \ItemDescribeArgument[c=fivestats]{median}: Median average % \ItemDescribeArgument[c=fivestats]{Q1}: First quartile value % \ItemDescribeArgument[c=fivestats]{Q3}: Third quartile value % \end{description} % % e.g. |\FiveStats[30]{1}{10}{5.5}{3}{8}| % % \FiveStats[30]{1}{10}{5.5}{3}{8} % %^^A ------------------------------------------------------------------------------ % \subsection{Package Initialisation} % \begin{macrocode} \ExplSyntaxOff \RequirePackage{amsmath} \RequirePackage{ifthen} \RequirePackage{siunitx} \sisetup{per-mode = symbol} \sisetup{uncertainty-mode = separate} \RequirePackage{tikz} \RequirePackage{pgfplots} \pgfplotsset{compat=1.18} \usepgfplotslibrary[units] \usetikzlibrary{angles, quotes, calc, arrows.meta, positioning, decorations.markings} % \end{macrocode} % % % \subsection{\TikZ\ styles for solid and hollow dots} % \changesSUP{v0.12}{2025-10-28}{Added \TikZ\ styles for solid and hollow dots used in inclusive and exclusive number lines} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% TikZ styles for solid and hollow dots % %%%%%%%%%%%%%%%%%%%%%%%%%%% % \end{macrocode} % Create \TikZ\ styles for solid and hollow dots: used to mark included and excluded points on number lines and graphs etc. For example $(2,5]\cup[8,10]\cup[12,16)$: % \begin{tikzpicture}[x=0.5cm, y=1cm, thick] % % --- number line --- % \draw[->] (0,0) -- (18,0) node[below right] {$x$}; % % --- tick marks and labels (adjust as you like) --- % \foreach \x in {0,2,4,6,8,10,12,14,16} % { % \draw (\x,0.1) -- (\x,-0.1); % \node[below] at (\x,-0.1) {\x}; % } % % intervals % \draw[very thick] (2,0.3) -- (5,0.3); % \draw[very thick] (8,0.3) -- (9,0.3); % \draw[very thick] (13,0.3) -- (16,0.3); % % use your styles here: % \node[hollowdot] at (2,0.3) {}; \node[soliddot] at (5,0.3) {}; % \node[soliddot] at (8,0.3) {}; \node[soliddot] at (9,0.3) {}; % \node[soliddot] at (13,0.3) {}; \node[hollowdot] at (16,0.3) {}; % \end{tikzpicture} % % \begin{macrocode} \tikzset{ soliddot/.style={ fill=black, draw=black, circle, minimum size=4pt, inner sep=0pt, }, hollowdot/.style={ fill=white, draw=black, circle, line width=0.6pt, minimum size=4pt, inner sep=0pt, }, } % \end{macrocode} % % % \subsection{Question subpart with extention} %\changesSUP{v0.12}{2025-10-28}{Added \cs{qsubparte} to allow a suffix on a question subpart} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Question subpart with extention % %%%%%%%%%%%%%%%%%%%%%%%%%%% % \end{macrocode} % % Make a question subpart with an extension, eg: Q1.a.i-1\\ % Usage:\\ % |\qsubparte[n]{ext}|\\ % \begin{itemize} % \item where \texttt{n} is an optional value to reset the counter, a decimal value, % if omitted, or zero, then continues the previous count; and % \item \texttt{ext} is the required extension string. % \end{itemize} % \begin{macrocode} \NewDocumentCommand{\qsubparte}{O{0}m}{ { \iftma@roman \renewcommand{\theqsubpart}{\alph{qsubpart}-#2} \else \renewcommand{\theqsubpart}{\roman{qsubpart}-#2} \fi \qsubpart[#1] } } % \end{macrocode} % % \DescribeMacro{\tmadp}\oarg{options}\marg{values}\oarg{units}\\ % \DescribeMacro{\tmasf}\oarg{options}\marg{values}\oarg{units}\\ % Each of these macros follow the same format, they produce automatically rendered $n$ decimal % places or significant figures, and can optionally display ranges and units thereof. % The values should be a comma separated list of two or three numbers, the last specifying the % appropriate digit count. If two values are given then they represent a real number followed % by the digit count; and if three values are given, then they represent a range of two real % numbers followed by the digit count. % % Zero padding is applied where needed, so:\\ % |\tmadp(5.5,3)| correctly returns \tmadp{5.5,3}; and\\ % |\tmadp[style=bracket]{2.25,7.25,2}[\gram]| returns % \tmadp[style=bracket]{2.25,7.25,2}[\gram] % % \subsection{Macros to render appropriate decimal places and significant figures} % \changesSUP{v0.12}{2025-10-28}{Added \cs{tmadp} and \cs{tmasf} for setting d.p. amd s.f. texts} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Decimal places and significant figures % %%%%%%%%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOn \tl_if_exist:NF \l__@@_style_tl { \tl_new:N \l__@@_style_tl } \tl_if_exist:NF \l__@@_label_style_tl { \tl_new:N \l__@@_label_style_tl } \keys_define:nn { tma } { style .choice:, style / to .code:n = { \tl_set:Nn \l__@@_style_tl { to } }, style / bracket .code:n = { \tl_set:Nn \l__@@_style_tl { bracket } }, style .initial:n = to, labels .choice:, labels / words .code:n = { \tl_set:Nn \l__@@_label_style_tl { words } }, labels / long .code:n = { \tl_set:Nn \l__@@_label_style_tl { long } }, labels / abbr .code:n = { \tl_set:Nn \l__@@_label_style_tl { abbr } }, labels / short .code:n = { \tl_set:Nn \l__@@_label_style_tl { abbr } }, labels / dp-sf .code:n = { \tl_set:Nn \l__@@_label_style_tl { abbr } }, labels .initial:n = abbr, } % \end{macrocode} % % Parameters for |\tmadp|\oarg{keyval}\marg{data}\oarg{units} and |\tmasf|\oarg{keyval}\marg{data}\oarg{units}: % \begin{itemize} % \item keyval: keyval options like |[style=bracket]| % \item data: data (e.g. |{1.2, 3.4, 2}|) % \item units: optional units (e.g. |[\gram]|) % \item mode added to |\@@_format:nnnn| routine: mode (|dp| or |sf|) % \end{itemize} % % \begin{macrocode} %% Public commands \NewDocumentCommand{\tmadp}{O{}mO{}}{ \@@_format:nnnn {#1}{#2}{#3}{dp} } \NewDocumentCommand{\tmasf}{O{}mO{}}{ \@@_format:nnnn {#1}{#2}{#3}{sf} } % Entry point: parse style and data \cs_new_protected:Nn \@@_format:nnnn { \keys_set:nn { tma } {#1} \@@_parse:nnn {#2}{#3}{#4} } % Parse 2- or 3-item list \cs_new_protected:Nn \@@_parse:nnn { \clist_set:Nn \l_tmpa_clist {#1} \int_case:nnF { \clist_count:N \l_tmpa_clist } { {2}{ \@@_format_single:nnnn { \clist_item:Nn \l_tmpa_clist {1} } { \clist_item:Nn \l_tmpa_clist {2} } {#2} % unit {#3} % mode } {3}{ \@@_format_range:nnnnn { \clist_item:Nn \l_tmpa_clist {1} } { \clist_item:Nn \l_tmpa_clist {2} } { \clist_item:Nn \l_tmpa_clist {3} } {#2} % unit {#3} % mode } } { \textbf{Error: expected 2 or 3 comma-separated values.} } } % Single number (optional unit) \cs_new_protected:Nn \@@_format_single:nnnn { \@@_with_rounding:nnn {#4}{#2} { \tl_if_blank:nTF {#3} { \num{#1} } { \qty{#1}{#3} } \text{~(to~#2~\@@_mode_label:nn {#4}{\l__@@_label_style_tl})} } } % Range (optional unit) with style switch \cs_new_protected:Nn \@@_format_range:nnnnn { % no unit \tl_if_blank:nTF {#4} { \tl_if_eq:NnTF \l__@@_style_tl { bracket } { \@@_output_bracketed_range:nnnnn {#1}{#2}{#3}{#4}{#5} } { \@@_with_rounding:nnn {#5}{#3} { \num{#1}\text{~to~}\num{#2} } } } { % with unit \tl_if_eq:NnTF \l__@@_style_tl { bracket } { \@@_output_bracketed_range:nnnnn {#1}{#2}{#3}{#4}{#5} } { \@@_with_rounding:nnn {#5}{#3} { \SIrange{#1}{#2}{#4} } } } } % Core: locally apply siunitx rounding then typeset #3 % #1 = mode code dp/sf/off, #2 = precision, #3 = content \cs_new_protected:Nn \@@_with_rounding:nnn { \group_begin: \exp_args:Nx \sisetup { round-mode=\@@_mode_map:n {#1}, round-precision=\int_eval:n {#2} } #3 \group_end: } % Bracketed style output; handles math/text mode parens \cs_new_protected:Nn \@@_output_bracketed_range:nnnnn { \@@_with_rounding:nnn {#5}{#3} { \mode_if_math:TF { ( \qty{#1}{#4},~\qty{#2}{#4} ) \text{~(to~#3~\@@_mode_label:nn {#5}{\l__@@_label_style_tl})} } { \text{(}\qty{#1}{#4},~\qty{#2}{#4}\text{)} \text{~(to~#3~\@@_mode_label:nn {#5}{\l__@@_label_style_tl})} } } } % Mapping + label text \cs_new:Npn \@@_mode_map:n #1 { \str_case:nnF {#1} { {dp}{places} {sf}{figures} {off}{off} } { places } } \cs_new:Npn \@@_mode_label:nn #1#2 { \str_case:nnF {#2} { {words}{ \@@_label_words:n {#1} } {long} { \@@_label_long:n {#1} } {abbr} { \@@_label_abbr:n {#1} } } { \@@_label_abbr:n {#1} } } \cs_new:Npn \@@_label_words:n #1 { \str_case:nnF {#1} { {dp}{places} {sf}{figures} {off}{off} } {places} } \cs_new:Npn \@@_label_long:n #1 { \str_case:nnF {#1} { {dp}{decimal~places} {sf}{significant~figures} {off}{off} } { decimal~places } } \cs_new:Npn \@@_label_abbr:n #1 { \str_case:nnF {#1} { {dp}{dp} {sf}{sf} {off}{off} } { dp } } \ExplSyntaxOff % \end{macrocode} % % % \subsection{Pound Sterling printing} %\changesSUP{v0.12}{2025-10-28}{Added \cs{Pounds} for setting Pound Sterling} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Pound Sterling value % %%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\Pounds}{m}{% \pounds\,\num[round-precision=2,round-mode=places]{#1}% } % \end{macrocode} % % % \subsection{Five value statistics summary} %\changesSUP{v0.12}{2025-10-28}{Added \cs{FiveStats} for setting statistic summaries} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Five value statistical summary diagram % %%%%%%%%%%%%%%%%%%%%%%%%%%% % \end{macrocode} % \cs{FiveStats}\oarg{n}\marg{$min_n$}\marg{$max_n$}\marg{$median_n$}\marg{Q1}\marg{Q3} % Print the five stats `square' with the provided values: % \begin{itemize} % \item [$n$]: (Optional) number of samples % \item [$min_n$]: Extreme minimum value % \item [$max_n$]: Extreme Maximum value % \item [$median_n$]: Median average % \item [$Q1$]: First quartile value % \item [$Q3$]: Third quartile value % \end{itemize} % \begin{macrocode} \NewDocumentCommand{\FiveStats}{o mmmmm}{% \begingroup \tikzset{ every node/.style = {font=\footnotesize,inner sep=0pt}, number/.style = {text depth=0pt}, % tidy baselines } %--- global layout knobs you might like to tweak -------- \def\Pad {3pt} % white-space between numbers and walls \def\XGap {25mm} % distance between the L & R interior columns \def\Row {1.7em} % vertical separation between rows %-------------------------------------------------------- \begin{tikzpicture}[baseline=(med.base)] % reference x–coordinates for the two interior columns \coordinate (IL) at (0,0); % interior-left column \coordinate (IR) at (\XGap,0); % interior-right column %---------------- Numbers ----------------- \node[number] (med) at ($ (IL)!0.5!(IR) $) {#4}; \node[number,anchor=west] (q1) at ($(IL)+(0,-\Row)$) {#5}; \node[number,anchor=west] (min) at ($(IL)+(0,-2*\Row)$) {#2}; \node[number,anchor=east] (q3) at ($(IR)+(0,-\Row)$) {#6}; \node[number,anchor=east] (max) at ($(IR)+(0,-2*\Row)$) {#3}; \IfNoValueF{#1}{ % sample size \node[number,anchor=east] (n) at ($(IL)+(-2*\Pad,-\Row)$) {$n = #1$}; } %---------------- Frame ------------------- \coordinate (TL) at ($(q1.west |- med.north) + (-\Pad,\Pad)$); \coordinate (TR) at ($(q3.east |- med.north) + ( \Pad,\Pad)$); \coordinate (BL) at ($(q1.west |- min.south) + (-\Pad,-\Pad)$); \coordinate (BR) at ($(q3.east |- min.south) + ( \Pad,-\Pad)$); % draw: top, right, and left edges \draw[cyan, line width=.4pt] (BL) -- (TL) -- (TR) -- (BR); \end{tikzpicture}% \endgroup } % \end{macrocode} % % % \subsection{Probability expression} % \textbf{\textit{Maths mode only.}} % % \DescribeMacro{\prob} % \cs{prob}\marg{text} typesets a probability statement. It allows the use of % \cs{and}, \cs{or}, \cs{bar} and \cs{not} within the definition so % that expressions like \\ % |$\prob{(Journey A \or Journey B) \and Bus}$| % may be set:\\ % $\prob{(Journey A \or Journey B) \and Bus}$. %\changesSUP{v0.12}{2025-10-28}{Added \cs{prob} for setting probability texts} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Probabilty expression % %%%%%%%%%%%%%%%%%%%%%%%%%%% \ExplSyntaxOn % Main \prob command \NewDocumentCommand{\prob}{m} { \@@_prob_prob:n { #1 } } % Internal implementation with local keyword overrides \cs_new_protected:Nn \@@_prob_prob:n { \mathrm{P}\left( \group_begin: % Locally redefine LaTeX primitives — safely! \cs_set_eq:NN \oldand \and \cs_set_eq:NN \oldor \or \cs_set_eq:NN \oldbar \bar \cs_set_eq:NN \oldnot \not \cs_set:Npn \and { \;\textit{and}\; } \cs_set:Npn \or { \;\textit{or}\; } \cs_set:Npn \bar { \mid } \cs_set:Npn \not { \textit{not}\; } \text{#1} \group_end: \right) } % \end{macrocode} % % % \changesSUP{v0.14}{2025-11-25}{ % Added polygon routines for entering symbols such as octagons directly % in maths mode.} % \subsection{Regular Polygons and Star Polygons in Mathematics Mode} % % The \pkg{ou-tma-sup} package provides commands for typesetting regular % polygons and regular stars directly in mathematics mode. These symbols % are constructed with \pkg{TikZ} and designed to harmonise with the height % and visual weight of standard mathematical symbols. % % All figures produced by the commands in this section: % \begin{itemize} % \item sit on the mathematics baseline; % \item have symbol-sized versions approximately one x-height tall; % \item have enlarged operator versions spaced as \verb|\mathbin|; % \item support both outline and filled variants via TikZ options; % \item include regular $n$-gons and star polygons~$\{n/k\}$. % \end{itemize} % % \DescribeMacro{\mregularpolygon} % \cs{mregularpolygon}\oarg{tikz-options}\marg{n} % % Produces a regular polygon with \meta{n} sides, drawn as a symbol-sized % mathematical object. The optional argument allows arbitrary TikZ drawing % options such as \verb|draw=blue|, \verb|thick|, or \verb|fill=gray!20|. % % \DescribeMacro{\mregularpolygonfill} % As \cs{mregularpolygon}, but filled by default. % % \DescribeMacro{\moctagon} % A convenience macro expanding to \verb|\mregularpolygon{8}|, useful in % group-theoretic notation such as \verb|$S(\moctagon)$|. % % \DescribeMacro{\mregularpolygonop} % A binary-operator-sized version of a regular \meta{n}-gon. These symbols % behave as \verb|\mathbin|. Their enlargement factor can be adjusted by % redefining the internal macro \cs{ou@tma@regularpolygonopscale}. % % \DescribeMacro{\mregularpolygonfillop} % As \cs{mregularpolygonop}, but filled by default. % % \DescribeMacro{\mregularstar} % \cs{mregularstar}\oarg{tikz-options}\marg{n}\marg{k} % % Produces the regular star polygon~$\{n/k\}$, using the same baseline and % height conventions as regular polygons. % % \DescribeMacro{\mregularstarfill} % As \cs{mregularstar}, but filled. % % \DescribeMacro{\mregularstarop} % Binary-operator-sized version of the star polygon $\{n/k\}$. % % \DescribeMacro{\mregularstarfillop} % Filled variant of the operator-sized star polygon. % % \DescribeMacro{\mpentagram} % Convenience macro expanding to the star polygon~$\{5/2\}$. % % Example usage: % % \begin{quote} % \verb|$S(\moctagon)$| \\ % \verb|$G \moctagonop H$| \\ % \verb|$\mregularstar{5}{2}$| \\ % \verb|$\mregularstarfillop{7}{3}$| % \end{quote} % % % \begin{macrocode} % ----------------------------------------- % Low-level TikZ helpers (normal catcodes) % ----------------------------------------- \ExplSyntaxOff % Regular polygon: symbol size \newcommand\ou@tma@regularpolygon[2]{% \tikz[x=1ex, y=1ex, baseline=0pt]{% \pgfmathtruncatemacro{\N}{#2}% \pgfmathtruncatemacro{\NmOne}{#2-1}% \pgfmathsetmacro{\start}{-90 + 180/\N}% \pgfmathsetmacro{\rad}{0.5/cos(180/\N)}% \pgfmathsetmacro{\shift}{0.5}% \draw[line width=0.12ex,#1] ({\rad*cos(\start)},{\shift + \rad*sin(\start)}) \foreach \x in {1,...,\NmOne}{% -- ({\rad*cos(\start + 360*\x/\N)}, {\shift + \rad*sin(\start + 360*\x/\N)})% } -- cycle; }% } % Operator-size scale factor \newcommand\ou@tma@regularpolygonopscale{1.2} % Regular polygon: operator size \newcommand\ou@tma@regularpolygonop[2]{% \tikz[x=1ex, y=1ex, baseline=0pt]{% \pgfmathtruncatemacro{\N}{#2}% \pgfmathtruncatemacro{\NmOne}{#2-1}% \pgfmathsetmacro{\start}{-90 + 180/\N}% \pgfmathsetmacro{\rad}{0.5/cos(180/\N) * \ou@tma@regularpolygonopscale}% \pgfmathsetmacro{\shift}{0.5 * \ou@tma@regularpolygonopscale}% \draw[line width=0.12ex,#1] ({\rad*cos(\start)},{\shift + \rad*sin(\start)}) \foreach \x in {1,...,\NmOne}{% -- ({\rad*cos(\start + 360*\x/\N)}, {\shift + \rad*sin(\start + 360*\x/\N)})% } -- cycle; }% } % Regular star polygon: symbol size \newcommand\ou@tma@regularstar[3]{% \tikz[x=1ex, y=1ex, baseline=0pt]{% \pgfmathtruncatemacro{\N}{#2}% \pgfmathtruncatemacro{\NmOne}{#2-1}% \pgfmathsetmacro{\start}{-90 + 180/\N}% \pgfmathsetmacro{\rad}{0.5/cos(180/\N)}% \pgfmathsetmacro{\shift}{0.5}% \draw[line width=0.12ex,#1] ({\rad*cos(\start)},{\shift + \rad*sin(\start)}) \foreach \t in {1,...,\NmOne}{% -- ({\rad*cos(\start + 360*\t*#3/\N)}, {\shift + \rad*sin(\start + 360*\t*#3/\N)})% } -- cycle; }% } % Regular star polygon: operator size \newcommand\ou@tma@regularstarop[3]{% \tikz[x=1ex, y=1ex, baseline=0pt]{% \pgfmathtruncatemacro{\N}{#2}% \pgfmathtruncatemacro{\NmOne}{#2-1}% \pgfmathsetmacro{\start}{-90 + 180/\N}% \pgfmathsetmacro{\rad}{0.5/cos(180/\N) * \ou@tma@regularpolygonopscale}% \pgfmathsetmacro{\shift}{0.5 * \ou@tma@regularpolygonopscale}% \draw[line width=0.12ex,#1] ({\rad*cos(\start)},{\shift + \rad*sin(\start)}) \foreach \t in {1,...,\NmOne}{% -- ({\rad*cos(\start + 360*\t*#3/\N)}, {\shift + \rad*sin(\start + 360*\t*#3/\N)})% } -- cycle; }% } \ExplSyntaxOn % ----------------------------------------- % expl3 wrappers % ----------------------------------------- \cs_new_protected:Npn \@@_mregularpolygon:nn #1#2 { \mathord{ \ou@tma@regularpolygon{#1}{#2} } } \cs_new_protected:Npn \@@_mregularpolygon_op:nn #1#2 { \mathbin{ \ou@tma@regularpolygonop{#1}{#2} } } \cs_new_protected:Npn \@@_mregularstar:nnn #1#2#3 { \mathord{ \ou@tma@regularstar{#1}{#2}{#3} } } \cs_new_protected:Npn \@@_mregularstar_op:nnn #1#2#3 { \mathbin{ \ou@tma@regularstarop{#1}{#2}{#3} } } % ----------------------------------------- % User commands % ----------------------------------------- \NewDocumentCommand{\mregularpolygon}{O{} m} { \@@_mregularpolygon:nn {#1} {#2} } \NewDocumentCommand{\mregularpolygonfill}{O{} m} { \@@_mregularpolygon:nn { fill,#1 } {#2} } \NewDocumentCommand{\mregularpolygonop}{O{} m} { \@@_mregularpolygon_op:nn {#1} {#2} } \NewDocumentCommand{\mregularpolygonfillop}{O{} m} { \@@_mregularpolygon_op:nn { fill,#1 } {#2} } \NewDocumentCommand{\mregularstar}{O{} m m} { \@@_mregularstar:nnn {#1} {#2} {#3} } \NewDocumentCommand{\mregularstarfill}{O{} m m} { \@@_mregularstar:nnn { fill,#1 } {#2} {#3} } \NewDocumentCommand{\mregularstarop}{O{} m m} { \@@_mregularstar_op:nnn {#1} {#2} {#3} } \NewDocumentCommand{\mregularstarfillop}{O{} m m} { \@@_mregularstar_op:nnn { fill,#1 } {#2} {#3} } % Convenience aliases \NewDocumentCommand{\moctagon}{} { \mregularpolygon{8} } \NewDocumentCommand{\moctagonfill}{} { \mregularpolygonfill{8} } \NewDocumentCommand{\moctagonop}{} { \mregularpolygonop{8} } \NewDocumentCommand{\moctagonfillop}{}{ \mregularpolygonfillop{8} } \NewDocumentCommand{\mpentagram}{} { \mregularstar{5}{2} } \NewDocumentCommand{\mpentagramfill}{} { \mregularstarfill{5}{2} } \NewDocumentCommand{\mpentagramop}{} { \mregularstarop{5}{2} } \NewDocumentCommand{\mpentagramfillop}{}{ \mregularstarfillop{5}{2} } % \end{macrocode} % % % \subsection{General utilitarian shorcuts} % % \changesSUP{v0.15}{2025-12-29}{Added shortcut for module handbook references.} % % \begin{macrocode} \cs_new_protected:Npn \@@_hb:nn #1 #2 { % Base text \textsc{hb}\, % Optional page/range \IfNoValueF{#1} { p#1 } % Optional section/range \IfNoValueF{#2} { \,\S#2 } } \NewDocumentCommand{\HB}{ o o } { \@@_hb:nn { #1 } { #2 } } % \end{macrocode} % % \changesSUP{v0.15}{2025-12-29}{Added \cs{AugMatrix} command for augmented matrix typesetting.} % % \begin{macrocode} % Base internal function \cs_new_protected:Npn \@@_augmatrix:nnnnn #1 #2 #3 #4 #5 { \begin{array}{@{} c @{\;} c @{\;} c @{}} % Left material \IfBooleanTF {#1} { % starred: raw \tl_if_blank:nTF {#4} { } {#4} } { % unstarred: row-aligned \tl_if_blank:nTF {#4} { } { \begin{array}{c} #4 \end{array} } } & % The augmented matrix itself \begin{pmatrix} \begin{array}{#2} #3 \end{array} \end{pmatrix} & % Right material \IfBooleanTF {#1} { % starred: raw \tl_if_blank:nTF {#5} { } {#5} } { % unstarred: row-aligned \tl_if_blank:nTF {#5} { } { \begin{array}{l} #5 \end{array} } } \end{array} } % Normal version: row-aligned side material % \AugMatrix[]{}[][] % is the array preamble, e.g. rrrr|r % is the rows, using & and \\ as usual % (optional) is a column aligned with rows, e.g. r_1\\r_2\\... % (optional) is a column aligned with rows, e.g. \text{...}\\... % \AugMatrix(*)[]{}[][] % Unstarred: left/right are row-aligned arrays (c and l). % Starred: left/right are inserted raw (you provide any structure you like). \NewDocumentCommand{\AugMatrix}{ s O{c|c} m O{} O{} } { \@@_augmatrix:nnnnn {#1} {#2} {#3} {#4} {#5} } \ExplSyntaxOff % \end{macrocode} % % \subsection{Extra macros} %\changesSUP{v0.12}{2025-10-28}{Added shortcuts for plus and minus flags used in sign tables.} %\changesSUP{v0.12}{2025-10-28}{Added shortcut \cs{ld} for \cs{lambda}.} % \begin{macrocode} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% Extra macros % %%%%%%%%%%%%%%%%%%%%%%%%%%% \NewDocumentCommand{\pflag}{}{\ensuremath{[+]}} \NewDocumentCommand{\nflag}{}{\ensuremath{[-]}} \NewDocumentCommand{\ld}{}{\ensuremath{\lambda}} % %%%%%%%%%%%%%%%%%%%%%%%%%%% %% End of Package ou-tma-sup % %%%%%%%%%%%%%%%%%%%%%%%%%%% % \end{macrocode} % \iffalse % % \fi % % \setcounter{CodelineNo}{0} % \section{Implementation of \textsf{doc-changes}} % % This is a `bonus' file developed for looking after multiple change log files within the same package. Use at your own risk. % % \iffalse %<*doc-changes.sty> % \fi % From this point, where you see the double ``at'' symbol, you should read it as though it is `dchg'.\\ %<@@=dchg> % \begin{macrocode} %% doc-changes.sty %% Copyright 2025-2026 G. I. Riley % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3c % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3c or later is part of all distributions of LaTeX % version 2005-12-01 or later. % % This work has the LPPL maintenance status `maintained.' % % The Current Maintainer of this work is Geoff Riley. % %% This package may be freely used, especially by, but not limited to, %% students, lecturers and staff of the Open University. No acknowledgement %% is _required_ for using this package within the production of a _Tutor %% Marked Assessment._ % \end{macrocode} % % \begin{macrocode} \RequirePackage{expl3} \RequirePackage{doc} \SetupDoc{reportchangedates} \ExplSyntaxOn %% Store State \tl_new:N \g__@@_target_tl \seq_new:N \g__@@_stack_seq \prop_new:N \g__@@_stream_prop \bool_new:N \g__@@_setup_bool %% Remember original \glossary and install dispatcher (once) \cs_new_protected:Npn \@@_setup: { \bool_if:NF \g__@@_setup_bool { \cs_set_eq:NN \@@_glossary_orig: \glossary \cs_set_protected:Npn \glossary ##1 { \@@_glossary:n {##1} } \bool_gset_true:N \g__@@_setup_bool } } \cs_new_eq:NN \@@_glossary_orig: \scan_stop: %% Ensure a stream exists & is open: name -> iow csname \cs_new_protected:Npn \@@_stream_ensure_open:n #1 { \prop_if_in:NnF \g__@@_stream_prop {#1} { \iow_new:c { g__@@_iow_#1 } \exp_args:Nc \iow_open:Nn { g__@@_iow_#1 } { \jobname-#1.glo } \prop_put:Nnx \g__@@_stream_prop {#1} { g__@@_iow_#1 } } } %% Current target (no stack) \cs_new_protected:Npn \@@_set_target:n #1 { \@@_setup: \@@_stream_ensure_open:n {#1} \tl_gset:Nn \g__@@_target_tl {#1} } \cs_new_protected:Npn \@@_clear_target: { \tl_gclear:N \g__@@_target_tl } %% Push / Pop targets \cs_new_protected:Npn \@@_push_target:n #1 { \seq_gpush:NV \g__@@_stack_seq \g__@@_target_tl \@@_set_target:n {#1} } \cs_new_protected:Npn \@@_pop_target: { \seq_gpop:NN \g__@@_stack_seq \l_tmpa_tl \tl_if_blank:VTF \l_tmpa_tl { \@@_clear_target: } { \tl_gset:NV \g__@@_target_tl \l_tmpa_tl } } %% Declare (open) a list of streams now \cs_new_protected:Npn \@@_declare_streams:n #1 { \clist_map_inline:nn {#1} { \@@_stream_ensure_open:n {##1} } } %% Dispatcher replacing \glossary \cs_new_protected:Npn \@@_glossary:n #1 { \tl_if_blank:VTF \g__@@_target_tl { % No active target -> pass through to original doc \glossary \@@_glossary_orig:{#1} } { % Lookup iow for current target \prop_get:NVN \g__@@_stream_prop \g__@@_target_tl \l_tmpa_tl % Freeze page number now \tl_set:Nx \l_tmpb_tl { \thepage } % Mirror doc.sty: \protected@write{}{\string\glossaryentry{#1}{}} \exp_args:Nc \protected@write { \l_tmpa_tl } {} {% \string\glossaryentry{#1}{\l_tmpb_tl}% }% } } %% Close all streams at end of document \cs_new_protected:Npn \@@_close_all: { \prop_map_inline:Nn \g__@@_stream_prop { \exp_args:Nc \iow_close:N {##2} } } \AtEndDocument{ \@@_close_all: } % \end{macrocode} % % \subsection{Single-column printing support for theglossary} % % \begin{macrocode} \int_new:N \g__@@_sc_depth_int \cs_new_eq:NN \@@_orig_theglossary_begin: \scan_stop: \cs_new_eq:NN \@@_orig_theglossary_end: \scan_stop: \cs_new_protected:Npn \@@_singlecolumn_begin: { \int_compare:nNnTF { \g__@@_sc_depth_int } = { 0 } { % First activation: capture originals \cs_if_exist:NT \theglossary { \cs_set_eq:NN \@@_orig_theglossary_begin: \theglossary } \cs_if_exist:NT \endtheglossary{ \cs_set_eq:NN \@@_orig_theglossary_end: \endtheglossary } % Install single-column 'theglossary' \cs_set_protected:Npn \theglossary { % Minimal single-column list layout compatible with gglo.ist entries \par\bigskip \begingroup \parindent\z@ \parskip\z@ \relax % Basic index-style paragraph items: \providecommand\indexspace{\par \vskip 10pt plus 2pt minus 2pt\relax} \providecommand\@idxitem{\par\hangindent 40\p@} \providecommand\subitem{\@idxitem\hspace*{20\p@}} \providecommand\subsubitem{\@idxitem\hspace*{30\p@}} \let\item\@idxitem } \cs_set_protected:Npn \endtheglossary { \par \endgroup } } { } % nested activation: keep our replacement \int_gincr:N \g__@@_sc_depth_int } \cs_new_protected:Npn \@@_singlecolumn_end: { \int_gdecr:N \g__@@_sc_depth_int \int_compare:nNnT { \g__@@_sc_depth_int } = { 0 } { % Restore originals when last guard unwinds \cs_if_eq:NNF \@@_orig_theglossary_begin: \scan_stop: { \cs_set_eq:NN \theglossary \@@_orig_theglossary_begin: } \cs_if_eq:NNF \@@_orig_theglossary_end: \scan_stop: { \cs_set_eq:NN \endtheglossary \@@_orig_theglossary_end: } } } % \end{macrocode} % % \changesCHG{0.3}{2025-11-13}{Documenting Public API} % \subsection{Public API (document commands)} % % \begin{description} % \ItemDescribeMacro[c=changes]{\DocChangeDeclareStreams}\marg{change sets} Comman separated list of change sets required. % \ItemDescribeMacro[c=changes]{\DocChangeSet}\marg{change set} Set the active change set. % \ItemDescribeMacro[c=changes]{\DocChangeClear} Save the current change set. % \ItemDescribeMacro[c=changes]{\DocChangePush}\marg{change set} Switch to the indicated change set, but remember which was active before. % \ItemDescribeMacro[c=changes]{\DocChangePop} Restore the previously active change set. % \ItemDescribeMacro[c=changes]{\DocChangeSingleColumnOn} Set single column glossary printing. % \ItemDescribeMacro[c=changes]{\DocChangeSingleColumnOff} Set double column glossary printing. % \ItemDescribeMacro[c=changes]{\DocChangePrint}\oarg{title}\marg{change set} Print the change set as a glossary using the provided title. % \end{description} % % \begin{macrocode} \NewDocumentCommand \DocChangeDeclareStreams { m } { \@@_declare_streams:n {#1} } \NewDocumentCommand \DocChangeSet { m } { \@@_set_target:n {#1} } \NewDocumentCommand \DocChangeClear { } { \@@_clear_target: } \NewDocumentCommand \DocChangePush { m } { \@@_push_target:n {#1} } \NewDocumentCommand \DocChangePop { } { \@@_pop_target: } %% Convenience: globally enable/disable single-column glossary layout \NewDocumentCommand \DocChangeSingleColumnOn { } { \@@_singlecolumn_begin: } \NewDocumentCommand \DocChangeSingleColumnOff { } { \@@_singlecolumn_end: } %% Print helper (single-column during print) \NewDocumentCommand \DocChangePrint { O{} m } { \par\bigskip \tl_if_blank:nF {#1} { \section*{#1} } \@@_singlecolumn_begin: \InputIfFileExists{ \jobname-#2.gls }{}{ \emph{No~changes~recorded.} } \@@_singlecolumn_end: } \ExplSyntaxOff % \end{macrocode} % \iffalse % % \fi % % \Finale % % \endinput