Add test/ directory with some example code.
[problempack.git] / test / problems.tex
1 \maketitle
2
3 We'll start with some automatically numbered problems \ldots
4
5 \begin{problem}
6 A problem \Part{a} with \Part{b} parts.
7 \end{problem}
8 \begin{solution}
9 \Part{a} A solution with \ans{answers}.
10 \end{solution}
11
12 \begin{problem}
13 What is $5\U{Hz}$ times $10^{-3}\U{m}$?
14 \end{problem}
15 \begin{solution}
16 \Part{a} Another solution.
17 \Part{b} this time with numbers:
18 $5\U{Hz}\cdot10^{-3}\U{m} = \ans{5\E{-3}\U{m/s}}$.
19 \end{solution}
20
21 \ldots and move on to an explicitly numered problem.
22
23 \begin{problem*}{98}
24 An apparently difficult problem.
25 \end{problem*}
26 \begin{solution}
27 But still easily solved.
28 \end{solution}
29
30 \begin{problem*}{101}
31 The last problem: draw the direction of any forces.
32 \end{problem*}
33 % this is a bit tricky, since we have one drawing that we'd like to show
34 % for nosolutions (just the charges), and another we would like to show
35 % when solutions are on that is very similar (charges+forces).
36 % the parts of the drawing common to both get defined as a macro:
37 \newcommand{\problemOneOhOneBaseFigure}{
38   \coordinate (A) at ($ (0,0) + 0.5*(rand,rand) $);
39   \coordinate (B) at ($ (3,1) + 0.5*(rand,rand) $);
40   \fill[red] (A) circle (6pt);
41   \fill[blue] (B) circle (3pt);
42   \node at (A) [below=8pt] {A};
43   \node at (B) [below=8pt] {B};
44 }
45
46 \begin{nosolution}
47 \begin{center}
48 \begin{tikzpicture}
49   \problemOneOhOneBaseFigure{}
50 \end{tikzpicture}
51 \end{center}
52 \end{nosolution}
53
54 \begin{solution}
55 \begin{center}
56 \begin{tikzpicture}
57   \problemOneOhOneBaseFigure{}
58   \begin{pgfonlayer}{background}
59     \draw[->] (A) -- ($ (A) ! -0.3 ! (B) $) node[pos=1,left=8pt] {\vbox{\hbox{$F_{BA}$}\hbox{($B$ on $A$)}}};
60     \draw[->] (B) -- ($ (B) ! -0.3 ! (A) $) node[pos=1,right=8pt] {\vbox{\hbox{$F_{AB}$}\hbox{($A$ on $B$)}}};
61   \end{pgfonlayer}
62 \end{tikzpicture}
63 \end{center}
64 \end{solution}
65
66 Note that the problem-separating space occurs after the nosolution
67 section in nosolution mode.