From 32c5084fa7a557049ae2cb4002f88413d541c595 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 14 Oct 2010 08:24:54 -0400 Subject: [PATCH] Add test/ directory with some example code. --- test/Makefile | 23 ++++++++++++++++ test/problems.tex | 67 +++++++++++++++++++++++++++++++++++++++++++++++ test/probs.tex | 17 ++++++++++++ test/sols.tex | 17 ++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 test/Makefile create mode 100644 test/problems.tex create mode 100644 test/probs.tex create mode 100644 test/sols.tex diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..9f174ed --- /dev/null +++ b/test/Makefile @@ -0,0 +1,23 @@ +# each MetaPost graphic has it's own file, +# so the basic definitions should get bundled out into an external file +# (encourages reuse anyway, so it's good for you :p) + +all : sols.pdf probs.pdf + +view : vprobs vsols + +vprobs : probs.pdf + xpdf $< & + +vsols : sols.pdf + xpdf $< & + +%.pdf : %.tex problems.tex + TEXINPUTS="..:" pdflatex $< + TEXINPUTS="..:" pdflatex $< + +semi-clean : + rm -f *.1 *.log *.mp *.mpx *.aux *.out *.cut + +clean : semi-clean + rm -f *.pdf diff --git a/test/problems.tex b/test/problems.tex new file mode 100644 index 0000000..5d6b277 --- /dev/null +++ b/test/problems.tex @@ -0,0 +1,67 @@ +\maketitle + +We'll start with some automatically numbered problems \ldots + +\begin{problem} +A problem \Part{a} with \Part{b} parts. +\end{problem} +\begin{solution} +\Part{a} A solution with \ans{answers}. +\end{solution} + +\begin{problem} +What is $5\U{Hz}$ times $10^{-3}\U{m}$? +\end{problem} +\begin{solution} +\Part{a} Another solution. +\Part{b} this time with numbers: +$5\U{Hz}\cdot10^{-3}\U{m} = \ans{5\E{-3}\U{m/s}}$. +\end{solution} + +\ldots and move on to an explicitly numered problem. + +\begin{problem*}{98} +An apparently difficult problem. +\end{problem*} +\begin{solution} +But still easily solved. +\end{solution} + +\begin{problem*}{101} +The last problem: draw the direction of any forces. +\end{problem*} +% this is a bit tricky, since we have one drawing that we'd like to show +% for nosolutions (just the charges), and another we would like to show +% when solutions are on that is very similar (charges+forces). +% the parts of the drawing common to both get defined as a macro: +\newcommand{\problemOneOhOneBaseFigure}{ + \coordinate (A) at ($ (0,0) + 0.5*(rand,rand) $); + \coordinate (B) at ($ (3,1) + 0.5*(rand,rand) $); + \fill[red] (A) circle (6pt); + \fill[blue] (B) circle (3pt); + \node at (A) [below=8pt] {A}; + \node at (B) [below=8pt] {B}; +} + +\begin{nosolution} +\begin{center} +\begin{tikzpicture} + \problemOneOhOneBaseFigure{} +\end{tikzpicture} +\end{center} +\end{nosolution} + +\begin{solution} +\begin{center} +\begin{tikzpicture} + \problemOneOhOneBaseFigure{} + \begin{pgfonlayer}{background} + \draw[->] (A) -- ($ (A) ! -0.3 ! (B) $) node[pos=1,left=8pt] {\vbox{\hbox{$F_{BA}$}\hbox{($B$ on $A$)}}}; + \draw[->] (B) -- ($ (B) ! -0.3 ! (A) $) node[pos=1,right=8pt] {\vbox{\hbox{$F_{AB}$}\hbox{($A$ on $B$)}}}; + \end{pgfonlayer} +\end{tikzpicture} +\end{center} +\end{solution} + +Note that the problem-separating space occurs after the nosolution +section in nosolution mode. diff --git a/test/probs.tex b/test/probs.tex new file mode 100644 index 0000000..c3c30d5 --- /dev/null +++ b/test/probs.tex @@ -0,0 +1,17 @@ +\documentclass[letterpaper, 10pt]{article} + +\usepackage[nosolutions, + author={W. Trevor King}, + coursetitle={Physics 101}, + classtitle={Recitation 1}, + subheading={Chapter 1}]{../problempack} +\usepackage{wtk_cmmds} +\usepackage{wtk_format} +\usepackage{tikz} +\usetikzlibrary{calc,backgrounds} + +\begin{document} + +\input{problems} + +\end{document} diff --git a/test/sols.tex b/test/sols.tex new file mode 100644 index 0000000..86675c9 --- /dev/null +++ b/test/sols.tex @@ -0,0 +1,17 @@ +\documentclass[letterpaper, 10pt]{article} + +\usepackage[solutions, + author={W. Trevor King}, + coursetitle={Physics 101}, + classtitle={Recitation 1}, + subheading={Chapter 1}]{../problempack} +\usepackage{wtk_cmmds} +\usepackage{wtk_format} +\usepackage{tikz} +\usetikzlibrary{calc,backgrounds} + +\begin{document} + +\input{problems} + +\end{document} -- 2.26.2