| 1 |
% \iffalse meta-comment |
| 2 |
% !TEX program = lualatexmk |
| 3 |
% |
| 4 |
% Copyright (C) 2021-2024 by Paul J. Heafner <[email protected]> |
| 5 |
% --------------------------------------------------------------------------- |
| 6 |
% This work may be distributed and/or modified under the conditions of the |
| 7 |
% LaTeX Project Public License, either version 1.3c of this license or (at |
| 8 |
% your option) any later version. The latest version of this license is in |
| 9 |
% https://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3c or later is part of all distributions of LaTeX version |
| 11 |
% 2005/12/01 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is Paul J. Heafner. |
| 16 |
% |
| 17 |
% This work consists of the files mandi.dtx |
| 18 |
% mandistudent.dtx |
| 19 |
% mandiexp.dtx |
| 20 |
% mandi.ins |
| 21 |
% mandi.pdf |
| 22 |
% README.md |
| 23 |
% |
| 24 |
% and includes the derived files mandi.sty |
| 25 |
% mandistudent.sty |
| 26 |
% mandiexp.sty |
| 27 |
% vdemo.py (not needed) |
| 28 |
% --------------------------------------------------------------------------- |
| 29 |
% |
| 30 |
%<*internal> |
| 31 |
\iffalse |
| 32 |
%</internal> |
| 33 |
% |
| 34 |
%<*vdemo> |
| 35 |
from vpython import * |
| 36 |
|
| 37 |
scene.width = 400 |
| 38 |
scene.height = 760 |
| 39 |
# constants and data |
| 40 |
g = 9.8 # m/s^2 |
| 41 |
mball = 0.03 # kg |
| 42 |
Lo = 0.26 # m |
| 43 |
ks = 1.8 # N/m |
| 44 |
deltat = 0.01 # s |
| 45 |
|
| 46 |
# objects (origin is at ceiling) |
| 47 |
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, |
| 48 |
width=0.2) |
| 49 |
ball = sphere(pos=vector(0,-0.3,0),radius=0.025, |
| 50 |
color=color.orange) |
| 51 |
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, |
| 52 |
color=color.cyan,thickness=0.003,coils=40, |
| 53 |
radius=0.010) |
| 54 |
|
| 55 |
# initial values |
| 56 |
pball = mball * vector(0,0,0) # kg m/s |
| 57 |
Fgrav = mball * g * vector(0,-1,0) # N |
| 58 |
t = 0 |
| 59 |
|
| 60 |
# improve the display |
| 61 |
scene.autoscale = False # turn off automatic camera zoom |
| 62 |
scene.center = vector(0,-Lo,0) # move camera down |
| 63 |
scene.waitfor('click') # wait for a mouse click |
| 64 |
|
| 65 |
# initial calculation loop |
| 66 |
# calculation loop |
| 67 |
while t < 10: |
| 68 |
rate(100) |
| 69 |
# we need the stretch |
| 70 |
s = mag(ball.pos) - Lo |
| 71 |
# we need the spring force |
| 72 |
Fspring = ks * s * -norm(spring.axis) |
| 73 |
Fnet = Fgrav + Fspring |
| 74 |
pball = pball + Fnet * deltat |
| 75 |
ball.pos = ball.pos + (pball / mball) * deltat |
| 76 |
spring.axis = ball.pos - ceiling.pos |
| 77 |
t = t + deltat |
| 78 |
%</vdemo> |
| 79 |
% |
| 80 |
%<*internal> |
| 81 |
\fi |
| 82 |
\def\nameofplainTeX{plain} |
| 83 |
\ifx\fmtname\nameofplainTeX\else |
| 84 |
\expandafter\begingroup |
| 85 |
\fi |
| 86 |
%</internal> |
| 87 |
% |
| 88 |
%<*internal> |
| 89 |
\usedir{tex/latex/mandi} |
| 90 |
\ifx\fmtname\nameofplainTeX |
| 91 |
\expandafter\endbatchfile |
| 92 |
\else |
| 93 |
\expandafter\endgroup |
| 94 |
\fi |
| 95 |
%</internal> |
| 96 |
% |
| 97 |
%<*driver> |
| 98 |
\ProvidesFile{mandistudent.dtx} |
| 99 |
\DisableCrossrefs % index descriptions only |
| 100 |
\PageIndex % index refers to page numbers |
| 101 |
\CodelineNumbered % number source lines |
| 102 |
\RecordChanges % record changes |
| 103 |
\begin{document} % main document |
| 104 |
\DocInput{\jobname.dtx} % |
| 105 |
\PrintIndex % |
| 106 |
\end{document} % end main document |
| 107 |
%</driver> |
| 108 |
% \fi |
| 109 |
% |
| 110 |
% ^^A DO NOT TRY TO COMPILE THIS DTX FILE BY ITSELF. IT WILL FAIL. |
| 111 |
% |
| 112 |
% \section{The \mandistudent{} Package}\setplace{sec:mandib} |
| 113 |
% |
| 114 |
% \mandi{} comes with an accessory package \mandistudent, |
| 115 |
% which extends \mandi{} with a collection of commands physics |
| 116 |
% students can use for writing problem solutions. This package |
| 117 |
% focuses on the most frequently needed tools. These commands |
| 118 |
% should always be used in math mode. \mandistudent{} requires, |
| 119 |
% and loads, \mandi{} but \mandi{} doesn't require, and doesn't |
| 120 |
% load, \mandistudent. |
| 121 |
% |
| 122 |
% Load \mandistudent{} as you would any package in your preamble. |
| 123 |
% There are no package options. |
| 124 |
% |
| 125 |
%\iffalse |
| 126 |
%<*example> |
| 127 |
%\fi |
| 128 |
\begin{dispListing*}{sidebyside = false,listing only} |
| 129 |
\usepackage{mandistudent} |
| 130 |
\end{dispListing*} |
| 131 |
%\iffalse |
| 132 |
%</example> |
| 133 |
%\fi |
| 134 |
% |
| 135 |
%\iffalse |
| 136 |
%<*example> |
| 137 |
%\fi |
| 138 |
\begin{docCommand}{mandistudentversion}{} |
| 139 |
Typesets the current version and build date. |
| 140 |
\end{docCommand} |
| 141 |
\begin{dispExample*}{sidebyside = false} |
| 142 |
The version is \mandistudentversion{} and is a stable build. |
| 143 |
\end{dispExample*} |
| 144 |
%\iffalse |
| 145 |
%</example> |
| 146 |
%\fi |
| 147 |
% |
| 148 |
% \subsection{Traditional Vector Notation} |
| 149 |
% |
| 150 |
%\iffalse |
| 151 |
%<*example> |
| 152 |
%\fi |
| 153 |
\begin{docCommands}[% |
| 154 |
doc updated = 2021-09-18,% |
| 155 |
doc parameter = \marg{symbol}\oarg{labels},% |
| 156 |
]% |
| 157 |
{% |
| 158 |
{% |
| 159 |
doc name = vec,% |
| 160 |
doc description = use this variant for boldface notation,% |
| 161 |
},% |
| 162 |
{% |
| 163 |
doc name = vec*,% |
| 164 |
doc description = use this variant for arrow notation,% |
| 165 |
}% |
| 166 |
}% |
| 167 |
Powerful and intelligent command for symbolic vector notation. The |
| 168 |
mandatory argument is the symbol for the vector quantity. The optional |
| 169 |
label(s) consists of superscripts and/or subscripts and can be |
| 170 |
mathematical or textual in nature. If textual, be sure to wrap them in |
| 171 |
|\symup{...}| for proper typesetting. The starred variant gives arrow |
| 172 |
notation whereas without the star you get boldface notation. Subscript |
| 173 |
and superscript labels can be arbitrarily mixed, and order doesn't matter. |
| 174 |
This command redefines the default \LaTeXe |\vec| command. |
| 175 |
\end{docCommands} |
| 176 |
\begin{dispExample*}{lefthand ratio = 0.6} |
| 177 |
\( \vec{p} \) \\ |
| 178 |
\( \vec{p}_{2} \) \\ |
| 179 |
\( \vec{p}^{\symup{ball}} \) \\ |
| 180 |
\( \vec{p}_{\symup{final}} \) \\ |
| 181 |
\( \vec{p}^{\symup{ball}}_{\symup{final}} \) \\ |
| 182 |
\( \vec{p}^{\symup{final}}_{\symup{ball}} \) \\ |
| 183 |
\( \vec*{p} \) \\ |
| 184 |
\( \vec*{p}_{2} \) \\ |
| 185 |
\( \vec*{p}^{\symup{ball}} \) \\ |
| 186 |
\( \vec*{p}_{\symup{final}} \) \\ |
| 187 |
\( \vec*{p}^{\symup{ball}}_{\symup{final}} \) \\ |
| 188 |
\( \vec*{p}^{\symup{final}}_{\symup{ball}} \) |
| 189 |
\end{dispExample*} |
| 190 |
%\iffalse |
| 191 |
%</example> |
| 192 |
%\fi |
| 193 |
% |
| 194 |
%\iffalse |
| 195 |
%<*example> |
| 196 |
%\fi |
| 197 |
\begin{docCommands}[% |
| 198 |
doc updated = 2021-09-18,% |
| 199 |
doc parameter = \marg{symbol}\oarg{labels},% |
| 200 |
]% |
| 201 |
{% |
| 202 |
{% |
| 203 |
doc name = dirvec,% |
| 204 |
doc description = use this variant for boldface notation,% |
| 205 |
},% |
| 206 |
{% |
| 207 |
doc name = dirvec*,% |
| 208 |
doc description = use this variant for arrow notation,% |
| 209 |
}% |
| 210 |
}% |
| 211 |
Powerful and intelligent command for typesetting the direction of |
| 212 |
a vector. The options are the same as those for \refCom{vec}. |
| 213 |
\end{docCommands} |
| 214 |
\begin{dispExample*}{lefthand ratio = 0.65} |
| 215 |
\( \dirvec{p} \) \\ |
| 216 |
\( \dirvec{p}_{2} \) \\ |
| 217 |
\( \dirvec{p}^{\symup{ball}} \) \\ |
| 218 |
\( \dirvec{p}_{\symup{final}} \) \\ |
| 219 |
\( \dirvec{p}^{\symup{ball}}_{\symup{final}} \) \\ |
| 220 |
\( \dirvec{p}^{\symup{final}}_{\symup{ball}} \) \\ |
| 221 |
\( \dirvec*{p} \) \\ |
| 222 |
\( \dirvec*{p}_{2} \) \\ |
| 223 |
\( \dirvec*{p}^{\symup{ball}} \) \\ |
| 224 |
\( \dirvec*{p}_{\symup{final}} \) \\ |
| 225 |
\( \dirvec*{p}^{\symup{ball}}_{\symup{final}} \) \\ |
| 226 |
\( \dirvec*{p}^{\symup{final}}_{\symup{ball}} \) |
| 227 |
\end{dispExample*} |
| 228 |
%\iffalse |
| 229 |
%</example> |
| 230 |
%\fi |
| 231 |
% |
| 232 |
%\iffalse |
| 233 |
%<*example> |
| 234 |
%\fi |
| 235 |
\begin{docCommands} |
| 236 |
{% |
| 237 |
{% |
| 238 |
doc name = zerovec,% |
| 239 |
doc description = use this variant for boldface notation,% |
| 240 |
},% |
| 241 |
{% |
| 242 |
doc name = zerovec*,% |
| 243 |
doc description = use this variant for arrow notation,% |
| 244 |
},% |
| 245 |
}% |
| 246 |
Command for typesetting the zero vector. The starred variant gives |
| 247 |
arrow notation. Without the star you get boldface notation. |
| 248 |
\end{docCommands} |
| 249 |
\begin{dispExample} |
| 250 |
\( \zerovec \) \\ |
| 251 |
\( \zerovec* \) |
| 252 |
\end{dispExample} |
| 253 |
%\iffalse |
| 254 |
%</example> |
| 255 |
%\fi |
| 256 |
% |
| 257 |
%\iffalse |
| 258 |
%<*example> |
| 259 |
%\fi |
| 260 |
\begin{docCommand}{changein}{}% |
| 261 |
Semantic alias for |\Delta|. |
| 262 |
\end{docCommand} |
| 263 |
\begin{dispExample} |
| 264 |
\( \changein t \) \\ |
| 265 |
\( \changein \vec{p} \) |
| 266 |
\end{dispExample} |
| 267 |
%\iffalse |
| 268 |
%</example> |
| 269 |
%\fi |
| 270 |
% |
| 271 |
%\iffalse |
| 272 |
%<*example> |
| 273 |
%\fi |
| 274 |
\begin{docCommands}[% |
| 275 |
doc new = 2021-02-21,% |
| 276 |
doc parameter = \oarg{size}\marg{quantity},% |
| 277 |
]% |
| 278 |
{% |
| 279 |
{% |
| 280 |
doc name = doublebars,% |
| 281 |
doc description = double bars,% |
| 282 |
},% |
| 283 |
{% |
| 284 |
doc name = doublebars*,% |
| 285 |
doc description = double bars for fractions,% |
| 286 |
},% |
| 287 |
{% |
| 288 |
doc name = singlebars,% |
| 289 |
doc description = single bars,% |
| 290 |
},% |
| 291 |
{% |
| 292 |
doc name = singlebars*,% |
| 293 |
doc description = single bars for fractions,% |
| 294 |
},% |
| 295 |
{% |
| 296 |
doc name = anglebrackets,% |
| 297 |
doc description = angle brackets,% |
| 298 |
},% |
| 299 |
{% |
| 300 |
doc name = anglebrackets*,% |
| 301 |
doc description = angle brackets for fractions,% |
| 302 |
},% |
| 303 |
{% |
| 304 |
doc name = parentheses,% |
| 305 |
doc description = parentheses,% |
| 306 |
},% |
| 307 |
{% |
| 308 |
doc name = parentheses*,% |
| 309 |
doc description = parentheses for fractions,% |
| 310 |
},% |
| 311 |
{% |
| 312 |
doc name = squarebrackets,% |
| 313 |
doc description = square brackets,% |
| 314 |
},% |
| 315 |
{% |
| 316 |
doc name = squarebrackets*,% |
| 317 |
doc description = square brackets for fractions,% |
| 318 |
},% |
| 319 |
{% |
| 320 |
doc name = curlybraces,% |
| 321 |
doc description = curly braces,% |
| 322 |
},% |
| 323 |
{% |
| 324 |
doc name = curlybraces*,% |
| 325 |
doc description = curly braces for fractions,% |
| 326 |
},% |
| 327 |
}% |
| 328 |
If no argument is given, a placeholder is provided. |
| 329 |
Sizers like |\big|,|\Big|,|\bigg|, and |\Bigg| can |
| 330 |
be optionally specified. Beginners are encouraged |
| 331 |
not to use them. See the |
| 332 |
\href{https://www.ctan.org/pkg/mathtools}{\pkg{mathtools}} package |
| 333 |
documentation for details. |
| 334 |
\end{docCommands} |
| 335 |
\begin{dispExample} |
| 336 |
\[ \doublebars{} \] |
| 337 |
\[ \doublebars{\vec{a}} \] |
| 338 |
\[ \doublebars*{\frac{\vec{a}}{3}} \] |
| 339 |
\[ \doublebars[\Bigg]{\frac{\vec{a}}{3}} \] |
| 340 |
\end{dispExample} |
| 341 |
\begin{dispExample} |
| 342 |
\[ \singlebars{} \] |
| 343 |
\[ \singlebars{x} \] |
| 344 |
\[ \singlebars*{\frac{x}{3}} \] |
| 345 |
\[ \singlebars[\Bigg]{\frac{x}{3}} \] |
| 346 |
\end{dispExample} |
| 347 |
\begin{dispExample} |
| 348 |
\[ \anglebrackets{} \] |
| 349 |
\[ \anglebrackets{\vec{a}} \] |
| 350 |
\[ \anglebrackets*{\frac{\vec{a}}{3}} \] |
| 351 |
\[ \anglebrackets[\Bigg]{\frac{\vec{a}}{3}} \] |
| 352 |
\end{dispExample} |
| 353 |
\begin{dispExample} |
| 354 |
\[ \parentheses{} \] |
| 355 |
\[ \parentheses{x} \] |
| 356 |
\[ \parentheses*{\frac{x}{3}} \] |
| 357 |
\[ \parentheses[\Bigg]{\frac{x}{3}} \] |
| 358 |
\end{dispExample} |
| 359 |
\begin{dispExample} |
| 360 |
\[ \squarebrackets{} \] |
| 361 |
\[ \squarebrackets{x} \] |
| 362 |
\[ \squarebrackets*{\frac{x}{3}} \] |
| 363 |
\[ \squarebrackets[\Bigg]{\frac{x}{3}} \] |
| 364 |
\end{dispExample} |
| 365 |
\begin{dispExample} |
| 366 |
\[ \curlybraces{} \] |
| 367 |
\[ \curlybraces{x} \] |
| 368 |
\[ \curlybraces*{\frac{x}{3}} \] |
| 369 |
\[ \curlybraces[\Bigg]{\frac{x}{3}} \] |
| 370 |
\end{dispExample} |
| 371 |
%\iffalse |
| 372 |
%</example> |
| 373 |
%\fi |
| 374 |
% |
| 375 |
%\iffalse |
| 376 |
%<*example> |
| 377 |
%\fi |
| 378 |
\begin{docCommands}[% |
| 379 |
doc new = 2021-02-21,% |
| 380 |
doc parameter = \oarg{size}\marg{quantity},% |
| 381 |
]% |
| 382 |
{% |
| 383 |
{% |
| 384 |
doc name = magnitude,% |
| 385 |
doc description = alias for double bars,% |
| 386 |
},% |
| 387 |
{% |
| 388 |
doc name = magnitude*,% |
| 389 |
doc description = alias for double bars for fractions,% |
| 390 |
},% |
| 391 |
{% |
| 392 |
doc name = norm,% |
| 393 |
doc description = alias for double bars,% |
| 394 |
},% |
| 395 |
{% |
| 396 |
doc name = norm*,% |
| 397 |
doc description = alias for double bars for fractions,% |
| 398 |
},% |
| 399 |
{% |
| 400 |
doc name = absolutevalue,% |
| 401 |
doc description = alias for single bars,% |
| 402 |
},% |
| 403 |
{% |
| 404 |
doc name = absolutevalue*,% |
| 405 |
doc description = alias for single bars for fractions,% |
| 406 |
},% |
| 407 |
}% |
| 408 |
Semantic aliases. Use \refCom{magnitude} or \refCom{magnitude*} to |
| 409 |
typeset the magnitude of a vector. |
| 410 |
\end{docCommands} |
| 411 |
\begin{dispExample} |
| 412 |
\[ \magnitude{\vec{p}} \] |
| 413 |
\[ \magnitude{\vec*{p}} \] |
| 414 |
\[ \magnitude*{\vec{p}_{\symup{final}}} \] |
| 415 |
\[ \magnitude*{\vec*{p}_{\symup{final}}} \] |
| 416 |
\end{dispExample} |
| 417 |
%\iffalse |
| 418 |
%</example> |
| 419 |
%\fi |
| 420 |
% |
| 421 |
%\iffalse |
| 422 |
%<*example> |
| 423 |
%\fi |
| 424 |
\begin{docCommands}[% |
| 425 |
doc new = 2021-04-06,% |
| 426 |
]% |
| 427 |
{% |
| 428 |
{% |
| 429 |
doc name = parallelto,% |
| 430 |
},% |
| 431 |
{% |
| 432 |
doc name = perpendicularto,% |
| 433 |
},% |
| 434 |
}% |
| 435 |
Commands for geometric relationships, mainly |
| 436 |
intended for subscripts. |
| 437 |
\end{docCommands} |
| 438 |
\begin{dispExample*}{lefthand ratio = 0.6} |
| 439 |
\( \vec{F}_{\parallelto} + \vec{F}_{\perpendicularto} \) |
| 440 |
\end{dispExample*} |
| 441 |
%\iffalse |
| 442 |
%</example> |
| 443 |
%\fi |
| 444 |
% |
| 445 |
% \subsection{Problems and Annotated Problem Solutions} |
| 446 |
% |
| 447 |
%\iffalse |
| 448 |
%<*example> |
| 449 |
%\fi |
| 450 |
\begin{docEnvironments}[% |
| 451 |
doc updated = 2023-08-01,% |
| 452 |
doc parameter = \marg{title},% |
| 453 |
doclang/environment content = problem,% |
| 454 |
]% |
| 455 |
{% |
| 456 |
{% |
| 457 |
doc name = physicsproblem,% |
| 458 |
doc description = use this variant for vertical lists,% |
| 459 |
},% |
| 460 |
{% |
| 461 |
doc name = physicsproblem*,% |
| 462 |
doc description = use this variant for in-line lists,% |
| 463 |
},% |
| 464 |
{% |
| 465 |
doc name = parts,% |
| 466 |
doc description = provides problem parts,% |
| 467 |
},% |
| 468 |
}% |
| 469 |
Provides an environment for stating physics problems. Each problem will |
| 470 |
begin on a new page. See the examples for how to handle single and |
| 471 |
multiple part problems. Due to incompatibilities with \textsc{beamer} |
| 472 |
and the \pkg{enumitem} package, these environments are not defined if |
| 473 |
\textsc{beamer} is loaded. |
| 474 |
\end{docEnvironments} |
| 475 |
\begin{docCommand}[doc updated = 2023-08-01]{problempart}{} |
| 476 |
Denotes a part of a problem within a \refEnv{parts} |
| 477 |
environment. This command is not defined if \textsc{beamer} |
| 478 |
is loaded. |
| 479 |
\end{docCommand} |
| 480 |
\begin{dispExample*}{sidebyside = false} |
| 481 |
\begin{physicsproblem}{Problem 1} |
| 482 |
This is a physics problem with no parts. |
| 483 |
\end{physicsproblem} |
| 484 |
\end{dispExample*} |
| 485 |
\begin{dispExample*}{sidebyside = false} |
| 486 |
\begin{physicsproblem}{Problem 2} |
| 487 |
This is a physics problem with multiple parts. |
| 488 |
The list is vertical. |
| 489 |
\begin{parts} |
| 490 |
\problempart This is the first part. |
| 491 |
\problempart This is the second part. |
| 492 |
\problempart This is the third part. |
| 493 |
\end{parts} |
| 494 |
\end{physicsproblem} |
| 495 |
\end{dispExample*} |
| 496 |
\begin{dispExample*}{sidebyside = false} |
| 497 |
\begin{physicsproblem*}{Problem 3} |
| 498 |
This is a physics problem with multiple parts. |
| 499 |
The list is in-line. |
| 500 |
\begin{parts} |
| 501 |
\problempart This is the first part. |
| 502 |
\problempart This is the second part. |
| 503 |
\problempart This is the third part. |
| 504 |
\end{parts} |
| 505 |
\end{physicsproblem*} |
| 506 |
\end{dispExample*} |
| 507 |
%\iffalse |
| 508 |
%</example> |
| 509 |
%\fi |
| 510 |
% |
| 511 |
%\iffalse |
| 512 |
%<*example> |
| 513 |
%\fi |
| 514 |
\begin{docEnvironments}[% |
| 515 |
doc updated = 2021-02-26,% |
| 516 |
doc parameter = {},% |
| 517 |
doclang/environment content = solution steps,% |
| 518 |
]% |
| 519 |
{% |
| 520 |
{% |
| 521 |
doc name = physicssolution,% |
| 522 |
doc description = use this variant for numbered steps,% |
| 523 |
},% |
| 524 |
{% |
| 525 |
doc name = physicssolution*,% |
| 526 |
doc description = use this variant for unnumbered steps,% |
| 527 |
},% |
| 528 |
}% |
| 529 |
This environment is only for mathematical solutions. The starred |
| 530 |
variant omits numbering of steps. See the examples. |
| 531 |
\end{docEnvironments} |
| 532 |
\begin{dispExample} |
| 533 |
\begin{physicssolution} |
| 534 |
x &= y + z \\ |
| 535 |
z &= x - y \\ |
| 536 |
y &= x - z |
| 537 |
\end{physicssolution} |
| 538 |
\begin{physicssolution*} |
| 539 |
x &= y + z \\ |
| 540 |
z &= x - y \\ |
| 541 |
y &= x - z |
| 542 |
\end{physicssolution*} |
| 543 |
\end{dispExample} |
| 544 |
%\iffalse |
| 545 |
%</example> |
| 546 |
%\fi |
| 547 |
% |
| 548 |
%\iffalse |
| 549 |
%<*example> |
| 550 |
%\fi |
| 551 |
\begin{docCommand}[doc updated = 2021-02-26]{reason}{\marg{reason}} |
| 552 |
Provides an annotation in a step-by-step solution. |
| 553 |
Keep reasons short and to the point. Wrap mathematical |
| 554 |
content in math mode. |
| 555 |
\end{docCommand} |
| 556 |
\begin{dispExample} |
| 557 |
\begin{physicssolution} |
| 558 |
x &= y + z \reason{This is a reason.} \\ |
| 559 |
z &= x - y \reason{This is a reason too.} \\ |
| 560 |
y &= x - z \reason{final answer} |
| 561 |
\end{physicssolution} |
| 562 |
\begin{physicssolution*} |
| 563 |
x &= y + z \reason{This is a reason.} \\ |
| 564 |
z &= x - y \reason{This is a reason too.} \\ |
| 565 |
y &= x - z \reason{final answer} |
| 566 |
\end{physicssolution*} |
| 567 |
\end{dispExample} |
| 568 |
%\iffalse |
| 569 |
%</example> |
| 570 |
%\fi |
| 571 |
% |
| 572 |
% When writing solutions, remember that the \refEnv{physicssolution} |
| 573 |
% environment is \emph{only} for mathematical content, not textual |
| 574 |
% content or explanations. |
| 575 |
% |
| 576 |
%\iffalse |
| 577 |
%<*example> |
| 578 |
%\fi |
| 579 |
\begin{dispListing*}{sidebyside = false,listing only} |
| 580 |
\begin{physicsproblem}{Combined Problem and Solution} |
| 581 |
This is an interesting physics problem. |
| 582 |
\begin{physicssolution} |
| 583 |
The solution goes here. |
| 584 |
\end{physicssolution} |
| 585 |
\end{physicsproblem} |
| 586 |
\end{dispListing*} |
| 587 |
\begin{dispListing*}{sidebyside = false,listing only} |
| 588 |
\begin{physicsproblem}{Combined Multipart Problem with Solutions} |
| 589 |
This is a physics problem with multiple parts. |
| 590 |
\begin{parts} |
| 591 |
\problempart This is the first part. |
| 592 |
\begin{physicssolution} |
| 593 |
The solution goes here. |
| 594 |
\end{physicssolution} |
| 595 |
\problempart This is the second part. |
| 596 |
\begin{physicssolution} |
| 597 |
The solution goes here. |
| 598 |
\end{physicssolution} |
| 599 |
\problempart This is the third part. |
| 600 |
\begin{physicssolution} |
| 601 |
The solution goes here. |
| 602 |
\end{physicssolution} |
| 603 |
\end{parts} |
| 604 |
\end{physicsproblem} |
| 605 |
\end{dispListing*} |
| 606 |
%\iffalse |
| 607 |
%</example> |
| 608 |
%\fi |
| 609 |
% |
| 610 |
%\iffalse |
| 611 |
%<*example> |
| 612 |
%\fi |
| 613 |
\begin{docCommand}[doc updated = 2023-08-01]{hilite}{% |
| 614 |
\oarg{color}\marg{target}\oarg{shape} |
| 615 |
}% |
| 616 |
Hilites the desired target, which can be an entire mathematical expression |
| 617 |
or a part thereof. The default color is magenta and the default shape is a |
| 618 |
rectangle. This command is not defined if \textsc{beamer} is loaded. |
| 619 |
\end{docCommand} |
| 620 |
\begin{dispListing*}{sidebyside = false,listing only} |
| 621 |
\begin{align*} |
| 622 |
(\Delta s)^2 &= -(\Delta t)^2 + (\Delta x)^2 + (\Delta y)^2 + |
| 623 |
(\Delta z)^2 \\ |
| 624 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rounded rectangle] + |
| 625 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 626 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rectangle] + |
| 627 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 628 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[ellipse] + |
| 629 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 630 |
(\Delta s)^{\hilite{2}[circle]} &= \hilite[green]{-}[circle] |
| 631 |
(\Delta t)^{\hilite[cyan]{2}[circle]}+ |
| 632 |
(\Delta x)^{\hilite[orange]{2}[circle]} + |
| 633 |
(\Delta y)^{\hilite[blue!50]{2}[circle]} + |
| 634 |
(\Delta z)^{\hilite[violet!45]{2}[circle]} |
| 635 |
\end{align*} |
| 636 |
\end{dispListing*} |
| 637 |
\begin{align*} |
| 638 |
(\Delta s)^2 &= -(\Delta t)^2 + (\Delta x)^2 + (\Delta y)^2 + |
| 639 |
(\Delta z)^2 \\ |
| 640 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rounded rectangle] + |
| 641 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 642 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[rectangle] + |
| 643 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 644 |
(\Delta s)^2 &= \hilite{-(\Delta t)^2 + (\Delta x)^2}[ellipse] + |
| 645 |
(\Delta y)^2 + (\Delta z)^2 \\ |
| 646 |
(\Delta s)^{\hilite{2}[circle]} &= \hilite[green]{-}[circle] |
| 647 |
(\Delta t)^{\hilite[cyan]{2}[circle]}+ |
| 648 |
(\Delta x)^{\hilite[orange]{2}[circle]} + |
| 649 |
(\Delta y)^{\hilite[blue!50]{2}[circle]} + |
| 650 |
(\Delta z)^{\hilite[violet!45]{2}[circle]} |
| 651 |
\end{align*} |
| 652 |
\begin{dispListing*}{sidebyside = false,listing only} |
| 653 |
\begin{align*} |
| 654 |
\Delta\vec{p} &= \vec{F}_{\sumup{net}}\Delta t \\ |
| 655 |
\hilite[orange]{\Delta\vec{p}}[circle] &= \vec{F}_{\symup{net}}\Delta t \\ |
| 656 |
\Delta\vec{p} &= \hilite[yellow!50]{\vec{F}_{\symup{net}}} |
| 657 |
[rounded rectangle]\Delta t \\ |
| 658 |
\Delta\vec{p} &= \vec{F}_{\symup{net}}\hilite[olive!50] |
| 659 |
{\Delta t}[rectangle] \\ |
| 660 |
\Delta\vec{p} &= \hilite[cyan!50]{\vec{F}_{\symup{net}}\Delta t} |
| 661 |
[ellipse] \\ |
| 662 |
\hilite{\Delta\vec{p}}[rectangle] &= \vec{F}_{\symup{net}}\Delta t |
| 663 |
\end{align*} |
| 664 |
\end{dispListing*} |
| 665 |
\begin{align*} |
| 666 |
\Delta\vec{p} &= \vec{F}_{\symup{net}}\Delta t \\ |
| 667 |
\hilite[orange]{\Delta\vec{p}}[circle] &= \vec{F}_{\symup{net}} |
| 668 |
\Delta t \\ |
| 669 |
\Delta\vec{p} &= \hilite[yellow!50]{\vec{F}_{\symup{net}}} |
| 670 |
[rounded rectangle]\Delta t \\ |
| 671 |
\Delta\vec{p} &= \vec{F}_{\symup{net}}\hilite[olive!50]{\Delta t} |
| 672 |
[rectangle] \\ |
| 673 |
\Delta\vec{p} &= \hilite[cyan!50]{\vec{F}_{\symup{net}}\Delta t} |
| 674 |
[ellipse] \\ |
| 675 |
\hilite{\Delta\vec{p}}[rectangle] &= \vec{F}_{\symup{net}}\Delta t |
| 676 |
\end{align*} |
| 677 |
%\iffalse |
| 678 |
%</example> |
| 679 |
%\fi |
| 680 |
% |
| 681 |
%\iffalse |
| 682 |
%<*example> |
| 683 |
%\fi |
| 684 |
\begin{docCommand}[doc updated = 2021-09-18]{image}{% |
| 685 |
\oarg{options}\marg{caption}\marg{label}\marg{image} |
| 686 |
}% |
| 687 |
Simplified interface for importing an image. The images are treated |
| 688 |
as floats, so they may not appear at the most logically intuitive |
| 689 |
place. |
| 690 |
\end{docCommand} |
| 691 |
\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent} |
| 692 |
\image[scale=0.20]{example-image-1x1} |
| 693 |
{Image shown 20 percent actual size.}{reffig1} |
| 694 |
\end{dispListing*} |
| 695 |
\image[scale=0.20]{example-image-1x1} |
| 696 |
{Image shown 20 percent actual size.}{reffig1} |
| 697 |
\begin{dispExample*}{sidebyside=false} |
| 698 |
Figure \ref{reffig1} is nice. |
| 699 |
It's captioned \nameref{reffig1} and is on page \pageref{reffig1}. |
| 700 |
\end{dispExample*} |
| 701 |
\begin{dispListing*}{sidebyside = false,listing only,verbatim ignore percent} |
| 702 |
\image[scale=0.20,angle=45]{example-image-1x1} |
| 703 |
{Image shown 20 percent actual size and rotated.}{reffig1} |
| 704 |
\end{dispListing*} |
| 705 |
\image[scale=0.20,angle=45]{example-image-1x1} |
| 706 |
{Image shown 20 percent actual size and rotated.}{reffig2} |
| 707 |
\begin{dispExample*}{sidebyside = false} |
| 708 |
Figure \ref{reffig2} is nice. |
| 709 |
It's captioned \nameref{reffig2} and is on page \pageref{reffig2}. |
| 710 |
\end{dispExample*} |
| 711 |
%\iffalse |
| 712 |
%</example> |
| 713 |
%\fi |
| 714 |
% |
| 715 |
% \subsection{Coordinate-Free and Index Notation} |
| 716 |
% |
| 717 |
% Beyond the current level of introductory physics, we need intelligent |
| 718 |
% commands for typesetting vector and tensor symbols and components |
| 719 |
% suitable for both coordinate-free and index notations. |
| 720 |
% |
| 721 |
%\iffalse |
| 722 |
%<*example> |
| 723 |
%\fi |
| 724 |
\begin{docCommands}[% |
| 725 |
doc parameter = \oarg{delimiter}\marg{\( c_{1},\dots,c_{n} \)},% |
| 726 |
]% |
| 727 |
{% |
| 728 |
{% |
| 729 |
doc name = colvec,% |
| 730 |
},% |
| 731 |
{% |
| 732 |
doc name = rowvec,% |
| 733 |
},% |
| 734 |
}% |
| 735 |
Typesets column vectors and row vectors as numeric or symbolic components. |
| 736 |
There can be more than three components. The delimiter used in the list of |
| 737 |
components can be specified; the default is a comma. Units are not |
| 738 |
supported, so these are mainly for symbolic work. |
| 739 |
\end{docCommands} |
| 740 |
\begin{dispExample} |
| 741 |
\[ \colvec{1,2,3} \] |
| 742 |
\[ \rowvec{1,2,3} \] |
| 743 |
\[ \colvec{x^{0},x^{1},x^{2},x^{3}} \] |
| 744 |
\[ \rowvec{x_{0},x_{1},x_{2},x_{3}} \] |
| 745 |
\end{dispExample} |
| 746 |
%\iffalse |
| 747 |
%</example> |
| 748 |
%\fi |
| 749 |
% |
| 750 |
%\iffalse |
| 751 |
%<*example> |
| 752 |
%\fi |
| 753 |
\begin{docCommands}[% |
| 754 |
doc parameter = \marg{symbol},% |
| 755 |
]% |
| 756 |
{% |
| 757 |
{% |
| 758 |
doc name = veccomp,% |
| 759 |
doc description = use this variant for coordinate-free vector notation,% |
| 760 |
},% |
| 761 |
{% |
| 762 |
doc name = veccomp*,% |
| 763 |
doc description = use this variant for index vector notation,% |
| 764 |
},% |
| 765 |
{% |
| 766 |
doc name = tencomp,% |
| 767 |
doc description = use this variant for coordinate-free tensor notation,% |
| 768 |
},% |
| 769 |
{% |
| 770 |
doc name = tencomp*,% |
| 771 |
doc description = use this variant for index tensor notation,% |
| 772 |
},% |
| 773 |
}% |
| 774 |
Conforms to ISO 80000-2 notation. |
| 775 |
\end{docCommands} |
| 776 |
\begin{dispExample} |
| 777 |
\( \veccomp{r} \) \\ |
| 778 |
\( \veccomp*{r} \) \\ |
| 779 |
\( \tencomp{r} \) \\ |
| 780 |
\( \tencomp*{r} \) |
| 781 |
\end{dispExample} |
| 782 |
%\iffalse |
| 783 |
%</example> |
| 784 |
%\fi |
| 785 |
% |
| 786 |
%\iffalse |
| 787 |
%<*example> |
| 788 |
%\fi |
| 789 |
\begin{docCommands}[% |
| 790 |
doc parameter = \marg{index}\marg{index},% |
| 791 |
]% |
| 792 |
{% |
| 793 |
{% |
| 794 |
doc name = valence,% |
| 795 |
},% |
| 796 |
{% |
| 797 |
doc name = valence*,% |
| 798 |
},% |
| 799 |
}% |
| 800 |
Typesets tensor valence. The starred variant typesets it horizontally. |
| 801 |
\end{docCommands} |
| 802 |
\begin{dispExample} |
| 803 |
A vector is a \( \valence{1}{0} \) tensor. \\ |
| 804 |
A vector is a \( \valence*{1}{0} \) tensor. |
| 805 |
\end{dispExample} |
| 806 |
%\iffalse |
| 807 |
%</example> |
| 808 |
%\fi |
| 809 |
% |
| 810 |
%\iffalse |
| 811 |
%<*example> |
| 812 |
%\fi |
| 813 |
\begin{docCommands}[% |
| 814 |
doc parameter = \marg{slot,slot},% |
| 815 |
]% |
| 816 |
{% |
| 817 |
{% |
| 818 |
doc name = contraction,% |
| 819 |
},% |
| 820 |
{% |
| 821 |
doc name = contraction*,% |
| 822 |
},% |
| 823 |
}% |
| 824 |
Typesets tensor contraction in coordinate-free notation. There |
| 825 |
is no standard for this so we assert one here. |
| 826 |
\end{docCommands} |
| 827 |
\begin{dispExample} |
| 828 |
\( \contraction{1,2} \) \\ |
| 829 |
\( \contraction*{1,2} \) |
| 830 |
\end{dispExample} |
| 831 |
%\iffalse |
| 832 |
%</example> |
| 833 |
%\fi |
| 834 |
% |
| 835 |
%\iffalse |
| 836 |
%<*example> |
| 837 |
%\fi |
| 838 |
\begin{docCommands}% |
| 839 |
{% |
| 840 |
{% |
| 841 |
doc name = slot,% |
| 842 |
doc parameter = \oarg{vector},% |
| 843 |
},% |
| 844 |
{% |
| 845 |
doc name = slot*,% |
| 846 |
doc parameter = \oarg{vector},% |
| 847 |
},% |
| 848 |
}% |
| 849 |
An intelligent slot command for coordinate-free vector |
| 850 |
and tensor notation. The starred variants suppress the |
| 851 |
underscore. |
| 852 |
\end{docCommands} |
| 853 |
\begin{dispExample} |
| 854 |
\( (\slot) \) \\ |
| 855 |
\( (\slot[\vec{a}]) \) \\ |
| 856 |
\( (\slot*) \) \\ |
| 857 |
\( (\slot*[\vec{a}]) \) |
| 858 |
\end{dispExample} |
| 859 |
%\iffalse |
| 860 |
%</example> |
| 861 |
%\fi |
| 862 |
% |
| 863 |
% \changes{v3.1.0}{2022-01-27} |
| 864 |
% {\linktoplace{sec:mandib}{mandistudent} \cs{diff} renamed to |
| 865 |
% \refCom{df} for compatibility with the \pkg{numerica} package} |
| 866 |
%\iffalse |
| 867 |
%<*example> |
| 868 |
%\fi |
| 869 |
\begin{docCommand}[doc updated = 2022-01-27]{df}{}% |
| 870 |
Intelligent differential and exterior derivative |
| 871 |
operator. |
| 872 |
\end{docCommand} |
| 873 |
\begin{dispExample} |
| 874 |
\[ |
| 875 |
\int x\,dx |
| 876 |
\] |
| 877 |
\[ |
| 878 |
\int x\,\df{x} |
| 879 |
\] |
| 880 |
\[ |
| 881 |
\int x\,\df*{x} |
| 882 |
\] |
| 883 |
\end{dispExample} |
| 884 |
%\iffalse |
| 885 |
%</example> |
| 886 |
%\fi |
| 887 |
% |
| 888 |
% \changes{v3.1.0}{2022-01-27} |
| 889 |
% {\linktoplace{sec:mandib}{mandistudent} All instances of |
| 890 |
% \texttt{GlowScript} have been changed to \texttt{Web VPython}} |
| 891 |
% \subsection{\WebVPython{} and \VPython{} Program Listings} |
| 892 |
% |
| 893 |
% \href{https://\gsurl}{\WebVPython} |
| 894 |
% \footnote{On November 9, 2021 \texttt{GlowScript} was renamed to |
| 895 |
% \WebVPython. The website was changed to |
| 896 |
% \href{https://\gsurl}{https://\gsurl}.} |
| 897 |
% and |
| 898 |
% \href{https://\vpurl}{VPython}\footnote{\href{https://\vpurl}{https://\vpurl}} |
| 899 |
% are programming environments (both use \href{https://www.python.org}{Python}) |
| 900 |
% frequently used in introductory physics to introduce students |
| 901 |
% for modeling physical systems. \mandi{} makes including code listings |
| 902 |
% very simple for students. |
| 903 |
% |
| 904 |
% \subsection{The \texttt{\small webvpythonblock} Environment} |
| 905 |
% |
| 906 |
%\iffalse |
| 907 |
%<*example> |
| 908 |
%\fi |
| 909 |
\begin{docEnvironments}[% |
| 910 |
doc parameter = {\oarg{options}(\meta{link})\marg{caption}},% |
| 911 |
doclang/environment content=WebVPython code,% |
| 912 |
]% |
| 913 |
{% |
| 914 |
{% |
| 915 |
doc updated = 2023-08-01,% |
| 916 |
doc name = webvpythonblock,% |
| 917 |
doc description = now includes a QR code,% |
| 918 |
},% |
| 919 |
{% |
| 920 |
doc updated = 2023-08-01,% |
| 921 |
doc name = webvpythonblock*,% |
| 922 |
doc description = use this variant to omit QR code,% |
| 923 |
},% |
| 924 |
}% |
| 925 |
Code placed here is nicely formatted and optionally linked to its source on |
| 926 |
\href{https://\gsurl}{\WebVPythonorg}, which must be in a public (not private) |
| 927 |
folder. Clicking anywhere in the code window (between the black horizontal bars) |
| 928 |
or on the URL will open the link in the default browser. A caption is mandatory, |
| 929 |
and a label is internally generated. The listing always begins on a new page. |
| 930 |
A URL shortening utility is recommended to keep the URL from getting unruly |
| 931 |
especially if it generates an overfull box error. For convenience, |https://| |
| 932 |
is automatically prepended to the URL and can be omitted. The |#| character |
| 933 |
in a URL should not cause problems. The default URL is that of the \WebVPython{} |
| 934 |
home page. |
| 935 |
\end{docEnvironments} |
| 936 |
\begin{dispListing*}{sidebyside = false} |
| 937 |
\begin{webvpythonblock} |
| 938 |
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo) |
| 939 |
{Example With QR Code} |
| 940 |
Web VPython 3.2 |
| 941 |
|
| 942 |
scene.width = 400 |
| 943 |
scene.height = 760 |
| 944 |
# constants and data |
| 945 |
g = 9.8 # m/s^2 |
| 946 |
mball = 0.03 # kg |
| 947 |
Lo = 0.26 # m |
| 948 |
ks = 1.8 # N/m |
| 949 |
deltat = 0.01 # s |
| 950 |
|
| 951 |
# objects (origin is at ceiling) |
| 952 |
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, |
| 953 |
width=0.2) |
| 954 |
ball = sphere(pos=vector(0,-0.3,0),radius=0.025, |
| 955 |
color=color.orange) |
| 956 |
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, |
| 957 |
color=color.cyan,thickness=0.003,coils=40, |
| 958 |
radius=0.010) |
| 959 |
|
| 960 |
# initial values |
| 961 |
pball = mball * vector(0,0,0) # kg m/s |
| 962 |
Fgrav = mball * g * vector(0,-1,0) # N |
| 963 |
t = 0 |
| 964 |
|
| 965 |
# improve the display |
| 966 |
scene.autoscale = False # turn off automatic camera zoom |
| 967 |
scene.center = vector(0,-Lo,0) # move camera down |
| 968 |
scene.waitfor('click') # wait for a mouse click |
| 969 |
|
| 970 |
# initial calculation loop |
| 971 |
# calculation loop |
| 972 |
while t < 10: |
| 973 |
rate(100) |
| 974 |
# we need the stretch |
| 975 |
s = mag(ball.pos) - Lo |
| 976 |
# we need the spring force |
| 977 |
Fspring = ks * s * -norm(spring.axis) |
| 978 |
Fnet = Fgrav + Fspring |
| 979 |
pball = pball + Fnet * deltat |
| 980 |
ball.pos = ball.pos + (pball / mball) * deltat |
| 981 |
spring.axis = ball.pos - ceiling.pos |
| 982 |
t = t + deltat |
| 983 |
\end{webvpythonblock} |
| 984 |
\end{dispListing*} |
| 985 |
\begin{webvpythonblock} |
| 986 |
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo) |
| 987 |
{Example With QR Code} |
| 988 |
Web VPython 3.2 |
| 989 |
|
| 990 |
scene.width = 400 |
| 991 |
scene.height = 760 |
| 992 |
# constants and data |
| 993 |
g = 9.8 # m/s^2 |
| 994 |
mball = 0.03 # kg |
| 995 |
Lo = 0.26 # m |
| 996 |
ks = 1.8 # N/m |
| 997 |
deltat = 0.01 # s |
| 998 |
|
| 999 |
# objects (origin is at ceiling) |
| 1000 |
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, |
| 1001 |
width=0.2) |
| 1002 |
ball = sphere(pos=vector(0,-0.3,0),radius=0.025, |
| 1003 |
color=color.orange) |
| 1004 |
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, |
| 1005 |
color=color.cyan,thickness=0.003,coils=40, |
| 1006 |
radius=0.010) |
| 1007 |
|
| 1008 |
# initial values |
| 1009 |
pball = mball * vector(0,0,0) # kg m/s |
| 1010 |
Fgrav = mball * g * vector(0,-1,0) # N |
| 1011 |
t = 0 |
| 1012 |
|
| 1013 |
# improve the display |
| 1014 |
scene.autoscale = False # turn off automatic camera zoom |
| 1015 |
scene.center = vector(0,-Lo,0) # move camera down |
| 1016 |
scene.waitfor('click') # wait for a mouse click |
| 1017 |
|
| 1018 |
# initial calculation loop |
| 1019 |
# calculation loop |
| 1020 |
while t < 10: |
| 1021 |
rate(100) |
| 1022 |
# we need the stretch |
| 1023 |
s = mag(ball.pos) - Lo |
| 1024 |
# we need the spring force |
| 1025 |
Fspring = ks * s * -norm(spring.axis) |
| 1026 |
Fnet = Fgrav + Fspring |
| 1027 |
pball = pball + Fnet * deltat |
| 1028 |
ball.pos = ball.pos + (pball / mball) * deltat |
| 1029 |
spring.axis = ball.pos - ceiling.pos |
| 1030 |
t = t + deltat |
| 1031 |
\end{webvpythonblock} |
| 1032 |
% |
| 1033 |
%\iffalse |
| 1034 |
%</example> |
| 1035 |
%\fi |
| 1036 |
% |
| 1037 |
% \newpage |
| 1038 |
% Here is how one would reference this program elsewhere. Notice the |
| 1039 |
% references are numbered sequentially within the document. |
| 1040 |
% |
| 1041 |
%\iffalse |
| 1042 |
%<*example> |
| 1043 |
%\fi |
| 1044 |
\begin{dispExample*}{sidebyside = false} |
| 1045 |
\WebVPython{} program \ref{gs:1} is nice. |
| 1046 |
It's called \nameref{gs:1} and is on page \pageref{gs:1}. |
| 1047 |
\end{dispExample*} |
| 1048 |
%\iffalse |
| 1049 |
%</example> |
| 1050 |
%\fi |
| 1051 |
% |
| 1052 |
% \newpage |
| 1053 |
% |
| 1054 |
%\iffalse |
| 1055 |
%<*example> |
| 1056 |
%\fi |
| 1057 |
\begin{dispListing*}{sidebyside = false} |
| 1058 |
\begin{webvpythonblock*} |
| 1059 |
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo) |
| 1060 |
{Example Without QR Code} |
| 1061 |
Web VPython 3.2 |
| 1062 |
|
| 1063 |
scene.width = 400 |
| 1064 |
scene.height = 760 |
| 1065 |
# constants and data |
| 1066 |
g = 9.8 # m/s^2 |
| 1067 |
mball = 0.03 # kg |
| 1068 |
Lo = 0.26 # m |
| 1069 |
ks = 1.8 # N/m |
| 1070 |
deltat = 0.01 # s |
| 1071 |
|
| 1072 |
# objects (origin is at ceiling) |
| 1073 |
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, |
| 1074 |
width=0.2) |
| 1075 |
ball = sphere(pos=vector(0,-0.3,0),radius=0.025, |
| 1076 |
color=color.orange) |
| 1077 |
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, |
| 1078 |
color=color.cyan,thickness=0.003,coils=40, |
| 1079 |
radius=0.010) |
| 1080 |
|
| 1081 |
# initial values |
| 1082 |
pball = mball * vector(0,0,0) # kg m/s |
| 1083 |
Fgrav = mball * g * vector(0,-1,0) # N |
| 1084 |
t = 0 |
| 1085 |
|
| 1086 |
# improve the display |
| 1087 |
scene.autoscale = False # turn off automatic camera zoom |
| 1088 |
scene.center = vector(0,-Lo,0) # move camera down |
| 1089 |
scene.waitfor('click') # wait for a mouse click |
| 1090 |
|
| 1091 |
# initial calculation loop |
| 1092 |
# calculation loop |
| 1093 |
while t < 10: |
| 1094 |
rate(100) |
| 1095 |
# we need the stretch |
| 1096 |
s = mag(ball.pos) - Lo |
| 1097 |
# we need the spring force |
| 1098 |
Fspring = ks * s * -norm(spring.axis) |
| 1099 |
Fnet = Fgrav + Fspring |
| 1100 |
pball = pball + Fnet * deltat |
| 1101 |
ball.pos = ball.pos + (pball / mball) * deltat |
| 1102 |
spring.axis = ball.pos - ceiling.pos |
| 1103 |
t = t + deltat |
| 1104 |
\end{webvpythonblock*} |
| 1105 |
\end{dispListing*} |
| 1106 |
\begin{webvpythonblock*} |
| 1107 |
(glowscript.org/#/user/heafnerj/folder/mandidemo/program/mandidemo) |
| 1108 |
{Example Without QR Code} |
| 1109 |
Web VPython 3.2 |
| 1110 |
|
| 1111 |
scene.width = 400 |
| 1112 |
scene.height = 760 |
| 1113 |
# constants and data |
| 1114 |
g = 9.8 # m/s^2 |
| 1115 |
mball = 0.03 # kg |
| 1116 |
Lo = 0.26 # m |
| 1117 |
ks = 1.8 # N/m |
| 1118 |
deltat = 0.01 # s |
| 1119 |
|
| 1120 |
# objects (origin is at ceiling) |
| 1121 |
ceiling = box(pos=vector(0,0,0), length=0.2, height=0.01, |
| 1122 |
width=0.2) |
| 1123 |
ball = sphere(pos=vector(0,-0.3,0),radius=0.025, |
| 1124 |
color=color.orange) |
| 1125 |
spring = helix(pos=ceiling.pos, axis=ball.pos-ceiling.pos, |
| 1126 |
color=color.cyan,thickness=0.003,coils=40, |
| 1127 |
radius=0.010) |
| 1128 |
|
| 1129 |
# initial values |
| 1130 |
pball = mball * vector(0,0,0) # kg m/s |
| 1131 |
Fgrav = mball * g * vector(0,-1,0) # N |
| 1132 |
t = 0 |
| 1133 |
|
| 1134 |
# improve the display |
| 1135 |
scene.autoscale = False # turn off automatic camera zoom |
| 1136 |
scene.center = vector(0,-Lo,0) # move camera down |
| 1137 |
scene.waitfor('click') # wait for a mouse click |
| 1138 |
|
| 1139 |
# initial calculation loop |
| 1140 |
# calculation loop |
| 1141 |
while t < 10: |
| 1142 |
rate(100) |
| 1143 |
# we need the stretch |
| 1144 |
s = mag(ball.pos) - Lo |
| 1145 |
# we need the spring force |
| 1146 |
Fspring = ks * s * -norm(spring.axis) |
| 1147 |
Fnet = Fgrav + Fspring |
| 1148 |
pball = pball + Fnet * deltat |
| 1149 |
ball.pos = ball.pos + (pball / mball) * deltat |
| 1150 |
spring.axis = ball.pos - ceiling.pos |
| 1151 |
t = t + deltat |
| 1152 |
\end{webvpythonblock*} |
| 1153 |
\begin{dispExample*}{sidebyside = false} |
| 1154 |
\WebVPython{} program \ref{gs:2} is nice. |
| 1155 |
It's called \nameref{gs:2} and is on page \pageref{gs:2}. |
| 1156 |
\end{dispExample*} |
| 1157 |
% |
| 1158 |
%\iffalse |
| 1159 |
%</example> |
| 1160 |
%\fi |
| 1161 |
% |
| 1162 |
% \subsection{The \texttt{\small vpythonfile} Command} |
| 1163 |
% |
| 1164 |
%\iffalse |
| 1165 |
%<*example> |
| 1166 |
%\fi |
| 1167 |
\begin{docCommand}[doc updated = 2023-08-01]{vpythonfile} |
| 1168 |
{\oarg{options}(\meta{link})\marg{file}\marg{caption}} |
| 1169 |
Command to load and typeset a \VPython{} program, read from local file |
| 1170 |
\marg{file}. Clicking anywhere in the code window (between the black |
| 1171 |
horizontal bars) or on the URL will open the link in the default browser. |
| 1172 |
A caption is mandatory, and a label is internally generated. The listing |
| 1173 |
always begins on a new page. A URL shortening utility is recommended to |
| 1174 |
keep the URL from getting unruly especially if it generates an overfull |
| 1175 |
box error. For convenience, |https://| is automatically prepended to the |
| 1176 |
URL and can be omitted. The default URL is that of the \VPython{} home page. |
| 1177 |
\end{docCommand} |
| 1178 |
\begin{dispListing*}{sidebyside = false} |
| 1179 |
\vpythonfile{vdemo.py}{A \VPython{} Program} |
| 1180 |
\end{dispListing*} |
| 1181 |
\vpythonfile{vdemo.py}{A \VPython{} Program} |
| 1182 |
%\iffalse |
| 1183 |
%</example> |
| 1184 |
%\fi |
| 1185 |
% |
| 1186 |
%\iffalse |
| 1187 |
%<*example> |
| 1188 |
%\fi |
| 1189 |
\begin{dispExample*}{sidebyside = false} |
| 1190 |
\VPython{} program \ref{vp:1} is nice. |
| 1191 |
It's called \nameref{vp:1} and is on page \pageref{vp:1}. |
| 1192 |
\end{dispExample*} |
| 1193 |
% |
| 1194 |
%\iffalse |
| 1195 |
%</example> |
| 1196 |
%\fi |
| 1197 |
% |
| 1198 |
% \subsection{The \texttt{\small webvpythoninline} and |
| 1199 |
% \texttt{\small vpythoninline} Commands} |
| 1200 |
% |
| 1201 |
%\iffalse |
| 1202 |
%<*example> |
| 1203 |
%\fi |
| 1204 |
\begin{docCommands}[% |
| 1205 |
doc updated = 2021-02-26,% |
| 1206 |
]% |
| 1207 |
{% |
| 1208 |
{% |
| 1209 |
doc name = webvpythoninline,% |
| 1210 |
doc parameter = \marg{Web VPython code},% |
| 1211 |
},% |
| 1212 |
{% |
| 1213 |
doc name = vpythoninline,% |
| 1214 |
doc parameter = \marg{VPython code},% |
| 1215 |
},% |
| 1216 |
}% |
| 1217 |
Typesets a small, in-line snippet of code. The snippet should be |
| 1218 |
less than one line long. |
| 1219 |
\end{docCommands} |
| 1220 |
\begin{dispExample*}{sidebyside = false} |
| 1221 |
\WebVPython{} programs begin with \webvpythoninline{Web VPython 3.2}. |
| 1222 |
\end{dispExample*} |
| 1223 |
\begin{dispExample*}{sidebyside = false} |
| 1224 |
\VPython{} programs begin with \vpythoninline{from vpython import *}. |
| 1225 |
\end{dispExample*} |
| 1226 |
%\iffalse |
| 1227 |
%</example> |
| 1228 |
%\fi |
| 1229 |
% |
| 1230 |
% \MaybeStop{} |
| 1231 |
% |
| 1232 |
% \newgeometry{left=0.50in,right=0.50in,top=1.00in,bottom=1.00in} |
| 1233 |
% \subsection{\mandistudent{} Source Code} |
| 1234 |
% |
| 1235 |
% \iffalse |
| 1236 |
%<*package> |
| 1237 |
% \fi |
| 1238 |
% Definine the package version and date for global use, exploiting the fact |
| 1239 |
% that in a \pkg{.sty} file there is now no need for |\makeatletter| and |
| 1240 |
% |\makeatother|. This simplifies defining internal commands, with |@| |
| 1241 |
% in the name, that are not for the user to know about. |
| 1242 |
% |
| 1243 |
% \changes{v3.1.0}{2022-01-27} |
| 1244 |
% {\linktoplace{sec:mandib}{mandistudent} Version number works} |
| 1245 |
% \begin{macrocode} |
| 1246 |
\def\mandistudent@version{3.2.2} |
| 1247 |
\def\mandistudent@date{2024-02-27} |
| 1248 |
\NeedsTeXFormat{LaTeX2e}[2020-02-02] |
| 1249 |
\DeclareRelease{v3.2.2}{2024-02-27}{mandistudent.sty} |
| 1250 |
\DeclareCurrentRelease{v\mandistudent@version}{\mandistudent@date} |
| 1251 |
\ProvidesPackage{mandistudent} |
| 1252 |
[\mandistudent@date\space v\mandistudent@version\space Macros for introductory physics] |
| 1253 |
% \end{macrocode} |
| 1254 |
% |
| 1255 |
% Define a convenient package version command. |
| 1256 |
% |
| 1257 |
% \begin{macrocode} |
| 1258 |
\newcommand*{\mandistudentversion}{v\mandistudent@version\space dated \mandistudent@date} |
| 1259 |
% \end{macrocode} |
| 1260 |
% |
| 1261 |
% Load third party packages, documenting why each one is needed. |
| 1262 |
% |
| 1263 |
% AMS goodness. Don't load \pkg{amssymb} or \pkg{amsfonts}. |
| 1264 |
% |
| 1265 |
% \begin{macrocode} |
| 1266 |
\RequirePackage{amsmath} |
| 1267 |
% \end{macrocode} |
| 1268 |
% |
| 1269 |
% We need \pkg{enumitem} for the |physicsproblem| environment. |
| 1270 |
% |
| 1271 |
% \textsc{beamer} is not compatible with \pkg{enumitem} so if |
| 1272 |
% \textsc{beamer} is loaded certain commands are not defined. |
| 1273 |
% |
| 1274 |
% \begin{macrocode} |
| 1275 |
\IfClassLoadedTF{beamer}% |
| 1276 |
{}% |
| 1277 |
{% |
| 1278 |
\RequirePackage[inline]{enumitem}% |
| 1279 |
}% |
| 1280 |
% \end{macrocode} |
| 1281 |
% |
| 1282 |
% We need \pkg{eso-pic} for |\hilite|. |
| 1283 |
% |
| 1284 |
% \begin{macrocode} |
| 1285 |
\RequirePackage{eso-pic} |
| 1286 |
% \end{macrocode} |
| 1287 |
% |
| 1288 |
% We need \pkg{esvect} for nice vector arrows, style g. |
| 1289 |
% |
| 1290 |
% \begin{macrocode} |
| 1291 |
\RequirePackage[g]{esvect} |
| 1292 |
% \end{macrocode} |
| 1293 |
% |
| 1294 |
% We need \pkg{pgfopts} for a key-value interface. |
| 1295 |
% |
| 1296 |
% \begin{macrocode} |
| 1297 |
\RequirePackage{pgfopts} |
| 1298 |
% \end{macrocode} |
| 1299 |
% |
| 1300 |
% We need \pkg{iftex} so we can require \lualatex. |
| 1301 |
% |
| 1302 |
% \begin{macrocode} |
| 1303 |
\RequirePackage{iftex} |
| 1304 |
% \end{macrocode} |
| 1305 |
% |
| 1306 |
% We need \pkg{makebox} for consistent |\dirvect| notation. |
| 1307 |
% |
| 1308 |
% \begin{macrocode} |
| 1309 |
\RequirePackage{makebox} |
| 1310 |
% \end{macrocode} |
| 1311 |
% |
| 1312 |
% We need \mandi{} to load \pkg{mathtools} and \pkg{unicode-math}. |
| 1313 |
% |
| 1314 |
% \begin{macrocode} |
| 1315 |
\IfPackageLoadedTF{mandi}% |
| 1316 |
{}% |
| 1317 |
{% |
| 1318 |
\RequirePackage{mandi}% |
| 1319 |
}% |
| 1320 |
% \end{macrocode} |
| 1321 |
% |
| 1322 |
% We need \pkg{nicematrix} for column and row vectors. |
| 1323 |
% |
| 1324 |
% \begin{macrocode} |
| 1325 |
\RequirePackage{nicematrix} |
| 1326 |
% \end{macrocode} |
| 1327 |
% |
| 1328 |
% We need \pkg{qrcode} for QR codes in |webvpythonblock|. |
| 1329 |
% |
| 1330 |
% \begin{macrocode} |
| 1331 |
\RequirePackage{qrcode} |
| 1332 |
% \end{macrocode} |
| 1333 |
% |
| 1334 |
% Set the default size for QR codes. |
| 1335 |
% |
| 1336 |
% \begin{macrocode} |
| 1337 |
\qrset{height=1.5cm} |
| 1338 |
% \end{macrocode} |
| 1339 |
% |
| 1340 |
% We need \pkg{tcolorbox} for program listings. |
| 1341 |
% |
| 1342 |
% \begin{macrocode} |
| 1343 |
\RequirePackage[most]{tcolorbox} |
| 1344 |
% \end{macrocode} |
| 1345 |
% |
| 1346 |
% We need \pkg{tensor} for index notation. |
| 1347 |
% |
| 1348 |
% \begin{macrocode} |
| 1349 |
\RequirePackage{tensor} |
| 1350 |
% \end{macrocode} |
| 1351 |
% \begin{macrocode} |
| 1352 |
% |
| 1353 |
% We need \pkg{tikz} for |\hilite|.. |
| 1354 |
% |
| 1355 |
\RequirePackage{tikz} |
| 1356 |
\usetikzlibrary{shapes,fit,tikzmark} |
| 1357 |
% \end{macrocode} |
| 1358 |
% |
| 1359 |
% Load \pkg{xparse} if necessary. |
| 1360 |
% |
| 1361 |
% \begin{macrocode} |
| 1362 |
\IfFormatAtLeastTF{2020-10-01} |
| 1363 |
{}% |
| 1364 |
{\RequirePackage{xparse}}% |
| 1365 |
% \end{macrocode} |
| 1366 |
% |
| 1367 |
% Always load \pkg{hyperref} last if possible. |
| 1368 |
% |
| 1369 |
% \begin{macrocode} |
| 1370 |
\RequirePackage{hyperref} |
| 1371 |
% \end{macrocode} |
| 1372 |
% |
| 1373 |
% We require the \lualatex{} engine. |
| 1374 |
% |
| 1375 |
% \begin{macrocode} |
| 1376 |
\RequireLuaTeX |
| 1377 |
% \end{macrocode} |
| 1378 |
% |
| 1379 |
% Set up the fonts to be consistent with ISO 80000-2 notation. |
| 1380 |
% The \href{https://www.ctan.org/pkg/unicode-math}{\pkg{unicode-math}} package |
| 1381 |
% loads the \href{https://www.ctan.org/pkg/fontspec}{\pkg{fontspec}} and |
| 1382 |
% \href{https://www.ctan.org/pkg/xparse}{\pkg{xparse}} |
| 1383 |
% packages. Note that \pkg{xparse} is now part of the \LaTeXe{} kernel. |
| 1384 |
% Because \pkg{unicode-math} is required, all documents using \mandi{} must |
| 1385 |
% be compiled with an engine that supports Unicode, and I recommend \lualatex. |
| 1386 |
% |
| 1387 |
% \begin{macrocode} |
| 1388 |
\unimathsetup{math-style=ISO} |
| 1389 |
% \end{macrocode} |
| 1390 |
% |
| 1391 |
% Use normal math letters from Latin Modern Math for familiarity with |
| 1392 |
% textbooks. This gives a better J. |
| 1393 |
% |
| 1394 |
% \begin{macrocode} |
| 1395 |
\setmathfont[Scale=MatchLowercase] |
| 1396 |
{Latin Modern Math} |
| 1397 |
% \end{macrocode} |
| 1398 |
% |
| 1399 |
% Borrow from TeX Gyre DejaVu Math for vectors and tensors to get |
| 1400 |
% single-storey lowercase g. |
| 1401 |
% |
| 1402 |
% \begin{macrocode} |
| 1403 |
\setmathfont[Scale=MatchLowercase,range={sfit/{latin},bfsfit/{latin}}] |
| 1404 |
{TeX Gyre DejaVu Math} |
| 1405 |
% \end{macrocode} |
| 1406 |
% |
| 1407 |
% Borrow from TeX Gyre DejaVu Math to get single-storey lowercase g. |
| 1408 |
% |
| 1409 |
% \begin{macrocode} |
| 1410 |
\setmathfont[Scale=MatchLowercase,range={sfup/{latin},bfsfup/{latin}}] |
| 1411 |
{TeX Gyre DejaVu Math} |
| 1412 |
% \end{macrocode} |
| 1413 |
% |
| 1414 |
% Borrow |mathscr| and |mathbfscr| from XITS Math.\newline |
| 1415 |
% See \url{https://tex.stackexchange.com/a/120073/218142}. |
| 1416 |
% |
| 1417 |
% \begin{macrocode} |
| 1418 |
\setmathfont[Scale=MatchLowercase,range={\mathscr,\mathbfscr}]{XITS Math} |
| 1419 |
% \end{macrocode} |
| 1420 |
% |
| 1421 |
% Get original and bold |mathcal| fonts.\newline |
| 1422 |
% See \url{https://tex.stackexchange.com/a/21742/218142}. |
| 1423 |
% |
| 1424 |
% \begin{macrocode} |
| 1425 |
\setmathfont[Scale=MatchLowercase,range={\mathcal,\mathbfcal},StylisticSet=1]{XITS Math} |
| 1426 |
% \end{macrocode} |
| 1427 |
% |
| 1428 |
% Borrow Greek |sfup| and |sfit| letters from STIX Two Math. |
| 1429 |
% Since this isn't officially supported in \pkg{unicode-math} |
| 1430 |
% we have to manually set this up. |
| 1431 |
% |
| 1432 |
% \begin{macrocode} |
| 1433 |
\setmathfont[Scale=MatchLowercase,range={"E17C-"E1F6}]{STIX Two Math} |
| 1434 |
\newfontfamily{\symsfgreek}{STIX Two Math} |
| 1435 |
% \end{macrocode} |
| 1436 |
% |
| 1437 |
% I don't understand why |\text{...}| is necessary. |
| 1438 |
% |
| 1439 |
% \begin{macrocode} |
| 1440 |
\newcommand{\symsfupalpha} {\text{\symsfgreek{^^^^e196}}} |
| 1441 |
\newcommand{\symsfupbeta} {\text{\symsfgreek{^^^^e197}}} |
| 1442 |
\newcommand{\symsfupgamma} {\text{\symsfgreek{^^^^e198}}} |
| 1443 |
\newcommand{\symsfupdelta} {\text{\symsfgreek{^^^^e199}}} |
| 1444 |
\newcommand{\symsfupepsilon} {\text{\symsfgreek{^^^^e1af}}} |
| 1445 |
\newcommand{\symsfupvarepsilon} {\text{\symsfgreek{^^^^e19a}}} |
| 1446 |
\newcommand{\symsfupzeta} {\text{\symsfgreek{^^^^e19b}}} |
| 1447 |
\newcommand{\symsfupeta} {\text{\symsfgreek{^^^^e19c}}} |
| 1448 |
\newcommand{\symsfuptheta} {\text{\symsfgreek{^^^^e19d}}} |
| 1449 |
\newcommand{\symsfupvartheta} {\text{\symsfgreek{^^^^e1b0}}} |
| 1450 |
\newcommand{\symsfupiota} {\text{\symsfgreek{^^^^e19e}}} |
| 1451 |
\newcommand{\symsfupkappa} {\text{\symsfgreek{^^^^e19f}}} |
| 1452 |
\newcommand{\symsfuplambda} {\text{\symsfgreek{^^^^e1a0}}} |
| 1453 |
\newcommand{\symsfupmu} {\text{\symsfgreek{^^^^e1a1}}} |
| 1454 |
\newcommand{\symsfupnu} {\text{\symsfgreek{^^^^e1a2}}} |
| 1455 |
\newcommand{\symsfupxi} {\text{\symsfgreek{^^^^e1a3}}} |
| 1456 |
\newcommand{\symsfupomicron} {\text{\symsfgreek{^^^^e1a4}}} |
| 1457 |
\newcommand{\symsfuppi} {\text{\symsfgreek{^^^^e1a5}}} |
| 1458 |
\newcommand{\symsfupvarpi} {\text{\symsfgreek{^^^^e1b3}}} |
| 1459 |
\newcommand{\symsfuprho} {\text{\symsfgreek{^^^^e1a6}}} |
| 1460 |
\newcommand{\symsfupvarrho} {\text{\symsfgreek{^^^^e1b2}}} |
| 1461 |
\newcommand{\symsfupsigma} {\text{\symsfgreek{^^^^e1a8}}} |
| 1462 |
\newcommand{\symsfupvarsigma} {\text{\symsfgreek{^^^^e1a7}}} |
| 1463 |
\newcommand{\symsfuptau} {\text{\symsfgreek{^^^^e1a9}}} |
| 1464 |
\newcommand{\symsfupupsilon} {\text{\symsfgreek{^^^^e1aa}}} |
| 1465 |
\newcommand{\symsfupphi} {\text{\symsfgreek{^^^^e1b1}}} |
| 1466 |
\newcommand{\symsfupvarphi} {\text{\symsfgreek{^^^^e1ab}}} |
| 1467 |
\newcommand{\symsfupchi} {\text{\symsfgreek{^^^^e1ac}}} |
| 1468 |
\newcommand{\symsfuppsi} {\text{\symsfgreek{^^^^e1ad}}} |
| 1469 |
\newcommand{\symsfupomega} {\text{\symsfgreek{^^^^e1ae}}} |
| 1470 |
\newcommand{\symsfupDelta} {\text{\symsfgreek{^^^^e180}}} |
| 1471 |
\newcommand{\symsfupGamma} {\text{\symsfgreek{^^^^e17f}}} |
| 1472 |
\newcommand{\symsfupTheta} {\text{\symsfgreek{^^^^e18e}}} |
| 1473 |
\newcommand{\symsfupLambda} {\text{\symsfgreek{^^^^e187}}} |
| 1474 |
\newcommand{\symsfupXi} {\text{\symsfgreek{^^^^e18a}}} |
| 1475 |
\newcommand{\symsfupPi} {\text{\symsfgreek{^^^^e18c}}} |
| 1476 |
\newcommand{\symsfupSigma} {\text{\symsfgreek{^^^^e18f}}} |
| 1477 |
\newcommand{\symsfupUpsilon} {\text{\symsfgreek{^^^^e191}}} |
| 1478 |
\newcommand{\symsfupPhi} {\text{\symsfgreek{^^^^e192}}} |
| 1479 |
\newcommand{\symsfupPsi} {\text{\symsfgreek{^^^^e194}}} |
| 1480 |
\newcommand{\symsfupOmega} {\text{\symsfgreek{^^^^e195}}} |
| 1481 |
\newcommand{\symsfitalpha} {\text{\symsfgreek{^^^^e1d8}}} |
| 1482 |
\newcommand{\symsfitbeta} {\text{\symsfgreek{^^^^e1d9}}} |
| 1483 |
\newcommand{\symsfitgamma} {\text{\symsfgreek{^^^^e1da}}} |
| 1484 |
\newcommand{\symsfitdelta} {\text{\symsfgreek{^^^^e1db}}} |
| 1485 |
\newcommand{\symsfitepsilon} {\text{\symsfgreek{^^^^e1f1}}} |
| 1486 |
\newcommand{\symsfitvarepsilon} {\text{\symsfgreek{^^^^e1dc}}} |
| 1487 |
\newcommand{\symsfitzeta} {\text{\symsfgreek{^^^^e1dd}}} |
| 1488 |
\newcommand{\symsfiteta} {\text{\symsfgreek{^^^^e1de}}} |
| 1489 |
\newcommand{\symsfittheta} {\text{\symsfgreek{^^^^e1df}}} |
| 1490 |
\newcommand{\symsfitvartheta} {\text{\symsfgreek{^^^^e1f2}}} |
| 1491 |
\newcommand{\symsfitiota} {\text{\symsfgreek{^^^^e1e0}}} |
| 1492 |
\newcommand{\symsfitkappa} {\text{\symsfgreek{^^^^e1e1}}} |
| 1493 |
\newcommand{\symsfitlambda} {\text{\symsfgreek{^^^^e1e2}}} |
| 1494 |
\newcommand{\symsfitmu} {\text{\symsfgreek{^^^^e1e3}}} |
| 1495 |
\newcommand{\symsfitnu} {\text{\symsfgreek{^^^^e1e4}}} |
| 1496 |
\newcommand{\symsfitxi} {\text{\symsfgreek{^^^^e1e5}}} |
| 1497 |
\newcommand{\symsfitomicron} {\text{\symsfgreek{^^^^e1e6}}} |
| 1498 |
\newcommand{\symsfitpi} {\text{\symsfgreek{^^^^e1e7}}} |
| 1499 |
\newcommand{\symsfitvarpi} {\text{\symsfgreek{^^^^e1f5}}} |
| 1500 |
\newcommand{\symsfitrho} {\text{\symsfgreek{^^^^e1e8}}} |
| 1501 |
\newcommand{\symsfitvarrho} {\text{\symsfgreek{^^^^e1f4}}} |
| 1502 |
\newcommand{\symsfitsigma} {\text{\symsfgreek{^^^^e1ea}}} |
| 1503 |
\newcommand{\symsfitvarsigma} {\text{\symsfgreek{^^^^e1e9}}} |
| 1504 |
\newcommand{\symsfittau} {\text{\symsfgreek{^^^^e1eb}}} |
| 1505 |
\newcommand{\symsfitupsilon} {\text{\symsfgreek{^^^^e1ec}}} |
| 1506 |
\newcommand{\symsfitphi} {\text{\symsfgreek{^^^^e1f3}}} |
| 1507 |
\newcommand{\symsfitvarphi} {\text{\symsfgreek{^^^^e1ed}}} |
| 1508 |
\newcommand{\symsfitchi} {\text{\symsfgreek{^^^^e1ee}}} |
| 1509 |
\newcommand{\symsfitpsi} {\text{\symsfgreek{^^^^e1ef}}} |
| 1510 |
\newcommand{\symsfitomega} {\text{\symsfgreek{^^^^e1f0}}} |
| 1511 |
\newcommand{\symsfitDelta} {\text{\symsfgreek{^^^^e1c2}}} |
| 1512 |
\newcommand{\symsfitGamma} {\text{\symsfgreek{^^^^e1c1}}} |
| 1513 |
\newcommand{\symsfitTheta} {\text{\symsfgreek{^^^^e1d0}}} |
| 1514 |
\newcommand{\symsfitLambda} {\text{\symsfgreek{^^^^e1c9}}} |
| 1515 |
\newcommand{\symsfitXi} {\text{\symsfgreek{^^^^e1cc}}} |
| 1516 |
\newcommand{\symsfitPi} {\text{\symsfgreek{^^^^e1ce}}} |
| 1517 |
\newcommand{\symsfitSigma} {\text{\symsfgreek{^^^^e1d1}}} |
| 1518 |
\newcommand{\symsfitUpsilon} {\text{\symsfgreek{^^^^e1d3}}} |
| 1519 |
\newcommand{\symsfitPhi} {\text{\symsfgreek{^^^^e1d4}}} |
| 1520 |
\newcommand{\symsfitPsi} {\text{\symsfgreek{^^^^e1d6}}} |
| 1521 |
\newcommand{\symsfitOmega} {\text{\symsfgreek{^^^^e1d7}}} |
| 1522 |
% \end{macrocode} |
| 1523 |
% |
| 1524 |
% Tweak the \href{https://www.ctan.org/pkg/esvect}{\pkg{esvect}} package |
| 1525 |
% fonts to get the correct font size.\newline |
| 1526 |
% See \url{https://tex.stackexchange.com/a/566676}. |
| 1527 |
% |
| 1528 |
% \begin{macrocode} |
| 1529 |
\DeclareFontFamily{U}{esvect}{} |
| 1530 |
\DeclareFontShape{U}{esvect}{m}{n}{% |
| 1531 |
<-5.5> vect5 |
| 1532 |
<5.5-6.5> vect6 |
| 1533 |
<6.5-7.5> vect7 |
| 1534 |
<7.5-8.5> vect8 |
| 1535 |
<8.5-9.5> vect9 |
| 1536 |
<9.5-> vect10 |
| 1537 |
}{}% |
| 1538 |
% \end{macrocode} |
| 1539 |
% |
| 1540 |
% Write a banner to the console showing the options in use. |
| 1541 |
% |
| 1542 |
% \begin{macrocode} |
| 1543 |
\typeout{}% |
| 1544 |
\typeout{mandistudent: You are using mandistudent \mandistudentversion.}% |
| 1545 |
\typeout{mandistudent: This package requires LuaLaTeX.}% |
| 1546 |
\typeout{mandistudent: This package changes the default math font(s).}% |
| 1547 |
\typeout{mandistudent: This package redefines the \protect\vec\space command.}% |
| 1548 |
\IfClassLoadedTF{beamer}% |
| 1549 |
{% |
| 1550 |
\typeout{mandistudent: BEAMER detected. Certain commands will not be defined.}% |
| 1551 |
}% |
| 1552 |
{}% |
| 1553 |
\typeout{}% |
| 1554 |
% \end{macrocode} |
| 1555 |
% |
| 1556 |
% A better, intelligent coordinate-free \refCom{vec} command. Note the use of |
| 1557 |
% the |e{_^}| type of optional argument. This accounts for much of the |
| 1558 |
% flexibility and power of this command. Also note the use of the \TeX{} |
| 1559 |
% primitives |\sb{}| and |\sp{}|. Why doesn't it work when I put spaces |
| 1560 |
% around |#3| or |#4|? Because outside of |\ExplSyntaxOn...\ExplSyntaxOff|, |
| 1561 |
% the |_| character has a different catcode and is treated as a mathematical |
| 1562 |
% entity.\newline |
| 1563 |
% See \url{https://tex.stackexchange.com/q/554706/218142}.\newline |
| 1564 |
% See also \url{https://tex.stackexchange.com/a/531037/218142}. |
| 1565 |
% |
| 1566 |
% \changes{v3.1.0}{2022-01-27} |
| 1567 |
% {\linktoplace{sec:mandib}{mandistudent} \refCom{vec} and \refCom{dirvec}% |
| 1568 |
% no longer add \cs{scriptspace} when no sub/superscript is given} |
| 1569 |
% \begin{macrocode} |
| 1570 |
\RenewDocumentCommand{\vec}{ s m e{_^} }% |
| 1571 |
{% |
| 1572 |
\IfBooleanTF{#1} |
| 1573 |
{% |
| 1574 |
\vv{#2}% |
| 1575 |
\IfValueT{#4}% |
| 1576 |
{\sp{\,#4\vphantom{\smash[t]{\big|}}}} |
| 1577 |
}% |
| 1578 |
{% |
| 1579 |
\symbfit{#2} |
| 1580 |
\IfValueT{#4}% |
| 1581 |
{\sp{#4\vphantom{\smash[t]{\big|}}}} |
| 1582 |
}% |
| 1583 |
\IfValueT{#3}% |
| 1584 |
{\sb{#3\vphantom{\smash[b]{|}}}} |
| 1585 |
}% |
| 1586 |
% \end{macrocode} |
| 1587 |
%% A command for the direction of a vector. |
| 1588 |
% We use a slight tweak to get uniform hats that |
| 1589 |
% requires the \href{https://www.ctan.org/pkg/makebox}{\pkg{makebox}} |
| 1590 |
% package.\newline |
| 1591 |
% See \url{https://tex.stackexchange.com/a/391204/218142}. |
| 1592 |
% |
| 1593 |
% \begin{macrocode} |
| 1594 |
\NewDocumentCommand{\dirvec}{ s m e{_^} }% |
| 1595 |
{% |
| 1596 |
\widehat% |
| 1597 |
{% |
| 1598 |
\makebox*{\(w\)}% |
| 1599 |
{% |
| 1600 |
\ensuremath{% |
| 1601 |
\IfBooleanTF {#1}% |
| 1602 |
{% |
| 1603 |
#2% |
| 1604 |
}% |
| 1605 |
{% |
| 1606 |
\symbfit{#2}% |
| 1607 |
}% |
| 1608 |
}% |
| 1609 |
}% |
| 1610 |
}% |
| 1611 |
\IfValueT{#3}% |
| 1612 |
{\sb{#3\vphantom{\smash[b]{|}}}}% |
| 1613 |
\IfValueT{#4}% |
| 1614 |
{\sp{\,#4\vphantom{\smash[t]{\big|}}}}% |
| 1615 |
}% |
| 1616 |
% \end{macrocode} |
| 1617 |
% |
| 1618 |
% The zero vector. |
| 1619 |
% |
| 1620 |
% \begin{macrocode} |
| 1621 |
\NewDocumentCommand{\zerovec}{ s }% |
| 1622 |
{% |
| 1623 |
\IfBooleanTF {#1} |
| 1624 |
{\vv{0}}% |
| 1625 |
{\symbfup{0}}% |
| 1626 |
}% |
| 1627 |
% \end{macrocode} |
| 1628 |
% |
| 1629 |
% Notation for column and row vectors.\newline |
| 1630 |
% See \url{https://tex.stackexchange.com/a/39054/218142}. |
| 1631 |
% |
| 1632 |
% \begin{macrocode} |
| 1633 |
\ExplSyntaxOn |
| 1634 |
\NewDocumentCommand{\colvec}{ O{,} m } |
| 1635 |
{ |
| 1636 |
\__mandi_vectormain:nnnn { p } { \\ } { #1 } { #2 } |
| 1637 |
} |
| 1638 |
\NewDocumentCommand{\rowvec}{ O{,} m } |
| 1639 |
{ |
| 1640 |
\__mandi_vectormain:nnnn { p } { & } { #1 } { #2 } |
| 1641 |
} |
| 1642 |
\seq_new:N \l__mandi_vectorarg_seq |
| 1643 |
\cs_new_protected:Npn \__mandi_vectormain:nnnn #1#2#3#4 |
| 1644 |
{ |
| 1645 |
\seq_set_split:Nnn \l__mandi_vectorarg_seq { #3 } { #4 } |
| 1646 |
\begin{#1NiceMatrix}[r] |
| 1647 |
\seq_use:Nnnn \l__mandi_vectorarg_seq { #2 } { #2 } { #2 } |
| 1648 |
\end{#1NiceMatrix} |
| 1649 |
} |
| 1650 |
\ExplSyntaxOff |
| 1651 |
% \end{macrocode} |
| 1652 |
% |
| 1653 |
% Students always need this symbol. |
| 1654 |
% |
| 1655 |
% \begin{macrocode} |
| 1656 |
\NewDocumentCommand{\changein}{}{\Delta} |
| 1657 |
% \end{macrocode} |
| 1658 |
% |
| 1659 |
% Intelligent delimiters provided via the |
| 1660 |
% \href{https://www.ctan.org/pkg/mathtools}{\pkg{mathtools}} package. |
| 1661 |
% Use the starred variants for fractions. You can supply optional sizes. |
| 1662 |
% Note that default placeholders are used when the argument is empty. |
| 1663 |
% |
| 1664 |
% \begin{macrocode} |
| 1665 |
\DeclarePairedDelimiterX{\doublebars}[1]{\lVert}{\rVert}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1666 |
\DeclarePairedDelimiterX{\singlebars}[1]{\lvert}{\rvert}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1667 |
\DeclarePairedDelimiterX{\anglebrackets}[1]{\langle}{\rangle}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1668 |
\DeclarePairedDelimiterX{\parentheses}[1]{(}{)}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1669 |
\DeclarePairedDelimiterX{\squarebrackets}[1]{\lbrack}{\rbrack}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1670 |
\DeclarePairedDelimiterX{\curlybraces}[1]{\lbrace}{\rbrace}{\ifblank{#1}{\:\cdot\:}{#1}} |
| 1671 |
% \end{macrocode} |
| 1672 |
% |
| 1673 |
% Some semantic aliases. Because of the way \refCom{vec} and |
| 1674 |
% \refCom{dirvec} are defined, I reluctantly decided not to |
| 1675 |
% implement a |\magvec| command. It would require accounting |
| 1676 |
% for too many options. So \refCom{magnitude} is the new |
| 1677 |
% solution. |
| 1678 |
% |
| 1679 |
% \begin{macrocode} |
| 1680 |
\NewDocumentCommand{\magnitude}{}{\doublebars} |
| 1681 |
\NewDocumentCommand{\norm}{}{\doublebars} |
| 1682 |
\NewDocumentCommand{\absolutevalue}{}{\singlebars} |
| 1683 |
% \end{macrocode} |
| 1684 |
% |
| 1685 |
% Commands for two important geometric relationships. These are meant |
| 1686 |
% mainly to be subscripts. |
| 1687 |
% |
| 1688 |
% \begin{macrocode} |
| 1689 |
\NewDocumentCommand{\parallelto}{}% |
| 1690 |
{% |
| 1691 |
\mkern3mu\vphantom{\perp}\vrule depth 0pt\mkern2mu\vrule depth 0pt\mkern3mu% |
| 1692 |
}% |
| 1693 |
\NewDocumentCommand{\perpendicularto}{}{\perp} |
| 1694 |
% \end{macrocode} |
| 1695 |
% |
| 1696 |
% An environment for problem statements. The starred variant gives |
| 1697 |
% in-line lists. These are not defined if \textsc{beamer} is loaded. |
| 1698 |
% |
| 1699 |
% \changes{v3.2.0}{2023-08-01} |
| 1700 |
% {\linktoplace{sec:mandib}{mandistudent} \refEnv{physicsproblem} and |
| 1701 |
% \refEnv{physicsproblem*} are not defined if \textsc{beamer} is loaded} |
| 1702 |
% \begin{macrocode} |
| 1703 |
\IfClassLoadedTF{beamer} |
| 1704 |
{}% |
| 1705 |
{% |
| 1706 |
\NewDocumentEnvironment{physicsproblem}{ m }% |
| 1707 |
{% |
| 1708 |
\newpage% |
| 1709 |
\section*{#1}% |
| 1710 |
\newlist{parts}{enumerate}{2}% |
| 1711 |
\setlist[parts]{label=\bfseries(\alph*)}% |
| 1712 |
}% |
| 1713 |
{}% |
| 1714 |
\NewDocumentEnvironment{physicsproblem*}{ m }% |
| 1715 |
{% |
| 1716 |
\newpage% |
| 1717 |
\section*{#1}% |
| 1718 |
\newlist{parts}{enumerate*}{2}% |
| 1719 |
\setlist[parts]{label=\bfseries(\alph*)}% |
| 1720 |
}% |
| 1721 |
{}% |
| 1722 |
\NewDocumentCommand{\problempart}{}{\item}% |
| 1723 |
}% |
| 1724 |
% \end{macrocode} |
| 1725 |
% |
| 1726 |
% An environment for problem solutions. Equation numbering |
| 1727 |
% is consecutive through the document. |
| 1728 |
% |
| 1729 |
% \begin{macrocode} |
| 1730 |
\NewDocumentEnvironment{physicssolution}{ +b }% |
| 1731 |
{% |
| 1732 |
\begin{align} |
| 1733 |
#1 |
| 1734 |
\end{align} |
| 1735 |
}% |
| 1736 |
{}% |
| 1737 |
\NewDocumentEnvironment{physicssolution*}{ +b }% |
| 1738 |
{% |
| 1739 |
\begin{align*} |
| 1740 |
#1 |
| 1741 |
\end{align*} |
| 1742 |
}% |
| 1743 |
{}% |
| 1744 |
% \end{macrocode} |
| 1745 |
% |
| 1746 |
% See \url{https://tex.stackexchange.com/q/570223/218142}. |
| 1747 |
% |
| 1748 |
% \begin{macrocode} |
| 1749 |
\NewDocumentCommand{\reason}{ O{4cm} m }% |
| 1750 |
{% |
| 1751 |
&&\begin{minipage}{#1}\raggedright\small #2\end{minipage}% |
| 1752 |
}% |
| 1753 |
% \end{macrocode} |
| 1754 |
% |
| 1755 |
% Command for highlighting parts of, or entire, mathematical expressions.\newline |
| 1756 |
% This command is not defined if \textsc{beamer} is loaded.\newline |
| 1757 |
% See \url{https://texample.net/tikz/examples/beamer-arrows/}.\newline |
| 1758 |
% See also \url{https://tex.stackexchange.com/a/406084/218142}.\newline |
| 1759 |
% See also \url{https://tex.stackexchange.com/a/570858/218142}.\newline |
| 1760 |
% See also \url{https://tex.stackexchange.com/a/570789/218142}.\newline |
| 1761 |
% See also \url{https://tex.stackexchange.com/a/79659/218142}.\newline |
| 1762 |
% See also \url{https://tex.stackexchange.com/q/375032/218142}.\newline |
| 1763 |
% See also \url{https://tex.stackexchange.com/a/571744/218142}% |
| 1764 |
% |
| 1765 |
% \changes{v3.2.0}{2023-08-01} |
| 1766 |
% {\linktoplace{sec:mandib}{mandistudent} \refCom{hilite} is |
| 1767 |
% not defined if \textsc{beamer} is loaded} |
| 1768 |
% \begin{macrocode} |
| 1769 |
\newcounter{tikzhighlightnode} |
| 1770 |
\NewDocumentCommand{\hilite}{ O{magenta!60} m O{rectangle} }% |
| 1771 |
{% |
| 1772 |
\stepcounter{tikzhighlightnode}% |
| 1773 |
\tikzmarknode{highlighted-node-\number\value{tikzhighlightnode}}{#2}% |
| 1774 |
\edef\temp{% |
| 1775 |
\noexpand\AddToShipoutPictureBG{% |
| 1776 |
\noexpand\begin{tikzpicture}[overlay,remember picture]% |
| 1777 |
\noexpand\iftikzmarkoncurrentpage{highlighted-node-\number\value{tikzhighlightnode}}% |
| 1778 |
\noexpand\node[inner sep=1.0pt,fill=#1,#3,fit=(highlighted-node-\number\value{tikzhighlightnode})]{};% |
| 1779 |
\noexpand\fi |
| 1780 |
\noexpand\end{tikzpicture}% |
| 1781 |
}% |
| 1782 |
}% |
| 1783 |
\temp% |
| 1784 |
}% |
| 1785 |
% \end{macrocode} |
| 1786 |
% |
| 1787 |
% A simplified command for importing images.\newline |
| 1788 |
% See \url{https://tex.stackexchange.com/a/614478/218142}. |
| 1789 |
% |
| 1790 |
% \changes{v3.1.0}{2022-01-27} |
| 1791 |
% {\linktoplace{sec:mandib}{mandistudent} Slightly modified \refCom{image}} |
| 1792 |
% \begin{macrocode} |
| 1793 |
\NewDocumentCommand{\image}{ O{scale=1} m m m }% |
| 1794 |
{% |
| 1795 |
\par |
| 1796 |
\begin{figure}[ht!] |
| 1797 |
\centering% |
| 1798 |
\includegraphics[#1]{#2}% |
| 1799 |
\caption{#3}% |
| 1800 |
\label{#4}% |
| 1801 |
\end{figure}% |
| 1802 |
\par |
| 1803 |
}% |
| 1804 |
% \end{macrocode} |
| 1805 |
% |
| 1806 |
% Intelligent commands for typesetting vector and tensor symbols and |
| 1807 |
% components suitable for use with both coordinate-free and index |
| 1808 |
% notations. Use starred form for index notation, unstarred form for |
| 1809 |
% coordinate-free. |
| 1810 |
% |
| 1811 |
% Consider renaming these to |\vectorsym| and |\tensorsym|. |
| 1812 |
% |
| 1813 |
% \begin{macrocode} |
| 1814 |
\NewDocumentCommand{\veccomp}{ s m }% |
| 1815 |
{% |
| 1816 |
\IfBooleanTF{#1} |
| 1817 |
{% |
| 1818 |
\symnormal{#2}% |
| 1819 |
}% |
| 1820 |
{% |
| 1821 |
\symbfit{#2}% |
| 1822 |
}% |
| 1823 |
}% |
| 1824 |
\NewDocumentCommand{\tencomp}{ s m }% |
| 1825 |
{% |
| 1826 |
\IfBooleanTF{#1}% |
| 1827 |
{% |
| 1828 |
\symsfit{#2}% |
| 1829 |
}% |
| 1830 |
{% |
| 1831 |
\symbfsfit{#2}% |
| 1832 |
}% |
| 1833 |
}% |
| 1834 |
% \end{macrocode} |
| 1835 |
% |
| 1836 |
% Command to typeset tensor valence. |
| 1837 |
% |
| 1838 |
% \begin{macrocode} |
| 1839 |
\NewDocumentCommand{\valence}{ s m m }% |
| 1840 |
{% |
| 1841 |
\IfBooleanTF{#1}% |
| 1842 |
{% |
| 1843 |
(#2,#3)% |
| 1844 |
}% |
| 1845 |
{% |
| 1846 |
\binom{#2}{#3}% |
| 1847 |
}% |
| 1848 |
}% |
| 1849 |
% \end{macrocode} |
| 1850 |
% |
| 1851 |
% Intelligent notation for contraction on pairs of slots. |
| 1852 |
% |
| 1853 |
% \begin{macrocode} |
| 1854 |
\NewDocumentCommand{\contraction}{ s m }% |
| 1855 |
{% |
| 1856 |
\IfBooleanTF{#1} |
| 1857 |
{% |
| 1858 |
\mathsf{C}% |
| 1859 |
}% |
| 1860 |
{% |
| 1861 |
\symbb{C}% |
| 1862 |
}% |
| 1863 |
_{#2} |
| 1864 |
}% |
| 1865 |
% \end{macrocode} |
| 1866 |
% |
| 1867 |
% Intelligent slot command for coordinate-free tensor notation. |
| 1868 |
% |d[]| must be used because of the way consecutive optional |
| 1869 |
% arguments are handled. See \pkg{xparse} docs for details. |
| 1870 |
% |
| 1871 |
% \begin{macrocode} |
| 1872 |
\NewDocumentCommand{\slot}{ s d[] }% |
| 1873 |
{% |
| 1874 |
\IfBooleanTF{#1} |
| 1875 |
{% |
| 1876 |
\IfValueTF{#2} |
| 1877 |
% \end{macrocode} |
| 1878 |
% |
| 1879 |
% Insert a vector, but don't show the slot. |
| 1880 |
% |
| 1881 |
% \begin{macrocode} |
| 1882 |
{% |
| 1883 |
\smash{\makebox[1.5em]{\ensuremath{#2}}} |
| 1884 |
}% |
| 1885 |
% \end{macrocode} |
| 1886 |
% |
| 1887 |
% No vector, no slot. |
| 1888 |
% |
| 1889 |
% \begin{macrocode} |
| 1890 |
{% |
| 1891 |
\smash{\makebox[1.5em]{\ensuremath{}}} |
| 1892 |
}% |
| 1893 |
}% |
| 1894 |
{% |
| 1895 |
\IfValueTF{#2} |
| 1896 |
% \end{macrocode} |
| 1897 |
% |
| 1898 |
% Insert a vector and show the slot. |
| 1899 |
% |
| 1900 |
% \begin{macrocode} |
| 1901 |
{% |
| 1902 |
\underline{\smash{\makebox[1.5em]{\ensuremath{#2}}}} |
| 1903 |
}% |
| 1904 |
% \end{macrocode} |
| 1905 |
% |
| 1906 |
% No vector; just show the slot. |
| 1907 |
% |
| 1908 |
% \begin{macrocode} |
| 1909 |
{% |
| 1910 |
\underline{\smash{\makebox[1.5em]{\ensuremath{}}}} |
| 1911 |
}% |
| 1912 |
}% |
| 1913 |
}% |
| 1914 |
% \end{macrocode} |
| 1915 |
% |
| 1916 |
% Intelligent differential (exterior derivative) operator. |
| 1917 |
% |
| 1918 |
% \begin{macrocode} |
| 1919 |
\NewDocumentCommand{\df}{ s }% |
| 1920 |
{% |
| 1921 |
\mathop{}\!% |
| 1922 |
\IfBooleanTF{#1}% |
| 1923 |
{% |
| 1924 |
\symbfsfup{d}% |
| 1925 |
}% |
| 1926 |
{% |
| 1927 |
\symsfup{d}% |
| 1928 |
}% |
| 1929 |
}% |
| 1930 |
% \end{macrocode} |
| 1931 |
% |
| 1932 |
% Here is a clever way to color digits in program listsings thanks to |
| 1933 |
% Ulrike Fischer.\newline |
| 1934 |
% See \url{https://tex.stackexchange.com/a/570717/218142}. |
| 1935 |
% |
| 1936 |
% \begin{macrocode} |
| 1937 |
\directlua{% |
| 1938 |
luaotfload.add_colorscheme("colordigits", |
| 1939 |
{["8000FF"] = {"one","two","three","four","five","six","seven","eight","nine","zero"}}) |
| 1940 |
}% |
| 1941 |
\newfontfamily\colordigits{DejaVuSansMono}[RawFeature={color=colordigits}] |
| 1942 |
% \end{macrocode} |
| 1943 |
% |
| 1944 |
% Set up a color scheme and a new code environment for listings. The new colors |
| 1945 |
% are more restful on the eye. All listing commands now use |
| 1946 |
% \href{https://www.ctan.org/pkg/tcolorbox}{\pkg{tcolorbox}}.\newline |
| 1947 |
% See \url{https://tex.stackexchange.com/a/529421/218142}. |
| 1948 |
% |
| 1949 |
% We set a new font for listings and some new colors (background gray, gray, |
| 1950 |
% green, orange, peach, pearl, and plum). |
| 1951 |
% |
| 1952 |
% \begin{macrocode} |
| 1953 |
\newfontfamily{\gsfontfamily}{DejaVuSansMono} |
| 1954 |
\definecolor{gsbggray} {rgb}{0.90,0.90,0.90} |
| 1955 |
\definecolor{gsgray} {rgb}{0.30,0.30,0.30} |
| 1956 |
\definecolor{gsgreen} {rgb}{0.00,0.60,0.00} |
| 1957 |
\definecolor{gsorange} {rgb}{0.80,0.45,0.12} |
| 1958 |
\definecolor{gspeach} {rgb}{1.00,0.90,0.71} |
| 1959 |
\definecolor{gspearl} {rgb}{0.94,0.92,0.84} |
| 1960 |
\definecolor{gsplum} {rgb}{0.74,0.46,0.70} |
| 1961 |
\lstdefinestyle{vpython}% |
| 1962 |
{% |
| 1963 |
backgroundcolor=\color{gsbggray},% % background color |
| 1964 |
basicstyle=\colordigits\footnotesize,% % default style |
| 1965 |
breakatwhitespace=true% % break at whitespace |
| 1966 |
breaklines=true,% % break long lines |
| 1967 |
captionpos=b,% % position caption |
| 1968 |
classoffset=1,% % STILL DON'T UNDERSTAND THIS |
| 1969 |
commentstyle=\color{gsgray},% % font for comments |
| 1970 |
deletekeywords={print},% % delete keywords from the given language |
| 1971 |
emph={self,cls,@classmethod,@property},% % words to emphasize |
| 1972 |
emphstyle=\color{gsorange}\itshape,% % font for emphasis |
| 1973 |
escapeinside={(*@}{@*)},% % add LaTeX within your code |
| 1974 |
frame=tb,% % frame style |
| 1975 |
framerule=2.0pt,% % frame thickness |
| 1976 |
framexleftmargin=5pt,% % extra frame left margin |
| 1977 |
%identifierstyle=\sffamily,% % style for identifiers |
| 1978 |
keywordstyle=\gsfontfamily\color{gsplum},% % color for keywords |
| 1979 |
language=Python,% % select language |
| 1980 |
linewidth=\linewidth,% % width of listings |
| 1981 |
morekeywords={% % VPython/Web VPython specific keywords |
| 1982 |
__future__,abs,acos,align,ambient,angle,append,append_to_caption,% |
| 1983 |
append_to_title,arange,arrow,asin,astuple,atan,atan2,attach_arrow,% |
| 1984 |
attach_trail,autoscale,axis,background,billboard,bind,black,blue,border,% |
| 1985 |
bounding_box,box,bumpaxis,bumpmap,bumpmaps,camera,canvas,caption,capture,% |
| 1986 |
ceil,center,clear,clear_trail,click,clone,CoffeeScript,coils,color,combin,% |
| 1987 |
comp,compound,cone,convex,cos,cross,curve,cyan,cylinder,data,degrees,del,% |
| 1988 |
delete,depth,descender,diff_angle,digits,division,dot,draw_complete,% |
| 1989 |
ellipsoid,emissive,end_face_color,equals,explog,extrusion,faces,factorial,% |
| 1990 |
False,floor,follow,font,format,forward,fov,frame,gcurve,gdisplay,gdots,% |
| 1991 |
get_library,get_selected,ghbars,global,GlowScript,graph,graphs,green,gvbars,% |
| 1992 |
hat,headlength,headwidth,height,helix,hsv_to_rgb,index,interval,keydown,% |
| 1993 |
keyup,label,length,lights,line,linecolor,linewidth,logx,logy,lower_left,% |
| 1994 |
lower_right,mag,mag2,magenta,make_trail,marker_color,markers,material,% |
| 1995 |
max,min,mouse,mousedown,mousemove,mouseup,newball,norm,normal,objects,% |
| 1996 |
offset,one,opacity,orange,origin,path,pause,pi,pixel_to_world,pixels,plot,% |
| 1997 |
points,pos,pow,pps,print,print_function,print_options,proj,purple,pyramid,% |
| 1998 |
quad,radians,radius,random,rate,ray,read_local_file,readonly,red,redraw,% |
| 1999 |
retain,rgb_to_hsv,ring,rotate,round,scene,scroll,shaftwidth,shape,shapes,% |
| 2000 |
shininess,show_end_face,show_start_face,sign,sin,size,size_units,sleep,% |
| 2001 |
smooth,space,sphere,sqrt,start,start_face_color,stop,tan,text,textpos,% |
| 2002 |
texture,textures,thickness,title,trail_color,trail_object,trail_radius,% |
| 2003 |
trail_type,triangle,trigger,True,twist,unbind,up,upper_left,upper_right,% |
| 2004 |
userpan,userspin,userzoom,vec,vector,vertex,vertical_spacing,visible,% |
| 2005 |
visual,vpython,VPython,waitfor,Web,VPython,white,width,world,xtitle,% |
| 2006 |
yellow,yoffset,ytitle% |
| 2007 |
},% |
| 2008 |
morekeywords={print,None,TypeError},% % additional keywords |
| 2009 |
morestring=[b]{"""},% % treat triple quotes as strings |
| 2010 |
numbers=left,% % where to put line numbers |
| 2011 |
numbersep=10pt,% % how far line numbers are from code |
| 2012 |
numberstyle=\bfseries\tiny,% % set to 'none' for no line numbers |
| 2013 |
showstringspaces=false,% % show spaces in strings |
| 2014 |
showtabs=false,% % show tabs within strings |
| 2015 |
stringstyle=\gsfontfamily\color{gsgreen},% % color for strings |
| 2016 |
upquote=true,% % how to typeset quotes |
| 2017 |
}% |
| 2018 |
% \end{macrocode} |
| 2019 |
% |
| 2020 |
% Introduce a new, more intelligent \refEnv{webvpythonblock} environment.\newline |
| 2021 |
% See \url{https://tex.stackexchange.com/a/232208/218142}. |
| 2022 |
% |
| 2023 |
% \changes{v3.1.0}{2022-01-27} |
| 2024 |
% {\linktoplace{sec:mandib}{mandistudent} URLs fixed in \refEnv{webvpythonblock}} |
| 2025 |
% \changes{v3.1.0}{2022-01-27} |
| 2026 |
% {\linktoplace{sec:mandib}{mandistudent} \refEnv{webvpythonblock} now automatically |
| 2027 |
% generates QR codes for program listings} |
| 2028 |
% \changes{v3.2.0}{2023-08-01} |
| 2029 |
% {\linktoplace{sec:mandib}{mandistudent} \refEnv{webvpythonblock} and |
| 2030 |
% \refEnv{webvpythonblock*} now show URL in header} |
| 2031 |
% \begin{macrocode} |
| 2032 |
\AtBeginEnvironment{webvpythonblock}{\catcode`\#=12} |
| 2033 |
\AtEndEnvironment{webvpythonblock}{\catcode`\#=6} |
| 2034 |
\NewTCBListing[auto counter,list inside=gsprogs]{webvpythonblock}{ O{} D(){webvpython.org} m }% |
| 2035 |
{% |
| 2036 |
breakable,% |
| 2037 |
center,% |
| 2038 |
code = \newpage,% |
| 2039 |
%derivpeach,% |
| 2040 |
enhanced,% |
| 2041 |
hyperurl interior = https://#2,% |
| 2042 |
label = {gs:\thetcbcounter},% |
| 2043 |
left = 8mm,% |
| 2044 |
list entry = \thetcbcounter~~~~~#3,% |
| 2045 |
listing only,% |
| 2046 |
listing style = vpython,% |
| 2047 |
nameref = {#3},% |
| 2048 |
title = \begin{minipage}{1.5cm}% |
| 2049 |
\protect\qrcode*{https://#2}% |
| 2050 |
\end{minipage}\hspace{5mm}% |
| 2051 |
\begin{minipage}{0.8\textwidth}% |
| 2052 |
\texttt{Web VPython} Program \thetcbcounter: #3\\ |
| 2053 |
\footnotesize{\href{https://#2}{\color{white}{https://#2}}}% |
| 2054 |
\end{minipage},% |
| 2055 |
width = 0.9\textwidth,% |
| 2056 |
{#1}, |
| 2057 |
}% |
| 2058 |
% \end{macrocode} |
| 2059 |
% |
| 2060 |
% Here is a variant that omits the QR code. |
| 2061 |
% |
| 2062 |
% \changes{v3.1.0}{2022-01-27} |
| 2063 |
% {\linktoplace{sec:mandib}{mandistudent} \refEnv{webvpythonblock*} is a variant |
| 2064 |
% of \refEnv{webvpythonblock} that omits the QR code} |
| 2065 |
% \begin{macrocode} |
| 2066 |
\AtBeginEnvironment{webvpythonblock*}{\catcode`\#=12} |
| 2067 |
\AtEndEnvironment{webvpythonblock*}{\catcode`\#=6} |
| 2068 |
\NewTCBListing[use counter from=webvpythonblock,list inside=gsprogs] |
| 2069 |
{webvpythonblock*}{ O{} D(){webvpython.org} m }% |
| 2070 |
{% |
| 2071 |
breakable,% |
| 2072 |
center,% |
| 2073 |
code = \newpage,% |
| 2074 |
%derivpeach,% |
| 2075 |
enhanced,% |
| 2076 |
hyperurl interior = https://#2,% |
| 2077 |
label = {gs:\thetcbcounter},% |
| 2078 |
left = 8mm,% |
| 2079 |
list entry = \thetcbcounter~~~~~#3,% |
| 2080 |
listing only,% |
| 2081 |
listing style = vpython,% |
| 2082 |
nameref = {#3},% |
| 2083 |
title = \texttt{Web VPython} Program \thetcbcounter: #3\\% |
| 2084 |
\footnotesize{\href{https://#2}{\color{white}{https://#2}}},% |
| 2085 |
width = 0.9\textwidth,% |
| 2086 |
{#1}, |
| 2087 |
}% |
| 2088 |
% \end{macrocode} |
| 2089 |
% |
| 2090 |
% A new command for generating a list of \WebVPython{} programs. |
| 2091 |
% |
| 2092 |
% \begin{macrocode} |
| 2093 |
\NewDocumentCommand{\listofwebvpythonprograms}{}% |
| 2094 |
{% |
| 2095 |
\tcblistof[\section*]{gsprogs}{List of \texttt{Web VPython} Programs}% |
| 2096 |
}% |
| 2097 |
% \end{macrocode} |
| 2098 |
% |
| 2099 |
% Introduce a new, more intelligent \refCom{vpythonfile} command.\newline |
| 2100 |
% See \url{https://tex.stackexchange.com/q/616205/218142}. |
| 2101 |
% |
| 2102 |
% \changes{v3.1.0}{2022-01-27} |
| 2103 |
% {\linktoplace{sec:mandib}{mandistudent} URLs fixed in \refCom{vpythonfile}} |
| 2104 |
% \changes{v3.1.0}{2022-01-27} |
| 2105 |
% {\linktoplace{sec:mandib}{mandistudent} Default URL for \refCom{vpythonfile} |
| 2106 |
% is now \vpurl} |
| 2107 |
% \changes{v3.2.0}{2023-08-01} |
| 2108 |
% {\linktoplace{sec:mandib}{mandistudent} \refCom{vpythonfile} now shows |
| 2109 |
% URL in header} |
| 2110 |
% \begin{macrocode} |
| 2111 |
\newcommand*{\vpythonfile}{\catcode`\#=12 \vpythonfile@auxA} |
| 2112 |
\NewDocumentCommand{\vpythonfile@auxA}{ O{} D(){vpython.org} m m }% |
| 2113 |
{% |
| 2114 |
\vpythonfile@auxB[#1](#2){#3}{#4}% |
| 2115 |
\catcode`\#=6 |
| 2116 |
}% |
| 2117 |
\NewTCBInputListing[auto counter,list inside=vpprogs] |
| 2118 |
{\vpythonfile@auxB}{ O{} D(){vpython.org} m m }% |
| 2119 |
{% |
| 2120 |
breakable,% |
| 2121 |
center,% |
| 2122 |
code = \newpage,% |
| 2123 |
%derivgray,% |
| 2124 |
enhanced,% |
| 2125 |
hyperurl interior = https://#2,% |
| 2126 |
label = {vp:\thetcbcounter},% |
| 2127 |
left = 8mm,% |
| 2128 |
list entry = \thetcbcounter~~~~~#4,% |
| 2129 |
listing file = {#3},% |
| 2130 |
listing only,% |
| 2131 |
listing style = vpython,% |
| 2132 |
nameref = {#4},% |
| 2133 |
title = \texttt{VPython} Program \thetcbcounter: #4,% |
| 2134 |
width = 0.9\textwidth,% |
| 2135 |
{#1},% |
| 2136 |
}% |
| 2137 |
% \end{macrocode} |
| 2138 |
% |
| 2139 |
% A new command for generating a list of \VPython{} programs. |
| 2140 |
% |
| 2141 |
% \begin{macrocode} |
| 2142 |
\NewDocumentCommand{\listofvpythonprograms}{}% |
| 2143 |
{% |
| 2144 |
\tcblistof[\section*]{vpprogs}{List of \texttt{VPython} Programs}% |
| 2145 |
}% |
| 2146 |
% \end{macrocode} |
| 2147 |
% |
| 2148 |
% Introduce a new \refCom{webvpythoninline} command. |
| 2149 |
% |
| 2150 |
% \begin{macrocode} |
| 2151 |
\DeclareTotalTCBox{\webvpythoninline}{ m }% |
| 2152 |
{% |
| 2153 |
bottom = 0pt,% |
| 2154 |
bottomrule = 0.0mm,% |
| 2155 |
boxsep = 1.0mm,% |
| 2156 |
colback = gsbggray,% |
| 2157 |
colframe = gsbggray,% |
| 2158 |
left = 0pt,% |
| 2159 |
leftrule = 0.0mm,% |
| 2160 |
nobeforeafter,% |
| 2161 |
right = 0pt,% |
| 2162 |
rightrule = 0.0mm,% |
| 2163 |
sharp corners,% |
| 2164 |
tcbox raise base,% |
| 2165 |
top = 0pt,% |
| 2166 |
toprule = 0.0mm,% |
| 2167 |
}% |
| 2168 |
{\lstinline[style = vpython]{#1}}% |
| 2169 |
% \end{macrocode} |
| 2170 |
% |
| 2171 |
% Define \refCom{vpythoninline}, a semantic alias for \VPython{} |
| 2172 |
% in-line listings. |
| 2173 |
% |
| 2174 |
% \begin{macrocode} |
| 2175 |
\NewDocumentCommand{\vpythoninline}{}{\webvpythoninline}% |
| 2176 |
% \end{macrocode} |
| 2177 |
% |
| 2178 |
% \restoregeometry |
| 2179 |
% |
| 2180 |
% \iffalse |
| 2181 |
%</package> |
| 2182 |
% \fi |
| 2183 |
% |
| 2184 |
% \Finale |