diff options
author | Norbert Preining <norbert@preining.info> | 2022-01-28 03:00:39 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-01-28 03:00:39 +0000 |
commit | aef84c3078da1ba1bad9754ea0555ac9bc1c0aac (patch) | |
tree | 504157331610369440808936658f31b027731b5f /macros/latex/contrib/mandi/mandistudent.dtx | |
parent | b5deca5ab245af14ca010a3e61225189e9c860f9 (diff) |
CTAN sync 202201280300
Diffstat (limited to 'macros/latex/contrib/mandi/mandistudent.dtx')
-rw-r--r-- | macros/latex/contrib/mandi/mandistudent.dtx | 987 |
1 files changed, 634 insertions, 353 deletions
diff --git a/macros/latex/contrib/mandi/mandistudent.dtx b/macros/latex/contrib/mandi/mandistudent.dtx index bbeb5d974a..d27bc93ac5 100644 --- a/macros/latex/contrib/mandi/mandistudent.dtx +++ b/macros/latex/contrib/mandi/mandistudent.dtx @@ -1,7 +1,7 @@ % \iffalse meta-comment % !TEX program = lualatexmk % -% Copyright (C) 2021 by Paul J. Heafner <heafnerj@gmail.com> +% Copyright (C) 2021,2022 by Paul J. Heafner <heafnerj@gmail.com> % --------------------------------------------------------------------------- % This work may be distributed and/or modified under the conditions of the % LaTeX Project Public License, either version 1.3 of this license or (at @@ -111,7 +111,7 @@ while t < 10: %</driver> % \fi % -% \CheckSum{706} +% \CheckSum{745} % % \CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -147,7 +147,7 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{dispListing*}{sidebyside=false,listing only} +\begin{dispListing*}{sidebyside = false,listing only} \usepackage{mandistudent} \end{dispListing*} %\iffalse @@ -160,7 +160,7 @@ while t < 10: \begin{docCommand}{mandistudentversion}{} Typesets the current version and build date. \end{docCommand} -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} The version is \mandistudentversion\ and is a stable build. \end{dispExample*} %\iffalse @@ -173,6 +173,7 @@ while t < 10: %<*example> %\fi \begin{docCommands}[% + doc updated = 2021-09-18,% doc parameter = \marg{symbol}\oarg{labels},% ]% {% @@ -192,16 +193,21 @@ while t < 10: |\symup{...}| for proper typesetting. The starred variant gives arrow notation whereas without the star you get boldface notation. Subscript and superscript labels can be arbitrarily mixed, and order doesn't matter. - This command redefines the default \LaTeX\ |\vec| command. + This command redefines the default \LaTeXe |\vec| command. \end{docCommands} -\begin{dispExample*}{lefthand ratio=0.6} - \( \vec{p} \) \\ - \( \vec{p}_{2} \) \\ - \( \vec{p}^{\symup{ball}} \) \\ - \( \vec{p}_{\symup{final}} \) \\ - \( \vec{p}^{\symup{ball}}_{\symup{final}} \) \\ - \( \vec{p}^{\symup{final}}_{\symup{ball}} \) \\ - \( \vec*{p} \) +\begin{dispExample*}{lefthand ratio = 0.6} + \( \vec{p} \) \\ + \( \vec{p}_{2} \) \\ + \( \vec{p}^{\symup{ball}} \) \\ + \( \vec{p}_{\symup{final}} \) \\ + \( \vec{p}^{\symup{ball}}_{\symup{final}} \) \\ + \( \vec{p}^{\symup{final}}_{\symup{ball}} \) \\ + \( \vec*{p} \) \\ + \( \vec*{p}_{2} \) \\ + \( \vec*{p}^{\symup{ball}} \) \\ + \( \vec*{p}_{\symup{final}} \) \\ + \( \vec*{p}^{\symup{ball}}_{\symup{final}} \) \\ + \( \vec*{p}^{\symup{final}}_{\symup{ball}} \) \end{dispExample*} %\iffalse %</example> @@ -211,6 +217,7 @@ while t < 10: %<*example> %\fi \begin{docCommands}[% + doc updated = 2021-09-18,% doc parameter = \marg{symbol}\oarg{labels},% ]% {% @@ -226,14 +233,19 @@ while t < 10: Powerful and intelligent command for typesetting the direction of a vector. The options are the same as those for \refCom{vec}. \end{docCommands} -\begin{dispExample*}{lefthand ratio=0.65} - \( \dirvec{p} \) \\ - \( \dirvec{p}_{2} \) \\ - \( \dirvec{p}^{\symup{ball}} \) \\ - \( \dirvec{p}_{\symup{final}} \) \\ - \( \dirvec{p}^{\symup{ball}}_{\symup{final}} \) \\ - \( \dirvec{p}^{\symup{final}}_{\symup{ball}} \) \\ - \( \dirvec*{p} \) +\begin{dispExample*}{lefthand ratio = 0.65} + \( \dirvec{p} \) \\ + \( \dirvec{p}_{2} \) \\ + \( \dirvec{p}^{\symup{ball}} \) \\ + \( \dirvec{p}_{\symup{final}} \) \\ + \( \dirvec{p}^{\symup{ball}}_{\symup{final}} \) \\ + \( \dirvec{p}^{\symup{final}}_{\symup{ball}} \) \\ + \( \dirvec*{p} \) \\ + \( \dirvec*{p}_{2} \) \\ + \( \dirvec*{p}^{\symup{ball}} \) \\ + \( \dirvec*{p}_{\symup{final}} \) \\ + \( \dirvec*{p}^{\symup{ball}}_{\symup{final}} \) \\ + \( \dirvec*{p}^{\symup{final}}_{\symup{ball}} \) \end{dispExample*} %\iffalse %</example> @@ -445,7 +457,7 @@ while t < 10: Commands for geometric relationships, mainly intended for subscripts. \end{docCommands} -\begin{dispExample*}{lefthand ratio=0.6} +\begin{dispExample*}{lefthand ratio = 0.6} \( \vec{F}_{\parallelto} + \vec{F}_{\perpendicularto} \) \end{dispExample*} %\iffalse @@ -480,16 +492,16 @@ while t < 10: begin on a new page. See the examples for how to handle single and multiple part problems. \end{docEnvironments} -\begin{docCommand}[doc new = 2012-02-03]{problempart}{} +\begin{docCommand}[doc new = 2021-02-03]{problempart}{} Denotes a part of a problem within a \refEnv{parts} environment. \end{docCommand} -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} \begin{physicsproblem}{Problem 1} This is a physics problem with no parts. \end{physicsproblem} \end{dispExample*} -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} \begin{physicsproblem}{Problem 2} This is a physics problem with multiple parts. The list is vertical. @@ -500,7 +512,7 @@ while t < 10: \end{parts} \end{physicsproblem} \end{dispExample*} -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} \begin{physicsproblem*}{Problem 3} This is a physics problem with multiple parts. The list is in-line. @@ -555,7 +567,7 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{docCommand}[doc updated = 2012-02-26]{reason}{\marg{reason}} +\begin{docCommand}[doc updated = 2021-02-26]{reason}{\marg{reason}} Provides an annotation in a step-by-step solution. Keep reasons short and to the point. Wrap mathematical content in math mode. @@ -583,7 +595,7 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{dispListing*}{sidebyside=false,listing only} +\begin{dispListing*}{sidebyside = false,listing only} \begin{physicsproblem}{Combined Problem and Solution} This is an interesting physics problem. \begin{physicssolution} @@ -591,7 +603,7 @@ while t < 10: \end{physicssolution} \end{physicsproblem} \end{dispListing*} -\begin{dispListing*}{sidebyside=false,listing only} +\begin{dispListing*}{sidebyside = false,listing only} \begin{physicsproblem}{Combined Multipart Problem with Solutions} This is a physics problem with multiple parts. \begin{parts} @@ -617,14 +629,14 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{docCommand}[doc new=2021-02-06]{hilite}{% +\begin{docCommand}[doc new = 2021-02-06]{hilite}{% \oarg{color}\marg{target}\oarg{shape} }% Hilites the desired target, which can be an entire mathematical expression or a part thereof. The default color is magenta and the default shape is a rectangle. \end{docCommand} -\begin{dispListing*}{sidebyside=false,listing only} +\begin{dispListing*}{sidebyside = false,listing only} \begin{align*} (\Delta s)^2 &= -(\Delta t)^2 + (\Delta x)^2 + (\Delta y)^2 + (\Delta z)^2 \\ @@ -656,7 +668,7 @@ while t < 10: (\Delta y)^{\hilite[blue!50]{2}[circle]} + (\Delta z)^{\hilite[violet!45]{2}[circle]} \end{align*} -\begin{dispListing*}{sidebyside=false,listing only} +\begin{dispListing*}{sidebyside = false,listing only} \begin{align*} \Delta\vec{p} &= \vec{F}_{\sumup{net}}\Delta t \\ \hilite[orange]{\Delta\vec{p}}[circle] &= \vec{F}_{\symup{net}}\Delta t \\ @@ -688,14 +700,14 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{docCommand}[doc updated = 2021-02-26]{image}{% +\begin{docCommand}[doc updated = 2021-09-18]{image}{% \oarg{options}\marg{caption}\marg{label}\marg{image} }% Simplified interface for importing an image. The images are treated as floats, so they may not appear at the most logically intuitive place. \end{docCommand} -\begin{dispListing*}{sidebyside=false,listing only,verbatim ignore percent} +\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent} \image[scale=0.20]{example-image-1x1} {Image shown 20 percent actual size.}{reffig1} \end{dispListing*} @@ -705,13 +717,13 @@ while t < 10: Figure \ref{reffig1} is nice. It's captioned \nameref{reffig1} and is on page \pageref{reffig1}. \end{dispExample*} -\begin{dispListing*}{sidebyside=false,listing only,verbatim ignore percent} +\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent} \image[scale=0.20,angle=45]{example-image-1x1} {Image shown 20 percent actual size and rotated.}{reffig1} \end{dispListing*} \image[scale=0.20,angle=45]{example-image-1x1} {Image shown 20 percent actual size and rotated.}{reffig2} -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} Figure \ref{reffig2} is nice. It's captioned \nameref{reffig2} and is on page \pageref{reffig2}. \end{dispExample*} @@ -729,7 +741,7 @@ while t < 10: %<*example> %\fi \begin{docCommands}[% - doc parameter = \oarg{delimiter}\marg{\ensuremath{c_1,\dots,c_n}},% + doc parameter = \oarg{delimiter}\marg{\( c_1,\dots,c_n \)},% ]% {% {% @@ -867,11 +879,14 @@ while t < 10: %</example> %\fi % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \cs{diff} renamed to +% \refCom{df} for compatibility with the \pkg{numerica} package} %\iffalse %<*example> %\fi -\begin{docCommand}[doc new=2021-04-06]{diff}{}% - Intelligent differential (exterior derivative) +\begin{docCommand}[doc updated = 2022-01-27]{df}{}% + Intelligent differential and exterior derivative operator. \end{docCommand} \begin{dispExample} @@ -879,19 +894,25 @@ while t < 10: \int x\,dx \] \[ - \int x\,\diff{x} + \int x\,\df{x} \] \[ - \int x\,\diff*{x} + \int x\,\df*{x} \] \end{dispExample} %\iffalse %</example> %\fi % -% \subsection{\GlowScript\ and \VPython\ Program Listings} +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} All instances of +% \texttt{GlowScript} have been changed to \texttt{Web VPython}} +% \subsection{\WebVPython\ and \VPython\ Program Listings} % -% \href{https://\gsurl}{\GlowScript}\footnote{\href{https://\gsurl}{https://\gsurl}} +% \href{https://\gsurl}{\WebVPython} +% \footnote{On November 9, 2021 \texttt{GlowScript} was renamed to +% \WebVPython. The website was changed to +% \href{https://\gsurl}{https://\gsurl}.} % and % \href{https://\vpurl}{VPython}\footnote{\href{https://\vpurl}{https://\vpurl}} % are programming environments (both use \href{https://www.python.org}{Python}) @@ -899,25 +920,39 @@ while t < 10: % for modeling physical systems. \mandi\ makes including code listings % very simple for students. % -% \subsection{The \texttt{\small glowscriptblock} Environment} +% \subsection{The \texttt{\small webvpythonblock} Environment} % %\iffalse %<*example> %\fi -\begin{docEnvironment}[% - doc updated = 2021-02-26,doclang/environment content=GlowScript code% - ]% - {glowscriptblock}{\oarg{options}(\meta{link})\marg{caption}} +\begin{docEnvironments}[% + doc parameter = {\oarg{options}(\meta{link})\marg{caption}},% + doclang/environment content=WebVPython code,% + ]% + {% + {% + doc updated = 2022-01-27,% + doc name = webvpythonblock,% + doc description = now includes a QR code,% + },% + {% + doc new = 2022-01-27,% + doc name = webvpythonblock*,% + doc description = use this variant to omit QR code,% + },% + }% Code placed here is nicely formatted and optionally linked to its source on - \href{https://\gsurl}{\GlowScriptorg}. Clicking anywhere in the code window - will open the link in the default browser. A caption is mandatory, and a - label is internally generated. The listing always begins on a new page. A - URL shortening utility is recommended to keep the URL from getting unruly. - For convenience, |https://| is automatically prepended to the URL and can - thus be omitted. The program must exist in a public, not private, folder. -\end{docEnvironment} -\begin{dispListing*}{sidebyside=false} -\begin{glowscriptblock}(tinyurl.com/y3lnqyn3){A \texttt{GlowScript} Program} + \href{https://\gsurl}{\WebVPythonorg}, which must be in a public (not private) + folder. Clicking anywhere in the code window will open the link in the default + browser. A caption is mandatory, and a label is internally generated. The + listing always begins on a new page. A URL shortening utility is recommended + to keep the URL from getting unruly. For convenience, |https://| is + automatically prepended to the URL and can thus be omitted. The |#| character + in a URL should not cause problems. The default URL is that of the \WebVPython\ + home page. +\end{docEnvironments} +\begin{dispListing*}{sidebyside = false} +\begin{webvpythonblock}(tinyurl.com/y3lnqyn3){A \texttt{Web VPython} Program With QR Code} GlowScript 3.0 vpython scene.width = 400 @@ -961,9 +996,9 @@ while t < 10: ball.pos = ball.pos + (pball / mball) * deltat spring.axis = ball.pos - ceiling.pos t = t + deltat -\end{glowscriptblock} +\end{webvpythonblock} \end{dispListing*} -\begin{glowscriptblock}(tinyurl.com/y3lnqyn3){A \texttt{GlowScript} Program} +\begin{webvpythonblock}(tinyurl.com/y3lnqyn3){A \texttt{Web VPython} Program With QR Code} GlowScript 3.0 vpython scene.width = 400 @@ -1007,18 +1042,128 @@ while t < 10: ball.pos = ball.pos + (pball / mball) * deltat spring.axis = ball.pos - ceiling.pos t = t + deltat -\end{glowscriptblock} +\end{webvpythonblock} +% %\iffalse %</example> %\fi % +% \newpage +% Here is how one would reference this program elsewhere. Notice the +% references are numbered sequentially within the document. +% %\iffalse %<*example> %\fi -\begin{dispExample*}{sidebyside=false} - \GlowScript\ program \ref{gs:1} is nice. +\begin{dispExample*}{sidebyside = false} + \WebVPython\ program \ref{gs:1} is nice. It's called \nameref{gs:1} and is on page \pageref{gs:1}. \end{dispExample*} +%\iffalse +%</example> +%\fi +% +% \newpage +% +%\iffalse +%<*example> +%\fi +\begin{dispListing*}{sidebyside = false} +\begin{webvpythonblock*}(tinyurl.com/y3lnqyn3){A \texttt{Web VPython} Program Without QR Code} +GlowScript 3.0 vpython + +scene.width = 400 +scene.height = 760 +# constants and data +g = 9.8 # m/s^2 +mball = 0.03 # kg +Lo = 0.26 # m +ks = 1.8 # N/m +deltat = 0.01 # s + +# objects (origin is at ceiling) +ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, + width=0.2) +ball = sphere(pos=vector(0,-0.3,0),radius=0.025, + color=color.orange) +spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, + color=color.cyan,thickness=0.003,coils=40, + radius=0.010) + +# initial values +pball = mball * vector(0,0,0) # kg m/s +Fgrav = mball * g * vector(0,-1,0) # N +t = 0 + +# improve the display +scene.autoscale = False # turn off automatic camera zoom +scene.center = vector(0,-Lo,0) # move camera down +scene.waitfor('click') # wait for a mouse click + +# initial calculation loop +# calculation loop +while t < 10: + rate(100) + # we need the stretch + s = mag(ball.pos) - Lo + # we need the spring force + Fspring = ks * s * -norm(spring.axis) + Fnet = Fgrav + Fspring + pball = pball + Fnet * deltat + ball.pos = ball.pos + (pball / mball) * deltat + spring.axis = ball.pos - ceiling.pos + t = t + deltat +\end{webvpythonblock*} +\end{dispListing*} +\begin{webvpythonblock*}(tinyurl.com/y3lnqyn3){A \texttt{Web VPython} Program Without QR Code} +GlowScript 3.0 vpython + +scene.width = 400 +scene.height = 760 +# constants and data +g = 9.8 # m/s^2 +mball = 0.03 # kg +Lo = 0.26 # m +ks = 1.8 # N/m +deltat = 0.01 # s + +# objects (origin is at ceiling) +ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, + width=0.2) +ball = sphere(pos=vector(0,-0.3,0),radius=0.025, + color=color.orange) +spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, + color=color.cyan,thickness=0.003,coils=40, + radius=0.010) + +# initial values +pball = mball * vector(0,0,0) # kg m/s +Fgrav = mball * g * vector(0,-1,0) # N +t = 0 + +# improve the display +scene.autoscale = False # turn off automatic camera zoom +scene.center = vector(0,-Lo,0) # move camera down +scene.waitfor('click') # wait for a mouse click + +# initial calculation loop +# calculation loop +while t < 10: + rate(100) + # we need the stretch + s = mag(ball.pos) - Lo + # we need the spring force + Fspring = ks * s * -norm(spring.axis) + Fnet = Fgrav + Fspring + pball = pball + Fnet * deltat + ball.pos = ball.pos + (pball / mball) * deltat + spring.axis = ball.pos - ceiling.pos + t = t + deltat +\end{webvpythonblock*} +\begin{dispExample*}{sidebyside = false} + \WebVPython\ program \ref{gs:2} is nice. + It's called \nameref{gs:2} and is on page \pageref{gs:2}. +\end{dispExample*} % %\iffalse %</example> @@ -1029,22 +1174,20 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{docCommand}[doc updated = 2021-02-26]{vpythonfile} - {\oarg{options}\marg{file}\marg{caption}} - Command to load and typeset a \VPython\ program. The file is read from +\begin{docCommand}[doc updated = 2022-01-27]{vpythonfile} + {\oarg{options}(\meta{link})\marg{file}\marg{caption}} + Command to load and typeset a \VPython\ program, read from local file \marg{file}. Clicking anywhere in the code window can optionally open a link, passed as an option, in the default browser. A caption is mandatory, and a label is internally generated. The listing always begins on a new page. A URL shortening utility is recommended to keep the URL from getting unruly. For convenience, |https://| is automatically prepended to the URL and can - thus be omitted. + thus be omitted. The default URL is that of the \VPython\ home page. \end{docCommand} -\begin{dispListing*}{sidebyside=false} -\vpythonfile[hyperurl interior = https://vpython.org]{vdemo.py} - {A \VPython\ Program} +\begin{dispListing*}{sidebyside = false} +\vpythonfile{vdemo.py}{A \VPython\ Program} \end{dispListing*} -\vpythonfile[hyperurl interior = https://vpython.org]{vdemo.py} - {A \VPython\ Program} +\vpythonfile{vdemo.py}{A \VPython\ Program} %\iffalse %</example> %\fi @@ -1052,7 +1195,7 @@ while t < 10: %\iffalse %<*example> %\fi -\begin{dispExample*}{sidebyside=false} +\begin{dispExample*}{sidebyside = false} \VPython\ program \ref{vp:1} is nice. It's called \nameref{vp:1} and is on page \pageref{vp:1}. \end{dispExample*} @@ -1061,7 +1204,7 @@ while t < 10: %</example> %\fi % -% \subsection{The \texttt{\small glowscriptinline} and +% \subsection{The \texttt{\small webvpythoninline} and % \texttt{\small vpythoninline} Commands} % %\iffalse @@ -1072,8 +1215,8 @@ while t < 10: ]% {% {% - doc name = glowscriptinline,% - doc parameter = \marg{GlowScript code},% + doc name = webvpythoninline,% + doc parameter = \marg{Web VPython code},% },% {% doc name = vpythoninline,% @@ -1083,8 +1226,8 @@ while t < 10: Typesets a small, in-line snippet of code. The snippet should be less than one line long. \end{docCommands} -\begin{dispExample*}{sidebyside=false} - \GlowScript\ programs begin with \glowscriptinline{GlowScript 3.0 VPython} +\begin{dispExample*}{sidebyside = false} + \WebVPython\ programs begin with \webvpythoninline{GlowScript 3.0 VPython} and \VPython\ programs begin with \vpythoninline{from vpython import *}. \end{dispExample*} %\iffalse @@ -1104,12 +1247,16 @@ while t < 10: % |\makeatother|. This simplifies defining internal commands, with |@| % in the name, that are not for the user to know about. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} Version number works} +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} Code formatted for better readability} % \begin{macrocode} -\def\mandistudent@version{\mandi@version} -\def\mandistudent@date{\mandi@date} +\def\mandistudent@version{3.1.0} +\def\mandistudent@date{2022-01-27} \NeedsTeXFormat{LaTeX2e}[2020-02-02] -\DeclareRelease{v3.0.0}{2021-08-22}{mandistudent.sty} -\DeclareCurrentRelease{v\mandi@version}{\mandi@date} +\DeclareRelease{v3.1.0}{2022-01-27}{mandistudent.sty} +\DeclareCurrentRelease{v\mandistudent@version}{\mandistudent@date} \ProvidesPackage{mandistudent} [\mandistudent@date\space v\mandistudent@version\space Macros for introductory physics] % \end{macrocode} @@ -1133,11 +1280,22 @@ while t < 10: \RequirePackage{mandi} \RequirePackage{mathtools} % needed for paired delimiters; extends amsmath \RequirePackage{nicematrix} % needed for column and row vectors +\RequirePackage{qrcode} % needed for QR codes in webvpythonblock +\qrset{height=1.5cm} % set default size of QR code \RequirePackage[most]{tcolorbox} % needed for program listings \RequirePackage{tensor} % needed for index notation \RequirePackage{tikz} % needed for \hilite \usetikzlibrary{shapes,fit,tikzmark} % needed for \hilite \RequirePackage{unicode-math} % needed for Unicode support +% \end{macrocode} +% +% +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \pkg{xparse} is loaded for older formats} +% \begin{macrocode} +\IfFormatAtLeastTF {2020-10-01} % load xparse if necessary + {}% + {\RequirePackage{xparse}}% \RequirePackage{hyperref} % load last \RequireLuaTeX % require this engine % \end{macrocode} @@ -1146,13 +1304,14 @@ while t < 10: % The \href{https://www.ctan.org/pkg/unicode-math}{\pkg{unicode-math}} package % loads the \href{https://www.ctan.org/pkg/fontspec}{\pkg{fontspec}} and % \href{https://www.ctan.org/pkg/xparse}{\pkg{xparse}} -% packages. Note that \pkg{xparse} is now part of the \LaTeX\ kernel. +% packages. Note that \pkg{xparse} is now part of the \LaTeXe\ kernel. % Because \pkg{unicode-math} is required, all documents using \mandi\ must % be compiled with an engine that supports Unicode. We recommend \lualatex. % % \begin{macrocode} \unimathsetup{math-style=ISO} \unimathsetup{warnings-off={mathtools-colon,mathtools-overbracket}} +% \end{macrocode} % % Use normal math letters from Latin Modern Math for familiarity with % textbooks. @@ -1162,19 +1321,20 @@ while t < 10: {Latin Modern Math} % default math font; better J % \end{macrocode} % -% Borrow from GeX Gyre DejaVu Math for vectors and tensors to get single-storey g. +% Borrow from TeX Gyre DejaVu Math for vectors and tensors to get single-storey g. % % \begin{macrocode} \setmathfont[Scale=MatchLowercase,range={sfit/{latin},bfsfit/{latin}}] {TeX Gyre DejaVu Math} % single-storey lowercase g % \end{macrocode} % -% Borrow from GeX Gyre DejaVu Math to get single-storey g. +% Borrow from TeX Gyre DejaVu Math to get single-storey g. % % \begin{macrocode} \setmathfont[Scale=MatchLowercase,range={sfup/{latin},bfsfup/{latin}}] {TeX Gyre DejaVu Math} % single-storey lowercase g % \end{macrocode} +% % Borrow |mathscr| and |mathbfscr| from XITS Math.\newline % See \url{https://tex.stackexchange.com/a/120073/218142}. % @@ -1282,7 +1442,7 @@ while t < 10: % \end{macrocode} % % Tweak the \href{https://www.ctan.org/pkg/esvect}{\pkg{esvect}} package -% fonts to get the correct font size. Code provided by |@egreg|.\newline +% fonts to get the correct font size.\newline % See \url{https://tex.stackexchange.com/a/566676}. % % \begin{macrocode} @@ -1318,23 +1478,32 @@ while t < 10: % See \url{https://tex.stackexchange.com/q/554706/218142}.\newline % See also \url{https://tex.stackexchange.com/a/531037/218142}. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \refCom{vec}% +% no longer adds \cs{scriptspace} when no sub/superscript is given} % \begin{macrocode} -\RenewDocumentCommand{\vec}{ s m e{_^} }{% +\RenewDocumentCommand{\vec}{ s m e{_^} }% + {% % Note the \, used to make superscript look better. - \IfBooleanTF {#1} - {\vv{#2}% % * gives an arrow - % Use \sp{} primitive for superscript. - % Adjust superscript for the arrow. - \sp{\IfValueT{#4}{\,#4}\vphantom{\smash[t]{\big|}}} - }% - {\symbfit{#2} % no * gives us bold - % Use \sp{} primitive for superscript. - % No superscript adjustment needed. - \sp{\IfValueT{#4}{#4}\vphantom{\smash[t]{\big|}}} - }% - % Use \sb{} primitive for subscript. - \sb{\IfValueT{#3}{#3}\vphantom{\smash[b]{|}}} -}% + \IfBooleanTF{#1} + {% + \vv{#2}% % * gives an arrow + % Use \sp{} primitive for superscript. + % Adjust superscript for the arrow. + \IfValueT{#4}% + {\sp{\,#4\vphantom{\smash[t]{\big|}}}} + }% + {% + \symbfit{#2} % no * gives us bold + % Use \sp{} primitive for superscript. + % No superscript adjustment needed. + \IfValueT{#4}% + {\sp{#4\vphantom{\smash[t]{\big|}}}} + }% + % Use \sb{} primitive for subscript. + \IfValueT{#3}% + {\sb{#3\vphantom{\smash[b]{|}}}} + }% % \end{macrocode} % % A command for the direction of a vector. @@ -1343,53 +1512,68 @@ while t < 10: % package.\newline % See \url{https://tex.stackexchange.com/a/391204/218142}. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \refCom{dirvec}% +% no longer adds \cs{scriptspace} when no sub/superscript is given} % \begin{macrocode} -\NewDocumentCommand{\dirvec}{ s m e{_^} }{% - \widehat{\makebox*{\(w\)}{\ensuremath{% - \IfBooleanTF {#1} - {% - #2 - }% - {% - \symbfit{#2} - }% - }% +\NewDocumentCommand{\dirvec}{ s m e{_^} }% + {% + \widehat% + {% + \makebox*{\(w\)}% + {% + \ensuremath{% + \IfBooleanTF {#1}% + {% + #2% + }% + {% + \symbfit{#2}% + }% + }% + }% }% - }% - \sb{\IfValueT{#3}{#3}\vphantom{\smash[b]{|}}} - \sp{\IfValueT{#4}{\,#4}\vphantom{\smash[t]{\big|}}} -}% + \IfValueT{#3}% + {\sb{#3\vphantom{\smash[b]{|}}}}% + \IfValueT{#4}% + {\sp{\,#4\vphantom{\smash[t]{\big|}}}}% + }% % \end{macrocode} % % The zero vector. % % \begin{macrocode} -\NewDocumentCommand{\zerovec}{ s }{% - \IfBooleanTF {#1} - {\vv{0}}% - {\symbfup{0}}% -}% +\NewDocumentCommand{\zerovec}{ s }% + {% + \IfBooleanTF {#1} + {\vv{0}}% + {\symbfup{0}}% + }% % \end{macrocode} % -% Notation for column and row vectors. -% Orginal code provided by |@egreg|.\newline +% Notation for column and row vectors.\newline % See \url{https://tex.stackexchange.com/a/39054/218142}. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \LaTeX3 code now conforms to formatting standards} % \begin{macrocode} \ExplSyntaxOn -\NewDocumentCommand{\colvec}{ O{,} m }{% - \vector_main:nnnn { p } { \\ } { #1 } { #2 } -}% -\NewDocumentCommand{\rowvec}{ O{,} m }{% - \vector_main:nnnn { p } { & } { #1 } { #2 } -}% -\seq_new:N \l__vector_arg_seq -\cs_new_protected:Npn \vector_main:nnnn #1 #2 #3 #4 {% - \seq_set_split:Nnn \l__vector_arg_seq { #3 } { #4 } - \begin{#1NiceMatrix}[r] - \seq_use:Nnnn \l__vector_arg_seq { #2 } { #2 } { #2 } - \end{#1NiceMatrix} -}% +\NewDocumentCommand{\colvec}{ O{,} m } + { + \__mandi_vectormain:nnnn { p } { \\ } { #1 } { #2 } + } +\NewDocumentCommand{\rowvec}{ O{,} m } + { + \__mandi_vectormain:nnnn { p } { & } { #1 } { #2 } + } +\seq_new:N \l__mandi_vectorarg_seq +\cs_new_protected:Npn \__mandi_vectormain:nnnn #1#2#3#4 + { + \seq_set_split:Nnn \l__mandi_vectorarg_seq { #3 } { #4 } + \begin{#1NiceMatrix}[r] + \seq_use:Nnnn \l__mandi_vectorarg_seq { #2 } { #2 } { #2 } + \end{#1NiceMatrix} + } \ExplSyntaxOff % \end{macrocode} % @@ -1416,7 +1600,7 @@ while t < 10: % Some semantic aliases. Because of the way \refCom{vec} and % \refCom{dirvec} are defined, I reluctantly decided not to % implement a |\magvec| command. It would require accounting -% for too mamy options. So \refCom{magnitude} is the new +% for too many options. So \refCom{magnitude} is the new % solution. % % \begin{macrocode} @@ -1429,8 +1613,10 @@ while t < 10: % mainly to be subscripts. % % \begin{macrocode} -\NewDocumentCommand{\parallelto}{} - {\mkern3mu\vphantom{\perp}\vrule depth 0pt\mkern2mu\vrule depth 0pt\mkern3mu} +\NewDocumentCommand{\parallelto}{}% + {% + \mkern3mu\vphantom{\perp}\vrule depth 0pt\mkern2mu\vrule depth 0pt\mkern3mu% + }% \NewDocumentCommand{\perpendicularto}{}{\perp} % \end{macrocode} % @@ -1438,17 +1624,21 @@ while t < 10: % in-line lists. % % \begin{macrocode} -\NewDocumentEnvironment{physicsproblem}{ m }{% - \newpage% - \section*{#1}% - \newlist{parts}{enumerate}{2}% - \setlist[parts]{label=\bfseries(\alph*)}}% +\NewDocumentEnvironment{physicsproblem}{ m }% + {% + \newpage% + \section*{#1}% + \newlist{parts}{enumerate}{2}% + \setlist[parts]{label=\bfseries(\alph*)}% + }% {}% -\NewDocumentEnvironment{physicsproblem*}{ m }{% - \newpage% - \section*{#1}% - \newlist{parts}{enumerate*}{2}% - \setlist[parts]{label=\bfseries(\alph*)}}% +\NewDocumentEnvironment{physicsproblem*}{ m }% + {% + \newpage% + \section*{#1}% + \newlist{parts}{enumerate*}{2}% + \setlist[parts]{label=\bfseries(\alph*)}% + }% {}% \NewDocumentCommand{\problempart}{}{\item}% % \end{macrocode} @@ -1456,29 +1646,34 @@ while t < 10: % An environment for problem solutions. % % \begin{macrocode} -\NewDocumentEnvironment{physicssolution}{ +b }{% - % Make equation numbering consecutive through the document. - \begin{align} - #1 - \end{align} -}{}% -\NewDocumentEnvironment{physicssolution*}{ +b }{% - % Make equation numbering consecutive through the document. - \begin{align*} - #1 - \end{align*} -}{}% +\NewDocumentEnvironment{physicssolution}{ +b }% + {% + % Make equation numbering consecutive through the document. + \begin{align} + #1 + \end{align} + }% + {}% +\NewDocumentEnvironment{physicssolution*}{ +b }% + {% + % Make equation numbering consecutive through the document. + \begin{align*} + #1 + \end{align*} + }% + {}% % \end{macrocode} % % See \url{https://tex.stackexchange.com/q/570223/218142}. % % \begin{macrocode} -\NewDocumentCommand{\reason}{ O{4cm} m } - {&&\begin{minipage}{#1}\raggedright\small #2\end{minipage}} +\NewDocumentCommand{\reason}{ O{4cm} m }% + {% + &&\begin{minipage}{#1}\raggedright\small #2\end{minipage}% + }% % \end{macrocode} % % Command for highlighting parts of, or entire, mathematical expressions.\newline -% Original code by anonymous user |@abcdefg|, modified by me.\newline % See \url{https://texample.net/tikz/examples/beamer-arrows/}.\newline % See also \url{https://tex.stackexchange.com/a/406084/218142}.\newline % See also \url{https://tex.stackexchange.com/a/570858/218142}.\newline @@ -1489,34 +1684,40 @@ while t < 10: % % \begin{macrocode} \newcounter{tikzhighlightnode} -\NewDocumentCommand{\hilite}{ O{magenta!60} m O{rectangle} }{% - \stepcounter{tikzhighlightnode}% - \tikzmarknode{highlighted-node-\number\value{tikzhighlightnode}}{#2}% - \edef\temp{% - \noexpand\AddToShipoutPictureBG{% - \noexpand\begin{tikzpicture}[overlay,remember picture]% - \noexpand\iftikzmarkoncurrentpage{highlighted-node-\number\value{tikzhighlightnode}}% - \noexpand\node[inner sep=1.0pt,fill=#1,#3,fit=(highlighted-node-\number\value{tikzhighlightnode})]{};% - \noexpand\fi - \noexpand\end{tikzpicture}% +\NewDocumentCommand{\hilite}{ O{magenta!60} m O{rectangle} }% + {% + \stepcounter{tikzhighlightnode}% + \tikzmarknode{highlighted-node-\number\value{tikzhighlightnode}}{#2}% + \edef\temp{% + \noexpand\AddToShipoutPictureBG{% + \noexpand\begin{tikzpicture}[overlay,remember picture]% + \noexpand\iftikzmarkoncurrentpage{highlighted-node-\number\value{tikzhighlightnode}}% + \noexpand\node[inner sep=1.0pt,fill=#1,#3,fit=(highlighted-node-\number\value{tikzhighlightnode})]{};% + \noexpand\fi + \noexpand\end{tikzpicture}% + }% }% + \temp% }% - \temp% -}% % \end{macrocode} % -% A simplified command for importing images. +% A simplified command for importing images.\newline +% See \url{https://tex.stackexchange.com/a/614478/218142}. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} Slightly modified \refCom{image}} % \begin{macrocode} -\NewDocumentCommand{\image}{ O{scale=1} m m m }{% - \begin{figure}[ht!] - \begin{center}% +\NewDocumentCommand{\image}{ O{scale=1} m m m }% + {% + \par + \begin{figure}[ht!] + \centering% \includegraphics[#1]{#2}% - \end{center}% - \caption{#3}% - \label{#4}% - \end{figure}% -}% + \caption{#3}% + \label{#4}% + \end{figure}% + \par + }% % \end{macrocode} % % Intelligent commands for typesetting vector and tensor symbols and @@ -1525,86 +1726,104 @@ while t < 10: % coordinate-free. % % \begin{macrocode} -\NewDocumentCommand{\veccomp}{ s m }{% - % Consider renaming this to \vectorsym. - \IfBooleanTF{#1} +\NewDocumentCommand{\veccomp}{ s m }% {% - \symnormal{#2}% - }% - {% - \symbfit{#2}% - }% -}% -\NewDocumentCommand{\tencomp}{ s m }{% - % Consider renaming this to \tensororsym. - \IfBooleanTF{#1} - {% - \symsfit{#2}% + % Consider renaming this to \vectorsym. + \IfBooleanTF{#1} + {% + \symnormal{#2}% + }% + {% + \symbfit{#2}% + }% }% +\NewDocumentCommand{\tencomp}{ s m }% {% - \symbfsfit{#2} + % Consider renaming this to \tensororsym. + \IfBooleanTF{#1}% + {% + \symsfit{#2}% + }% + {% + \symbfsfit{#2}% + }% }% -}% % \end{macrocode} % % Command to typeset tensor valence. % % \begin{macrocode} -\NewDocumentCommand{\valence}{ s m m }{% - \IfBooleanTF{#1} - {(#2,#3)} - {\binom{#2}{#3}} -}% +\NewDocumentCommand{\valence}{ s m m }% + {% + \IfBooleanTF{#1}% + {% + (#2,#3)% + }% + {% + \binom{#2}{#3}% + }% + }% % \end{macrocode} % % Intelligent notation for contraction on pairs of slots. % % \begin{macrocode} -\NewDocumentCommand{\contraction}{ s m }{% - \IfBooleanTF{#1} - {\mathsf{C}}% - {\symbb{C}}% - _{#2} -}% +\NewDocumentCommand{\contraction}{ s m }% + {% + \IfBooleanTF{#1} + {% + \mathsf{C}% + }% + {% + \symbb{C}% + }% + _{#2} + }% % \end{macrocode} % % Intelligent slot command for coordinate-free tensor notation. % % \begin{macrocode} -\NewDocumentCommand{\slot}{ s d[] }{% - % d[] must be used because of the way consecutive optional - % arguments are handled. See xparse docs for details. - \IfBooleanTF{#1} - {% - \IfValueTF{#2} - {% Insert a vector, but don't show the slot. - \smash{\makebox[1.5em]{\ensuremath{#2}}} - }% - {% No vector, no slot. - \smash{\makebox[1.5em]{\ensuremath{}}} - }% - }% +\NewDocumentCommand{\slot}{ s d[] }% {% - \IfValueTF{#2} - {% Insert a vector and show the slot. - \underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}} + % d[] must be used because of the way consecutive optional + % arguments are handled. See xparse docs for details. + \IfBooleanTF{#1} + {% + \IfValueTF{#2} + {% Insert a vector, but don't show the slot. + \smash{\makebox[1.5em]{\ensuremath{#2}}} + }% + {% No vector, no slot. + \smash{\makebox[1.5em]{\ensuremath{}}} + }% }% - {% No vector; just show the slot. - \underline{\smash{\makebox[1.5em]{\ensuremath{}}}} + {% + \IfValueTF{#2} + {% Insert a vector and show the slot. + \underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}} + }% + {% No vector; just show the slot. + \underline{\smash{\makebox[1.5em]{\ensuremath{}}}} + }% }% }% -}% % \end{macrocode} % % Intelligent differential (exterior derivative) operator. % % \begin{macrocode} -\NewDocumentCommand{\diff}{ s }{% - \mathop{}\! - \IfBooleanTF{#1} - {\symbfsfup{d}}% - {\symsfup{d}}% -}% +\NewDocumentCommand{\df}{ s }% + {% + \mathop{}\!% + \IfBooleanTF{#1}% + {% + \symbfsfup{d}% + }% + {% + \symsfup{d}% + }% + }% % \end{macrocode} % % Here is a clever way to color digits in program listsings thanks to @@ -1633,151 +1852,213 @@ while t < 10: \definecolor{gspeach} {rgb}{1.00,0.90,0.71} % peach \definecolor{gspearl} {rgb}{0.94,0.92,0.84} % pearl \definecolor{gsplum} {rgb}{0.74,0.46,0.70} % plum -\lstdefinestyle{vpython}{% % style for listings - backgroundcolor=\color{gsbggray},% % background color - basicstyle=\colordigits\footnotesize,% % default style - breakatwhitespace=true% % break at whitespace - breaklines=true,% % break long lines - captionpos=b,% % position caption - classoffset=1,% % STILL DON'T UNDERSTAND THIS - commentstyle=\color{gsgray},% % font for comments - deletekeywords={print},% % delete keywords from the given language - emph={self,cls,@classmethod,@property},% % words to emphasize - emphstyle=\color{gsorange}\itshape,% % font for emphasis - escapeinside={(*@}{@*)},% % add LaTeX within your code - frame=tb,% % frame style - framerule=2.0pt,% % frame thickness - framexleftmargin=5pt,% % extra frame left margin - %identifierstyle=\sffamily,% % style for identifiers - keywordstyle=\gsfontfamily\color{gsplum},% % color for keywords - language=Python,% % select language - linewidth=\linewidth,% % width of listings - morekeywords={% % VPython/GlowScript specific keywords - __future__,abs,acos,align,ambient,angle,append,append_to_caption,% - append_to_title,arange,arrow,asin,astuple,atan,atan2,attach_arrow,% - attach_trail,autoscale,axis,background,billboard,bind,black,blue,border,% - bounding_box,box,bumpaxis,bumpmap,bumpmaps,camera,canvas,caption,capture,% - ceil,center,clear,clear_trail,click,clone,CoffeeScript,coils,color,combin,% - comp,compound,cone,convex,cos,cross,curve,cyan,cylinder,data,degrees,del,% - delete,depth,descender,diff_angle,digits,division,dot,draw_complete,% - ellipsoid,emissive,end_face_color,equals,explog,extrusion,faces,factorial,% - False,floor,follow,font,format,forward,fov,frame,gcurve,gdisplay,gdots,% - get_library,get_selected,ghbars,global,GlowScript,graph,graphs,green,gvbars,% - hat,headlength,headwidth,height,helix,hsv_to_rgb,index,interval,keydown,% - keyup,label,length,lights,line,linecolor,linewidth,logx,logy,lower_left,% - lower_right,mag,mag2,magenta,make_trail,marker_color,markers,material,% - max,min,mouse,mousedown,mousemove,mouseup,newball,norm,normal,objects,% - offset,one,opacity,orange,origin,path,pause,pi,pixel_to_world,pixels,plot,% - points,pos,pow,pps,print,print_function,print_options,proj,purple,pyramid,% - quad,radians,radius,random,rate,ray,read_local_file,readonly,red,redraw,% - retain,rgb_to_hsv,ring,rotate,round,scene,scroll,shaftwidth,shape,shapes,% - shininess,show_end_face,show_start_face,sign,sin,size,size_units,sleep,% - smooth,space,sphere,sqrt,start,start_face_color,stop,tan,text,textpos,% - texture,textures,thickness,title,trail_color,trail_object,trail_radius,% - trail_type,triangle,trigger,True,twist,unbind,up,upper_left,upper_right,% - userpan,userspin,userzoom,vec,vector,vertex,vertical_spacing,visible,% - visual,vpython,VPython,waitfor,white,width,world,xtitle,yellow,yoffset,% - ytitle% - },% - morekeywords={print,None,TypeError},% % additional keywords - morestring=[b]{"""},% % treat triple quotes as strings - numbers=left,% % where to put line numbers - numbersep=10pt,% % how far line numbers are from code - numberstyle=\bfseries\tiny,% % set to 'none' for no line numbers - showstringspaces=false,% % show spaces in strings - showtabs=false,% % show tabs within strings - stringstyle=\gsfontfamily\color{gsgreen},% % color for strings - upquote=true,% % how to typeset quotes -}% +\lstdefinestyle{vpython}% + {% % style for listings + backgroundcolor=\color{gsbggray},% % background color + basicstyle=\colordigits\footnotesize,% % default style + breakatwhitespace=true% % break at whitespace + breaklines=true,% % break long lines + captionpos=b,% % position caption + classoffset=1,% % STILL DON'T UNDERSTAND THIS + commentstyle=\color{gsgray},% % font for comments + deletekeywords={print},% % delete keywords from the given language + emph={self,cls,@classmethod,@property},% % words to emphasize + emphstyle=\color{gsorange}\itshape,% % font for emphasis + escapeinside={(*@}{@*)},% % add LaTeX within your code + frame=tb,% % frame style + framerule=2.0pt,% % frame thickness + framexleftmargin=5pt,% % extra frame left margin + %identifierstyle=\sffamily,% % style for identifiers + keywordstyle=\gsfontfamily\color{gsplum},% % color for keywords + language=Python,% % select language + linewidth=\linewidth,% % width of listings + morekeywords={% % VPython/Web VPython specific keywords + __future__,abs,acos,align,ambient,angle,append,append_to_caption,% + append_to_title,arange,arrow,asin,astuple,atan,atan2,attach_arrow,% + attach_trail,autoscale,axis,background,billboard,bind,black,blue,border,% + bounding_box,box,bumpaxis,bumpmap,bumpmaps,camera,canvas,caption,capture,% + ceil,center,clear,clear_trail,click,clone,CoffeeScript,coils,color,combin,% + comp,compound,cone,convex,cos,cross,curve,cyan,cylinder,data,degrees,del,% + delete,depth,descender,diff_angle,digits,division,dot,draw_complete,% + ellipsoid,emissive,end_face_color,equals,explog,extrusion,faces,factorial,% + False,floor,follow,font,format,forward,fov,frame,gcurve,gdisplay,gdots,% + get_library,get_selected,ghbars,global,GlowScript,graph,graphs,green,gvbars,% + hat,headlength,headwidth,height,helix,hsv_to_rgb,index,interval,keydown,% + keyup,label,length,lights,line,linecolor,linewidth,logx,logy,lower_left,% + lower_right,mag,mag2,magenta,make_trail,marker_color,markers,material,% + max,min,mouse,mousedown,mousemove,mouseup,newball,norm,normal,objects,% + offset,one,opacity,orange,origin,path,pause,pi,pixel_to_world,pixels,plot,% + points,pos,pow,pps,print,print_function,print_options,proj,purple,pyramid,% + quad,radians,radius,random,rate,ray,read_local_file,readonly,red,redraw,% + retain,rgb_to_hsv,ring,rotate,round,scene,scroll,shaftwidth,shape,shapes,% + shininess,show_end_face,show_start_face,sign,sin,size,size_units,sleep,% + smooth,space,sphere,sqrt,start,start_face_color,stop,tan,text,textpos,% + texture,textures,thickness,title,trail_color,trail_object,trail_radius,% + trail_type,triangle,trigger,True,twist,unbind,up,upper_left,upper_right,% + userpan,userspin,userzoom,vec,vector,vertex,vertical_spacing,visible,% + visual,vpython,VPython,waitfor,WebVPython,white,width,world,xtitle,% + yellow,yoffset,ytitle% + },% + morekeywords={print,None,TypeError},% % additional keywords + morestring=[b]{"""},% % treat triple quotes as strings + numbers=left,% % where to put line numbers + numbersep=10pt,% % how far line numbers are from code + numberstyle=\bfseries\tiny,% % set to 'none' for no line numbers + showstringspaces=false,% % show spaces in strings + showtabs=false,% % show tabs within strings + stringstyle=\gsfontfamily\color{gsgreen},% % color for strings + upquote=true,% % how to typeset quotes + }% % \end{macrocode} % -% Introduce a new, more intelligent \refEnv{glowscriptblock} environment. +% Introduce a new, more intelligent \refEnv{webvpythonblock} environment.\newline +% See \url{https://tex.stackexchange.com/a/232208/218142}. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} URLs fixed in \refEnv{webvpythonblock}} +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \refEnv{webvpythonblock} now automatically +% generates QR codes for program listings} % \begin{macrocode} -\NewTCBListing[auto counter,list inside=gsprogs]{glowscriptblock} - { O{} D(){glowscript.org} m }{% - breakable,% - center,% - code = \newpage,% - %derivpeach,% - enhanced,% - hyperurl interior = https://#2,% - label = {gs:\thetcbcounter},% - left = 8mm,% - list entry = \thetcbcounter~~~~~#3,% - listing only,% - listing style = vpython,% - nameref = {#3},% - title = \texttt{GlowScript} Program \thetcbcounter: #3,% - width = 0.9\textwidth,% - {#1}, -}% +\AtBeginEnvironment{webvpythonblock}{\catcode`\#=12} +\AtEndEnvironment{webvpythonblock}{\catcode`\#=6} +\NewTCBListing[auto counter,list inside=gsprogs]{webvpythonblock}{ O{} D(){webvpython.org} m }% + {% + breakable,% + center,% + code = \newpage,% + %derivpeach,% + enhanced,% + hyperurl interior = https://#2,% + label = {gs:\thetcbcounter},% + left = 8mm,% + list entry = \thetcbcounter~~~~~#3,% + listing only,% + listing style = vpython,% + nameref = {#3},% + title = \begin{minipage}{1.5cm}% + \protect\qrcode*{https://#2}% + \end{minipage}\hspace{5mm}% + \begin{minipage}{0.7\textwidth}% + \texttt{Web VPython} Program \thetcbcounter: #3% + \end{minipage},% + width = 0.9\textwidth,% + {#1}, + }% % \end{macrocode} % -% A new command for generating a list of \GlowScript\ programs. +% Here is a variant that omits the QR code. % +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} \refEnv{webvpythonblock*} is a variant +% of \refEnv{webvpythonblock} that omits the QR code} % \begin{macrocode} -\NewDocumentCommand{\listofglowscriptprograms}{}{\tcblistof[\section*]{gsprogs} - {List of \texttt{GlowScript} Programs}}% +\AtBeginEnvironment{webvpythonblock*}{\catcode`\#=12} +\AtEndEnvironment{webvpythonblock*}{\catcode`\#=6} +\NewTCBListing[use counter from=webvpythonblock,list inside=gsprogs] + {webvpythonblock*}{ O{} D(){webvpython.org} m }% + {% + breakable,% + center,% + code = \newpage,% + %derivpeach,% + enhanced,% + hyperurl interior = https://#2,% + label = {gs:\thetcbcounter},% + left = 8mm,% + list entry = \thetcbcounter~~~~~#3,% + listing only,% + listing style = vpython,% + nameref = {#3},% + title = \texttt{Web VPython} Program \thetcbcounter: #3,% + width = 0.9\textwidth,% + {#1}, + }% % \end{macrocode} % -% Introduce a new, more intelligent \refCom{vpythonfile} command. +% A new command for generating a list of \WebVPython\ programs. % % \begin{macrocode} -\NewTCBInputListing[auto counter,list inside=vpprogs]{\vpythonfile} - { O{} m m }{% - breakable,% - center,% - code = \newpage,% - %derivgray,% - enhanced,% - hyperurl interior = https://,% - label = {vp:\thetcbcounter},% - left = 8mm,% - list entry = \thetcbcounter~~~~~#3,% - listing file = {#2},% - listing only,% - listing style = vpython,% - nameref = {#3},% - title = \texttt{VPython} Program \thetcbcounter: #3,% - width = 0.9\textwidth,% - {#1},% -}% +\NewDocumentCommand{\listofwebvpythonprograms}{}% + {% + \tcblistof[\section*]{gsprogs}{List of \texttt{Web VPython} Programs}% + }% +% \end{macrocode} +% +% Introduce a new, more intelligent \refCom{vpythonfile} command.\newline +% See \url{https://tex.stackexchange.com/q/616205/218142}. +% +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} URLs fixed in \refCom{vpythonfile}} +% \changes{v3.1.0}{2022-01-27} +% {\linktoplace{sec:mandistudentpkg}{mandistudent} Default URL for \refCom{vpythonfile} +% is now \vpurl} +% \begin{macrocode} +\newcommand*{\vpythonfile}{\catcode`\#=12 \vpythonfile@auxA} +\NewDocumentCommand{\vpythonfile@auxA}{ O{} D(){vpython.org} m m }% + {% + \vpythonfile@auxB[#1](#2){#3}{#4}% + \catcode`\#=6 + }% +\NewTCBInputListing[auto counter,list inside=vpprogs] + {\vpythonfile@auxB}{ O{} D(){vpython.org} m m }% + {% + breakable,% + center,% + code = \newpage,% + %derivgray,% + enhanced,% + hyperurl interior = https://#2,% + label = {vp:\thetcbcounter},% + left = 8mm,% + list entry = \thetcbcounter~~~~~#4,% + listing file = {#3},% + listing only,% + listing style = vpython,% + nameref = {#4},% + title = \texttt{VPython} Program \thetcbcounter: #4,% + width = 0.9\textwidth,% + {#1},% + }% % \end{macrocode} % % A new command for generating a list of \VPython\ programs. % % \begin{macrocode} -\NewDocumentCommand{\listofvpythonprograms}{}{\tcblistof[\section*]{vpprogs} - {List of \texttt{VPython} Programs}}% +\NewDocumentCommand{\listofvpythonprograms}{}% + {% + \tcblistof[\section*]{vpprogs}{List of \texttt{VPython} Programs}% + }% % \end{macrocode} % -% Introduce a new \refCom{glowscriptinline} command. +% Introduce a new \refCom{webvpythoninline} command. % % \begin{macrocode} -\DeclareTotalTCBox{\glowscriptinline}{ m }{% - bottom = 0pt,% - bottomrule = 0.0mm,% - boxsep = 1.0mm,% - colback = gsbggray,% - colframe = gsbggray,% - left = 0pt,% - leftrule = 0.0mm,% - nobeforeafter,% - right = 0pt,% - rightrule = 0.0mm,% - sharp corners,% - tcbox raise base,% - top = 0pt,% - toprule = 0.0mm,% -}{\lstinline[style = vpython]{#1}}% +\DeclareTotalTCBox{\webvpythoninline}{ m }% + {% + bottom = 0pt,% + bottomrule = 0.0mm,% + boxsep = 1.0mm,% + colback = gsbggray,% + colframe = gsbggray,% + left = 0pt,% + leftrule = 0.0mm,% + nobeforeafter,% + right = 0pt,% + rightrule = 0.0mm,% + sharp corners,% + tcbox raise base,% + top = 0pt,% + toprule = 0.0mm,% + }% + {\lstinline[style = vpython]{#1}}% % \end{macrocode} % % Define \refCom{vpythoninline}, a semantic alias for \VPython\ % in-line listings. % % \begin{macrocode} -\NewDocumentCommand{\vpythoninline}{}{\glowscriptinline}% +\NewDocumentCommand{\vpythoninline}{}{\webvpythoninline}% % \end{macrocode} % % \restoregeometry |