Debian Codegraph @

texmf-dist/doc/latex/brandeis-problemset/brandeis-problemset.tex

raw
1 \PassOptionsToPackage{inline}{enumitem}
2 \documentclass{ltxguidex}
3 \usepackage{fontspec}
4 \usepackage[pseudocode, solution, assembly, tabu]{brandeis-problemset}
5
6 \usepackage{xkeyval}
7 \usepackage{xparse}
8 \usepackage{textcomp} % needed for listings
9 \usepackage{hologo} % xetex, etc. logos
10 \usepackage{changelog}
11 \newcommand{\bps}{\ltxclass{brandeis-problemset}}
12 \newcommand{\fontspecok}{\hologo{XeLaTeX} or \hologo{LuaTeX}}
13 \newcommand{\unicode}[1]{\textsc{u+#1}}
14 \NewDocumentCommand{\cosi}{o m}{\textsc{cosi}~#2\IfValueT{#1}{ (#1)}}
15 \newnotice{todo}{To-do}
16
17 \newcommand{\reqopt}[1]{Requires the \texttt{\color{magenta}#1} option.\par}
18 \newcommand{\dep}[1]{{\noticestyle Warning:} deprecated since #1.\par}
19 \newcommand{\withopt}[1]{\fbox{With the \option{#1} option:}}
20
21 \makeatletter
22 \renewcommand{\SX@explpreset}{
23 language=[LaTeX]TeX,
24 numbers=none,
25 }
26 \define@cmdkeys{joinlist}{sep, wrapper}
27 \define@cmdkey{joinlist}{last}{\KV@joinlist@oxfordfalse}
28 \define@boolkey{joinlist}{oxford}[true]{}
29 \define@boolkey{joinlist}{and}[true]{\ifKV@joinlist@and\def\cmdKV@joinlist@last{and}\fi}
30 \define@boolkey{joinlist}{or} [true]{\ifKV@joinlist@or \def\cmdKV@joinlist@last{or}\fi}
31 \presetkeys{joinlist}{sep={,}, last=and, oxford, wrapper=\relax}{}
32 \NewDocumentCommand{\joinlist}{O{} >{\SplitList{,}} m}
33 {{\setkeys{joinlist}{#1}%
34 \newcommand{\joinlist@wrapper}[1]{\item\cmdKV@joinlist@wrapper{##1}}%
35 \begin{itemize*}[
36 label={},
37 itemjoin={\cmdKV@joinlist@sep},
38 itemjoin*={\ifKV@joinlist@oxford\cmdKV@joinlist@sep\ \fi
39 \cmdKV@joinlist@last}]%
40 \ProcessList{#2}{\joinlist@wrapper}%
41 \end{itemize*}}}
42 \makeatother
43
44 \makeatletter
45 \NewDocumentCommand{\withopts}{m}
46 {\fbox{With any of the \joinlist[or, wrapper=\option]{#1} options:}}
47 \makeatother
48 \newcommand{\onlyclass}{Only available in the \bps\ document class.}
49 \newcommand{\optenables}[2]{If \option{#1} is set, then \option{#2} is
50 automatically enabled.}
51
52 \setmainfont{Tiempos Text}
53 \usepackage{FiraSans}
54 \usepackage{FiraMono}
55 \lstset{basewidth=0.6em}
56
57 \lstnewenvironment{latexfile}[1]
58 {\lstset{
59 language=[LaTeX]TeX,
60 numbers=none,
61 }}
62 {}
63
64 \author{Rebecca Turner\thanks{Brandeis University; \email{[email protected]}}}
65 \title{The \bps\ Document Class}
66 \date{2019/04/15 0.5.5}
67 \begin{document}
68 \maketitle
69 \begin{abstract}
70 Brandeis University's computer science (``\textsc{cosi}'') courses
71 often assign ``problem sets'' which require fairly rigorous
72 formatting. The \ctan{brandeis-problemset} document class, which
73 extends \ltxclass{article}, provides a simple way to typeset these
74 problem sets in \LaTeX.
75
76 Although \bps\ is compatible with all \LaTeX\ flavors, \fontspecok\
77 is recommended for \ctan{fontspec} support.
78 \end{abstract}
79
80 \begin{note}
81 The \bps\ document class should be considered experimental; the only
82 stable \textsc{api} is that of the |problem| environment.
83 \end{note}
84
85 \begin{note}
86 Browse the sources, contribute, or complain at \\
87 \https{github.com/9999years/brandeis-problemset}
88 \end{note}
89
90 \begin{note}
91 In roughly May 2021 I will graduate from Brandeis University and
92 this package will become unmaintained. Although I'd like the
93 computer science department to adopt this package, I'm not sure any
94 professors have an interest in that maintenance. If you care about
95 the extended future of this package, send some emails!
96 \end{note}
97
98 \tableofcontents
99 \vfill
100 \pagebreak
101
102 \section{Default behavior}
103 \bps\ provides packages and well-formatted constructs (notably the
104 |problem| environment) for problem-set writers. \bps\ will always render
105 its body copy as a Times variant (\ctan{stix} for plain \LaTeX\ or
106 \ctan{xits} with \fontspecok) and always contains a useful header (which
107 contains the page number, author's name, course, instructor, and assignment
108 due date).
109
110 \subsection{Default packages loaded}
111 In general, \bps\ will only load a feature if it's useful in more than one
112 class; features like Gantt charts, Scheme code, assembly code, and so on,
113 are loaded on demand.
114
115 \begin{enumerate}
116 \item \ctan{hyperref}, for a nicely-linked table of contents;
117 |\href||{url}{label}|.
118 \item \ctan{geometry} for page size and margins.
119 \item \ctan{enumitem} for better control over the margins and spacing of
120 the |enumerate|, |itemize|, and |description|
121 environments.
122 \item \withopts{listings, scheme, pseudocode, assembly}
123 \begin{enumerate}
124 \item \ctan{listings}, for verbatim code listings (including the
125 |assembly|, |java|, and |pseudocode| environments).
126 \item \ctan{xcolor}, for colored identifiers, strings, comments, and
127 line numbers in listings; e.g.\ |\color||{gray}|.
128 \end{enumerate}
129 \item \withopt{math} \begin{enumerate}
130 \item \ctan{amsmath} for tons of useful math commands, including
131 |\text|, |\intertext|, and |\boxed| as well as the |bmatrix|,
132 |multiline|, |gather|, |align|, and
133 |alignat| environments. See
134 \href{http://texdoc.net/texmf-dist/doc/latex/amsmath/amsldoc.pdf}{``User's
135 Guide for the \package{amsmath} Package''} for a more
136 complete listing.
137 \item \ctan{mathtools} for other useful/utilitarian commands.
138 \item With \fontspecok, \ctan{unicode-math} to allow equations to be
139 copy-pasted.
140 \item The \ctan{stix2-otf} math fonts.
141 \end{enumerate}
142 \item \withopt{tabu} \begin{enumerate}
143 \item \ctan{multirow} for cells spanning multiple rows.
144 \item \ctan{booktabs} for beautiful-by-default tables and the
145 |\cline| macro.
146 \item \ctan{tabu}, the best table package with dynamically resizable
147 columns, easy creation of new column types, and more.
148 \end{enumerate}
149 \end{enumerate}
150
151 \section{Class configuration}
152
153 \subsection{Class options}
154
155 Class options are limited to configuration options which require the loading
156 of fonts or other packages; ``string'' settings like the assignment's due
157 date are configured with the |\bpsset| command.
158
159 All class options can be negated with |no<option>|; e.g.\ \option{scheme}
160 can be disabled with \option{noscheme}. Later options override previous
161 ones.
162
163 \begin{keys}
164 \key{antonella} \onlyclass\ Use Dr.\ Antonella DiLillio's preferred
165 styles (Courier for code)
166 \key{tabu} \onlyclass\ Loads useful packages and defines commands for
167 typesetting tables.
168 \key{math} \onlyclass\ Loads utilities for typesetting mathematics.
169 Because mathematics requires specialized fonts\footnote{The
170 \textsc{stix2} math font that this package loads weighs in
171 at 740kb!} as well as several other specialized
172 packages,\footnote{Including \ctan{amsmath},
173 \ctan{mathtools}, and, with \fontspecok,
174 \ctan{unicode-math}.} this is disabled by default. Although
175 I find myself needing mathematics fonts frequently, I know
176 many students do not.
177 \key[default=true]{listings} Enables code listings and enables
178 default styles for colored keywords, pretty line numbers,
179 and so on. While only this option enables the |java|
180 environment, the \option{scheme}, \option{assembly}, and
181 \option{pseudocode} options also load and style the
182 \ctan{listings} package.
183 \key{scheme} Enable Scheme language support, in particular for the
184 \textsc{r5rs} dialect. Additionally, provides the |scheme|
185 environment.
186 \key{pseudocode} Enables the |pseudocode| environment, notably
187 useful for \cosi[data structures]{21b}.
188 \key{assembly} Enables the |assembly| environment, notably useful
189 for \cosi[operating systems]{131a}.
190 \key{solution} Show the content of |solution| environments; by
191 default, they are excluded from compilation using the
192 \ctan{comment} package.
193 \key{gantt} Loads the |ganttschedule| environment.
194 \key[default=true]{maketitle} Redefines |\maketitle| and defines
195 |\maketitlepage| to include information about the course,
196 instructor, assignment, and due date.
197 \optenables{maketitle}{option}.
198 \key[default=true]{header} Adds a header to the top of every page including
199 information about the author, assignment, due date, and
200 instructor. \optenables{header}{option}.
201 \key[default=true]{config} Enables document metadata like the
202 assignment's due date, name/number, instructor, and course
203 through the |\bpsset| command, which supports |\maketitle|,
204 page headers, and so on.
205 \end{keys}
206
207 \subsubsection{Class options or keyval options?}
208 There's trade-offs to be made either way; class options greatly simplify the
209 code (we don't have to worry about loading packages and defining commands in
210 more than one place, for the most part), but are much less flexible and
211 difficult to interface with when the package loading is hidden. At the
212 moment, package/class options provide commands and keyval options define
213 document-configuration data (like names, due dates, and the like; see
214 section~\ref{s:config} for more information).
215
216 \subsection{Configuring \bps\ after loading}\label{s:config}
217 \begin{desc}
218 |\bpsset{<options>}|
219 \end{desc}
220 Sets global \bps\ options. Mnemonic: \textbf{B}randeis \textbf{p}roblem
221 \textbf{s}et \textbf{set}up (this should feel familiar to users of the
222 \ctan{listings} package).
223
224 \begin{note}
225 |\bpsset| was renamed from |\problemsetsetup| in version 0.5.0. The
226 |\problemsetsetup| command is deprecated and will be removed in a
227 future release.
228 \end{note}
229
230 \begin{keys}
231 \key{course}[\m{course name}]
232 Course name in full.
233 \key{coursenumber}[\m{course number}]
234 Course name shorthand; use \texttt{21a} for ``\cosi{21a}''.
235 \key{assignment}[\m{assignment name}]
236 Assignment name in full.
237 \key{number}[\m{problem set number}]
238 Assignment name shorthand; use \texttt{3} for ``Problem Set 3''.
239 \key{duedate}[\m{due date}]
240 Due date, e.g.\ \texttt{2018-10-18}; not parsed at all, but
241 \href{https://en.wikipedia.org/wiki/ISO_8601}{\textsc{iso} 8601
242 dates} are highly recommended.
243 \key{instructor}[\m{course instructor}]
244 Course instructor. With the \option{antonella} class-option, this is
245 automatically set to |Dr.~Antonella DiLillio|.
246 \key{author}[\m{your name}]
247 Alternate interface for the |\author| command.
248 \key{date}[\m{document date}]
249 Alternate interface for the |\date| command.
250 \key{codefont}[\m{fontspec font name}]
251 With \fontspecok, pass the given font to |\setmonofont| and enable
252 Unicode shortcuts for the |pseudocode| environment. (If you need to
253 specify options to |\setmonofont|, use |\setcodefont|.)
254 \end{keys}
255
256 \begin{desc}
257 |\setcodefont[<fontspec options>]{<fontspec font name>}|
258 \end{desc}
259 Sets the monospaced font to \meta{fontspec font name} and uses it for
260 shortcuts in the |pseudocode| environment.
261
262 \subsection{Practical usage}
263
264 You may find it useful to define a customized document class for each
265 course. There's no reason to install these to some system-wide directory; it
266 makes sense for them to live in the same directory as the problem set source
267 files. For instance, \filename{cosi21a.cls} might read:
268
269 \begin{latexfile}{cosi21a.cls}
270 \LoadClass[antonella, pseudocode]{brandeis-problemset}
271
272 % pass all unknown options to brandeis-problemset
273 \DeclareOption*{\PassOptionsToClass
274 {\CurrentOption}{brandeis-problemset}}
275 \ProcessOptions\relax
276
277 % set course/author data
278 \bpsset{
279 coursenumber=21a,
280 author=Rebecca Turner,
281 }
282
283 % get a prettier code font -- these can be pretty big so they're not
284 % loaded by default
285 \setcodefont[
286 Extension = .otf,
287 UprightFont = *-Regular,
288 BoldFont = *-Bold,
289 ]{FiraMono}
290 \end{latexfile}
291
292 and then \filename{ps1.tex} might read:
293
294 \begin{latexfile}{ps1.tex}
295 \documentclass{cosi21a}
296 % stuff specific to this assignment
297 \bpsset{
298 number=1,
299 duedate=2018-10-29,
300 }
301 \begin{document}
302 % etc.
303 \end{document}
304 \end{latexfile}
305
306 Note that you could use e.g.~|\documentclass[math]{cosi21a}| to add a
307 specific per-document option. See section~\ref{sec:example} for a more
308 complete example.
309
310 \section{User commands and environments}
311
312 \bps\ provides a number of commands for typesetting problems.
313
314 \begin{desc}
315 |\begin{problem}[<options>]...\end{problem}|
316 \end{desc}
317 Defines a problem. A problem is set 1~inch from the left margin (although
318 this amount may be customized by modifying the |\problemindent| length) and
319 begins a new page.
320
321 \begin{note}
322 The |problem| and |subproblem| environments are typeset using
323 |\section| and |\subsection| respectively, and as such can be
324 customized with styling packages like \ctan{titlesec}; note,
325 however, that they ignore and hide the usual section counters.
326 \end{note}
327
328 |<options>| may include:
329 \begin{keys}
330 \key{title}[\m{problem title}]
331 Displayed after ``Problem'' and the problem's number.
332 \key{number}[\m{problem number}]
333 If given, the problem-number counter will not advance. The number
334 must be robust, because it goes inside a |\section|.
335 \key{pagebreak}[\bool][true]
336 Add a pagebreak before the problem?
337 \key{label}[\m{problem label}]
338 Adds a custom label to the problem with |\label| that can be used
339 with |\ref|. I recommend prefixing your problem labels with |p:| as
340 in |p:big-o-proofs|.
341 \key{toc}[\bool][true]
342 Include this problem in the table of contents?
343 \key{part}[\m{part name}]
344 Indicates that this problem starts a new ``part'' of the assignment;
345 actually calls |\part| under the hood.
346 \key{partlabel}[\m{part label}]
347 Adds a custom label to this part in the same fashion as the
348 \option{label} key.
349 \end{keys}
350
351 Vertical material is allowed in a~|problem|.
352
353 \begin{desc}
354 |\begin{subproblem}[<options>]...\end{subproblem}|
355 \end{desc}
356 Defines a subproblem. A subproblem is set 1~inch from the left margin
357 (although this amount may be customized by modifying the |\subproblemindent|
358 length) and begins a new page. Valid |<options>| are identical to the
359 |problem| environment's, with the following exceptions:
360 \begin{keys}
361 \key[default=false]{pagebreak}
362 False by default.
363 \key{part}
364 \key{partlabel}
365 Not available in the |subproblem| environment.
366 \end{keys}
367
368 \begin{example}
369 Note that although these examples are too short to display them,
370 vertical material --- including listings --- is allowed in the
371 |problem| and |subproblem| environments.
372 \end{example}
373 \begin{LTXexample}[preset={
374 \presetkeys{problem}{toc=false}{}
375 \presetkeys{subproblem}{toc=false}{}
376 }]
377 \begin{problem}
378 This is a problem in an assignment.
379 \end{problem}
380
381 Some solution here\dots
382
383 \begin{subproblem}
384 This is a subproblem.
385 \end{subproblem}
386 \end{LTXexample}
387
388 \begin{desc}
389 |\begin{solution}...\end{solution}|
390 \end{desc}
391
392 Defines a solution for a problem; a solution prints in blue and is excluded
393 from the compiled document entirely unless the \option{solutions} package
394 option is given.
395
396 In this way, the same \extension{tex} file can serve as both a postable
397 assignment prompt and an answer key.
398
399 \begin{note}
400 The style of solutions is customizable by redefining
401 |\solutionstyle|; it's defined to |\color{blue}| by default.
402 \end{note}
403
404 \begin{example}
405 The default solution style is shown below; note, however, that this
406 document is compiled with the \option{solution} option passed to
407 \bps; without it, the typeset solution is entirely blank.
408 \end{example}
409 \begin{LTXexample}
410 \begin{solution}
411 Some solution here\dots
412 \end{solution}
413 \end{LTXexample}
414
415 \begin{desc}
416 |\Th[<column spec>]{<header text>}|
417 \end{desc}
418
419 Typesets a table header in bold-face. |<column spec>| defaults to |l|.
420 Useful for when a column is wrapped in a math environment; if you have a
421 column |>>{\ttfamily}l|, using |\Th| will not print the header in
422 |\ttfamily|.
423
424 \begin{LTXexample}
425 \begin{tabular}{ll}
426 \Th{Server} & \Th{\textsc{ip}} \\
427 juice & 1.1.1.1 \\
428 dogs & 2.2.2.2 \\
429 \end{tabular}
430 \end{LTXexample}
431
432 \begin{desc}
433 |\begin{pseudocode}[<keywords>]...\end{pseudocode}|
434 \end{desc}
435 Prints pseudocode.\footnote{Designed for \cosi{21a} as taught by Dr.\
436 Antonella DiLillo}
437
438 Several ``shortcuts,'' which replace a source-code sequence like
439 \texttt{->} with a symbol like \texttt{→}, are shown in
440 table~\ref{tab:pseudocode}.
441
442 These shortcuts display in |\pseudocodesymbolfont| (default:
443 |\ttfamily|), which may be redefined if you prefer something else. The
444 easiest way to change |\pseudocodesymbolfont| is with |\setcodefont|. If
445 you use the \option{antonella} option with \fontspecok, \bps\ will load
446 \ctan{lm-math} and display the symbols seen in table~\ref{tab:pseudocode},
447 which look significantly better with Courier than \ctan{stix}' symbols.
448
449 The following words are treated as keywords in pseudocode, and will be
450 bolded as appropriate: |Input|, |Output|, |Complexity|, |while|, |do|,
451 |return|, |for|, |to|, |if|, |then|, |else|, |True|, |False|, |None|, |and|,
452 |or|, |nil|, and |len|.
453
454 \begin{table}[h]
455 \centering
456 \caption{Shortcuts provided by the \texttt{pseudocode}
457 environment}%
458 \label{tab:pseudocode}
459 \begin{tabular}{llll}
460 \Th{Input} & \Th{Command} & \Th{Display} & \Th{Codepoint} \\
461 \ttfamily <- & |\pseudocodeleftarrow| & \pseudocodeleftarrow & \unicode{2190} \\
462 \ttfamily -> & |\pseudocoderightarrow| & \pseudocoderightarrow & \unicode{2192} \\
463 \ttfamily (/) & |\pseudocodeemptyset| & \pseudocodeemptyset & \unicode{2205} \\
464 \ttfamily inf & |\pseudocodeinfty| & \pseudocodeinfty & \unicode{221e} \\
465 \ttfamily != & |\pseudocodene| & \pseudocodene & \unicode{2260} \\
466 \ttfamily >= & |\pseudocodege| & \pseudocodege & \unicode{2265} \\
467 \ttfamily <= & |\pseudocodele| & \pseudocodele & \unicode{2264} \\
468 \end{tabular}
469 \end{table}
470
471 \begin{example}
472 Note how the option |[Bar]| argument makes |Bar| appear bold like
473 any other keyword in the typeset listing.
474 \end{example}
475 \begin{LTXexample}[rframe=]
476 \begin{pseudocode}[Bar]
477 Bar(a, n)
478 Input: two integers, a and n
479 Output: a^n
480 k <- n # k is a counter
481 b <- inf
482 c <- a
483 while k >= 0 do
484 if k mod 2 = 0 then
485 k <- k / 2
486 c <- c * c
487 else
488 k <- k - 1
489 b <- b * c
490 return b
491 \end{pseudocode}
492 \end{LTXexample}
493
494 \begin{desc}
495 |\begin{assembly}[<listings options>]...\end{assembly}|
496 \end{desc}
497 Typesets assembly code.\footnote{Designed for \cosi{131a} as taught by Dr.\
498 Liuba Shrira} Several considerations are taken into account; most notably,
499 line numbers are printed as \texttt{x + n}, where $n$ starts at 0 and counts
500 by 4; the line number actually indicates the instruction's location in
501 memory as an offset from the program start. Additionally, all valid
502 instructions are treated as keywords and styled appropriately.
503
504 |<listings options>| is passed directly to the \ctan{listings} package.
505
506 \begin{LTXexample}[rframe=, wide,
507 explpreset={basicstyle=\small\ttfamily, basewidth=0.575em,},
508 preset=\lstset{numbers=left, basicstyle=\small\ttfamily, basewidth=0.575em,},]
509 \begin{assembly}
510 LOAD R4, $200 ; sum addr
511 LOAD R1, =0 ; sum
512 LOAD R2, =0 ; i
513 LOAD R3, =0 ; j
514 BR OUTER ; we know i < 10
515 INNER:
516 ADD R1, R3 ; sum += j
517 INC R3 ; j++
518 OUTER:
519 BLT R3, R2, INNER ; while j < i goto inner
520 INC R2 ; i++
521 LOAD R3, =0 ; j = 0
522 BLT R2, =10, OUTER ; while i < 10 goto outer
523 STORE R1, @R4 ; store sum
524 HALT
525 \end{assembly}
526 \end{LTXexample}
527
528 \begin{desc}
529 |\begin{java}[<listings options>]...\end{java}|
530 \end{desc}
531 Tragically-common shorthand environment for a listing of Java code.
532
533 |<listings options>| is passed directly to the \ctan{listings} package.
534
535 \begin{desc}
536 |\begin{scheme}[<listings options>]...\end{scheme}|
537 \end{desc}
538 Shorthand environment for a listing of Scheme code, useful for \cosi{121b}.
539 Requires the \option{scheme} package option to be loaded.
540
541 |<listings options>| is passed directly to the \ctan{listings} package.
542
543 \begin{desc}
544 |\begin{ganttschedule}[<total cell count>]...\end{ganttschedule}|
545 \end{desc}
546 An environment for drawing Gantt charts indicating process scheduling. The
547 mandatory argument indicates how small the grid should be; \texttt{19}
548 subdivides the line into 19 cells.
549
550 To use the |ganttschedule| environment, make sure to use the
551 \option{gantt} package option.
552
553 Within a |ganttschedule|, use the |\burst| command to indicate an
554 active process (i.e.\ a process burst).
555
556 \begin{note}
557 The charts |ganttschedule| draws aren't actually really proper Gantt
558 charts, which can indicate parallel activities; however, that's what
559 Liuba calls them, so that's what they're called here.
560 \end{note}
561
562 \begin{desc}
563 |\pid{<pid>}{<burst length>}|
564 \end{desc}
565 Draw a burst for process |<pid>| of time length |<burst length>|.
566
567 \begin{note}
568 The Gantt chart packages (notably \ctan{tikz}) don't play nicely
569 with \ctan{ltxguidex}, the package this documentation is written in;
570 for a typeset example, see section~\ref{sec:example}.
571 \end{note}
572
573 \begin{latexcode}
574 \begin{ganttschedule}{19}
575 \pid{2}{1}
576 \pid{4}{1}
577 \pid{3}{2}
578 \pid{5}{5}
579 \pid{1}{10}
580 \end{ganttschedule}
581 \end{latexcode}
582
583 \begin{note}
584 Because |ganttschedule| relies on \ctan{tikz}, \ctan{fp}, and
585 \ctan{calc}, it can add significantly to document compile times. If
586 you intend to use the |ganttschedule| environment, make sure to use
587 the \option{gantt} class option or set \option{gantt} in
588 |\bpsset|. If you fail to include the \option{gantt}
589 option, you will see an error message:
590
591 \begin{latexcode}
592 ! Package brandeis-problemset Error: ganttschedule enviornment not loaded in preamble.
593
594 See the brandeis-problemset package documentation for explanation.
595 Type H <return> for immediate help.
596 l.4 \burst
597 {1}{1}
598 ? H
599 Did you mean to use the 'gantt' option for the brandeis-problemset document class?
600
601 \end{latexcode}
602 \end{note}
603
604 \subsection{General formatting commands}
605
606 \begin{desc}
607 |\newacronym[<command>]{<acronym text>}|\\
608 |\newacronyms{<acronym list>}|
609 \end{desc}
610
611 Creates a new acronym. If |<command>| isn't given, the text of the macro
612 will be used instead; |\newacronym{cfg}| would define a command |\cfg| which
613 typesets as ``\ac{cfg}''. If the
614 resulting command already exists, it will be redefined. For |\newacronyms|, the
615 |<acronym list>| is a comma-delimited list of acronyms.
616
617 \begin{LTXexample}
618 \newacronym[\xyz]{cfg}
619 A \xyz\ describes a context-free language\dots
620
621 \newacronyms{sparc, cpu}
622 The \sparc\ had a unique \cpu\dots
623 \end{LTXexample}
624
625
626 \begin{desc}
627 |\ac{<acronym>}|
628 \end{desc}
629 Typesets an acronym. The |<acronym>| should be lowercase (e.g.\ |\ac{cpu}|
630 rather than |\ac{CPU}|). Currently, |\ac| simply delegates to |\textsc|. In
631 the future, I'd like to support a bit of letterspacing; ``for abbreviations
632 and acronyms in the midst of normal text, use spaced small
633 caps.''\footnote{\textit{The Elements of Typographic Style} by Robert
634 Bringhurst, 2nd.\ ed, \S\ 3.2.2}
635
636 \begin{desc}|\Sc{<text>}|\end{desc}
637 An abbreviation for |\textsc|.
638 \begin{desc}|\Rm{<text>}|\end{desc}
639 An abbreviation for |\textrm|.
640 \begin{desc}|\Up{<text>}|\end{desc}
641 An abbreviation for |\textup|.
642 \begin{desc}|\Bf{<text>}|\end{desc}
643 An abbreviation for |\textbf|.
644 \begin{desc}|\It{<text>}|\end{desc}
645 An abbreviation for |\textit|.
646 \begin{desc}|\Tt{<text>}|\end{desc}
647 An abbreviation for |\texttt|.
648
649 \section{A class and a package}
650 As a user, you'll likely only need the \bps\ document class. However,
651 a \emph{package} named \bps\ is also provided. The class styles an entire
652 document, while the package only provides commands. This allows --- for
653 example --- loading the package for the examples in this document without
654 messing up our titles, headers, and so on.
655
656 \section{Example}\label{sec:example}
657
658 A brief example usage of \bps\ follows. For a longer, more in-depth example,
659 see
660 \href{https://github.com/9999years/brandeis-problemset/blob/master/example.tex}{\filename{example.tex}
661 in the \bps\ repository.}
662
663 \begin{latexcode}
664 \documentclass[gantt]{brandeis-problemset}
665 \author{Rebecca Turner}
666 \bpsset{
667 coursenumber=21a,
668 instructor=Dr.\ Liuba Shrira,
669 duedate=2018-10-20,
670 number=3,
671 }
672 \newcommand{\io}{\ac{io}}
673 \newcommand{\cpu}{\ac{cpu}}
674 \begin{document}
675
676 \begin{problem}
677 Write an assembly program!
678 \end{problem}
679
680 \begin{assembly}
681 LOAD R1, $200 ; A = (program location) + 200
682 LOAD R2, =1 ; i = 1
683 \end{assembly}
684
685 \begin{problem}
686 What does this algorithm do? Analyze its worst-case running time and
687 express it using big-O notation.
688
689 \begin{pseudocode}[Foo]
690 Foo(a, n)
691 Input: two integers, a and n
692 Output: a^n
693 k <- 0
694 b <- 1
695 while k < n do
696 k <- k + 1
697 b <- b * a
698 return b
699 \end{pseudocode}
700 \end{problem}
701
702 $\Rm{Foo}(a, n)$ computes $a^n$, and will run in $O(n)$ time always.
703
704 \begin{problem}[number=5.4]
705 Consider the following set of processes, with the length of the
706 \cpu\ burst given in milliseconds:
707
708 \begin{center}
709 \begin{tabu} to 0.25\linewidth{X[1,$]rr}
710 \Th{Process} & \Th{Burst time} & \Th{Priority} \\
711 P_1 & 10 & 3 \\
712 P_2 & 1 & 1 \\
713 P_3 & 2 & 3 \\
714 P_4 & 1 & 4 \\
715 P_5 & 5 & 2 \\
716 \end{tabu}
717 \end{center}%$
718
719 Draw a Gantt chart to illustrate the execution of these processes
720 using the \ac{sjf} scheduling algorith.
721 \end{problem}
722
723 \begin{ganttschedule}{19}
724 \pid{2}{1}
725 \pid{4}{1}
726 \pid{3}{2}
727 \pid{5}{5}
728 \pid{1}{10}
729 \end{ganttschedule}
730 \end{document}
731 \end{latexcode}%stopzone
732
733 \begin{changelog}[author=Rebecca Turner]
734 \begin{version}[v=Coming soon\dots]
735 \added
736 \item Support for \cosi{130b}, including regular expressions and
737 context-free grammars.
738 \end{version}
739
740 \shortversion{v=0.5.5, date=2019-04-10, changes={Reordered package loading
741 to prevent \ctan{mathtools} from breaking \cs{overbrace} and \cs{underbrace}
742 commands.}}
743
744 \shortversion{v=0.5.4, date=2019-04-02, changes={Fixed hanging indent in
745 \texttt{description}-lists; the hanging indent was accidentally
746 removed through a tweak to hang the list item markers for the
747 \texttt{itemize} and \texttt{enumerate} lists.}}
748
749 \shortversion{v=0.5.3, date=2019-03-30, changes={Commands such as
750 \cs{texttt} won't automatically cause errors when used in the optional
751 arguments of the \texttt{problem} and \texttt{subproblem} environments.
752 More complex commands may still cause issues, however.}}
753
754 \shortversion{v=0.5.2, date=2019-03-13, changes={Scheme code highlighting
755 erroneously highlighted \texttt{c\textbf{b}r},
756 \texttt{ca\textbf{b}r}, etc.\ rather than
757 \texttt{c\textbf{d}r},\texttt{ca\textbf{d}r}, etc. These keywords
758 have been renamed.}}
759
760 \shortversion{v=0.5.1, date=2019-03-09, changes={Distribution erroneously
761 excluded \filename{brandeis-problemset.sty}.}}
762
763 \begin{version}[v=0.5.0, date=2019-03-06]
764 \added
765 \item |\newacronym| and |\newacronyms| commands.
766 \item Added \option{toc} option to the |problem| and |subproblem|
767 environments.
768 \changed
769 \item Cleaned up internals; improved option system, split \bps\ into
770 a class and a package, renamed commands and lengths to use the
771 |bps@| prefix more consistently.
772 \item \bps\ now has a modular and much more conservative approach;
773 far fewer packages are loaded and features are loaded only upon
774 request to a much greater extent.
775 \item |subproblem| is now an environment, not a command, with an
776 interface matching the |problem| environment.
777 \item The \option{assembly} and \option{pseudocode} options now
778 define languages for the \ctan{listings} package, rather than just
779 providing environments to use the languages.
780 \removed
781 \item The following commands have been removed in favor of the
782 |\bpsset| command, which encompasses their functionality
783 entirely:
784 |\duedate{<date>}|,
785 |\instructor{<name>}|,
786 |\course{<name>}|,
787 |\coursenumber{<number>}|,
788 |\assignment{<name>}|, and
789 |\problemsetnumber{<number>}|.
790 \item Removed dependencies: \ctan{environ} and \ctan{titlesec}. No
791 longer unconditionally loaded: \ctan{hyperref},
792 \ctan{xcolor}, \ctan{comment}, \ctan{listings},
793 \ctan{multirow}, \ctan{booktabs}, \ctan{longtable},
794 \ctan{tabu}.
795 \deprecated
796 \item The |\problemsetsetup| command, which has been renamed
797 |\bpsset|.
798 \end{version}
799
800 \begin{version}[v=0.4.4, date=2019-02-14]
801 \changed
802 \item Changed Times body copy font from \ctan{tex-gyre}'s Termes to
803 the newer \ctan{stix2-otf} (for \fontspecok) and \ctan{stix2-type1}
804 (for other \TeX\ engines) --- the \textsc{stix2} fonts are somewhat
805 unique amongst Times-likes in that they contain small caps.
806
807 \item Redefined |\Re| to print in blackboard-bold.
808 \end{version}
809
810 \shortversion{v=0.4.3, date=2019-01-20,
811 changes={Fixed typos in license file, fixed distributed
812 documentation \extension{pdf}.}}
813
814 \begin{version}[v=0.4.2, date=2019-01-19]
815 \added
816 \item |author| and |date| keys added to |\problemsetsetup| to
817 simplify class-wide configuration.
818 \fixed
819 \item Fixed definitions for |\duedate|, |\instructor|, etc.\ to
820 avoid spurious errors due to undefined commands.
821 \changed
822 \item Translated documentation to the new \ctan{ltxguidex} document
823 class for added beauty.
824 \item Re-licensed \bps\ to the \textsc{lppl} v1.3c for easy transfer of
825 maintenence in the future.
826 \end{version}
827
828 \shortversion{v=0.4.1, date=2019-01-03,
829 changes={Updated |scheme| environment to properly recognize all
830 primitive functions, added syntax coloring to all code.}}
831
832 \begin{version}[v=0.4.0, date=2018-12-20]
833 \added
834 \item |solution| environment and \option{solutions} class
835 option.
836 \item |scheme| shorthand environment and \option{scheme} class
837 option.
838 \fixed
839 \item Boolean class options being overwritten by keys defined for
840 |\problemsetsetup|.
841 \item Title-formatting errors
842 \removed
843 \item Assignment- and course-specific class options
844 \option{duedate}, \option{assignment}, \option{instructor},
845 and \option{course}. These settings should be configured
846 with either |\problemsetsetup| or their specific commands.
847 (|\duedate|, |\instructor|, etc.).
848 \end{version}
849
850 \begin{version}[v=0.3.0, date=2018-10-24]
851 \added
852 \item This changelog.
853 \item Support for |\part|s and referencing problems.
854 \item Options to |problem| environment: \option{part},
855 \option{label}, and \option{partlabel}.
856 \item |\maketitle| (contrast with |\maketitlepage|).
857 \end{version}
858
859 \begin{version}[v=0.2.0, date=2018-10-20]
860 \changed
861 \item Class renamed to from \ltxclass{problemset} to \bps.
862 \added
863 \item A license header.
864 \item |ganttschedule| environment.
865 \item Additional keywords for |pseudocode| environment:
866 \texttt{and}, \texttt{or}, \texttt{nil}, and \texttt{len}.
867 \item |\ac| command for acronyms.
868 \item An example document.
869 \end{version}
870
871 \shortversion{v=0.1.0, date=2018-10-19,
872 changes=Initial beta as \ltxclass{problemset}.}
873 \end{changelog}
874 \end{document}