Add test/ directory with some example code.
[problempack.git] / wtk_cmmds.sty
1 % Assorted macros useful to W. Trevor King (mostly for physics)
2 %
3 % Released to the public domain.
4
5 \RequirePackage{relsize} % for \smaller
6 \RequirePackage{amsmath} % for \text{}
7
8 % Author, Copyright junk
9 \newcommand{\copytitle}{
10   \begin{center}
11     Copyright \copyright\ \today\ by W.\ Trevor King\\
12     \smaller{This document is distributed under the GNU Free Documentation License.}
13   \end{center}
14 }
15
16 % define theorem environments
17 \newtheorem{thm}{Theorem}
18 \newtheorem{cor}[thm]{Corollary}
19 \newtheorem{lem}{Lemma}
20
21 \newcommand{\U}[1]{\text{ #1}}                  % units shortcut
22 \newcommand{\E}[1]{\ensuremath{\cdot 10 ^{#1}}} % exponent shortcut
23 \newcommand{\dg}{\ensuremath{^{\circ}}}         % degree symbol ^o
24 \newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}} % make vectors bold
25
26 \newcommand{\Ohm}{\ensuremath{\Omega}} % units of resistance
27 \newcommand{\EMF}{\ensuremath{\mathcal{E}}} % electro-motive force
28
29 \newcommand{\ihat}{\vect{\hat{i}}}
30 \newcommand{\jhat}{\vect{\hat{j}}}
31 \newcommand{\khat}{\vect{\hat{k}}}
32 \newcommand{\rhat}{\vect{\hat{r}}}
33
34 \newcommand{\avg}[1]{\ensuremath{\left\langle {#1} \right\rangle}} % average
35 \newcommand{\dt}[1]{\ensuremath{\dot{#1}}} % first deriv with respect to time
36 \newcommand{\ddt}[1]{\ensuremath{\ddot{#1}}} % 2nd deriv with respect to time
37 % the proper d to be used in derivatives and integrals
38 \newcommand{\dd}{\ensuremath{\mathrm d}}
39 % derivative of #2 with respect to #1
40 \newcommand{\deriv}[2]{\ensuremath{\frac{\dd{#2}}{\dd{#1}}}}
41 % #1th order derivative of #3 with respect to #2
42 \newcommand{\nderiv}[3]{\ensuremath{\frac{\dd^{#1}{#3}}{\dd{#2}^{#1}}}}
43 % partial derivative of #2 with respect to #1
44 \newcommand{\pderiv}[2]{\ensuremath{\frac{\partial#2}{\partial#1}}}
45 % #1th order partial derivative of #3 with respect to #2
46 \newcommand{\npderiv}[3]{\ensuremath{\frac{\partial^{#1}{#3}}{\partial{#2}^{#1}}}}
47
48 % parenthesis, for example (some stuff] would be \p({some stuff}]
49 \newcommand{\p}[3]{\left#1 #2 \right#3}
50
51 % parts for multi-part problems and solutions (use problempack.sty instead)
52 %\newcommand{\Part}[1]{\textcolor{Red}{(#1)}}
53 % highlight answers in solutions
54 %\newcommand{\ans}[1]{\textcolor{Red}{#1}}
55
56 % struts for table spacing
57 \newcommand{\Tstrut}{\rule{0pt}{2.6ex}}
58 \newcommand{\Bstrut}{\rule[-1.2ex]{0pt}{0pt}}
59
60 % \numberwithin{equation}{section}% number equations by section
61 % \setcounter{secnumdepth}{0}     % turn off section numbering below this level
62
63
64 % tighter lists, a la alvin alexander
65 % http://www.devdaily.com/blog/post/latex/control-line-spacing-in-itemize-enumerate-tags/
66
67 \newenvironment{packed_enum}{
68 \begin{enumerate}
69   \setlength{\itemsep}{1pt}
70   \setlength{\parskip}{0pt}
71   \setlength{\parsep}{0pt}
72 }{\end{enumerate}}
73
74 \newenvironment{packed_item}{
75 \begin{itemize}
76   \setlength{\itemsep}{1pt}
77   \setlength{\parskip}{0pt}
78   \setlength{\parsep}{0pt}
79 }{\end{itemize}}