Rework problempack numbering to allow repeated X in `\problem*{X}`.
[problempack.git] / wtk_cmmds.sty
1 % wtk_cmmds.sty, assorted macros useful to W. Trevor King (mostly for physics)
2 %
3 % Copyright (C) 2009-2010 W. Trevor King <wking@drexel.edu>
4 %
5 % This program is free software; you can redistribute it and/or modify
6 % it under the terms of the GNU General Public License as published by
7 % the Free Software Foundation; either version 2 of the License, or
8 % (at your option) any later version.
9 %
10 % This program is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 % GNU General Public License for more details.
14 %
15 % You should have received a copy of the GNU General Public License along
16 % with this program; if not, write to the Free Software Foundation, Inc.,
17 % 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
19 \NeedsTeXFormat{LaTeX2e}
20 \ProvidesPackage{wtk_cmmds}[2010/10/14 0.2 wtk_cmmds]
21
22 \RequirePackage{relsize} % for \smaller
23 \RequirePackage{amsmath} % for \text{}
24
25 % Author, Copyright stuff
26 \newcommand{\copytitle}{
27   \begin{center}
28     Copyright \copyright\ \today\ by W.\ Trevor King\\
29     \smaller{This document is distributed under the GNU Free Documentation License.}
30   \end{center}
31 }
32
33 % define theorem environments
34 \newtheorem{thm}{Theorem}
35 \newtheorem{cor}[thm]{Corollary}
36 \newtheorem{lem}{Lemma}
37
38 % define a few physics shortcuts
39 \newcommand{\U}[1]{\textnormal{\ \bareU{#1}}}   % units shortcut
40 \newcommand{\bareU}[1]{\textnormal{#1}}         % units without preceding value
41 \newcommand{\E}[1]{\ensuremath{\cdot 10 ^{#1}}} % exponent shortcut
42 \newcommand{\dg}{\ensuremath{^{\circ}}}         % degree symbol ^o
43 \newcommand{\celsius}{\dg\text{C}}              % degrees Celsius
44 \newcommand{\farenheit}{\dg\text{F}}            % degrees Farenheit
45 \newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}} % make vectors bold
46
47 \newcommand{\Ohm}{\ensuremath{\Omega}} % units of resistance
48 \newcommand{\EMF}{\ensuremath{\mathcal{E}}} % electro-motive force
49
50 \newcommand{\ihat}{\vect{\hat{i}}}
51 \newcommand{\jhat}{\vect{\hat{j}}}
52 \newcommand{\khat}{\vect{\hat{k}}}
53 \newcommand{\rhat}{\vect{\hat{r}}}
54
55 \newcommand{\avg}[1]{\ensuremath{\left\langle {#1} \right\rangle}} % average
56 \newcommand{\dt}[1]{\ensuremath{\dot{#1}}} % first deriv with respect to time
57 \newcommand{\ddt}[1]{\ensuremath{\ddot{#1}}} % 2nd deriv with respect to time
58 % the proper d to be used in derivatives and integrals
59 \newcommand{\dd}{\ensuremath{\mathrm d}}
60 % derivative of #2 with respect to #1
61 \newcommand{\deriv}[2]{\ensuremath{\frac{\dd{#2}}{\dd{#1}}}}
62 % #1th order derivative of #3 with respect to #2
63 \newcommand{\nderiv}[3]{\ensuremath{\frac{\dd^{#1}{#3}}{\dd{#2}^{#1}}}}
64 % partial derivative of #2 with respect to #1
65 \newcommand{\pderiv}[2]{\ensuremath{\frac{\partial#2}{\partial#1}}}
66 % #1th order partial derivative of #3 with respect to #2
67 \newcommand{\npderiv}[3]{\ensuremath{\frac{\partial^{#1}{#3}}{\partial{#2}^{#1}}}}
68
69 % parenthesis, for example (some stuff] would be \p({some stuff}]
70 \newcommand{\p}[3]{\left#1 #2 \right#3}
71
72 % parts for multi-part problems and solutions (use problempack.sty instead)
73 %\newcommand{\Part}[1]{\textcolor{Red}{(#1)}}
74 % highlight answers in solutions
75 %\newcommand{\ans}[1]{\textcolor{Red}{#1}}
76
77 % struts for table spacing
78 \newcommand{\Tstrut}{\rule{0pt}{2.6ex}}
79 \newcommand{\Bstrut}{\rule[-1.2ex]{0pt}{0pt}}
80
81 % \numberwithin{equation}{section}% number equations by section
82 % \setcounter{secnumdepth}{0}     % turn off section numbering below this level
83
84
85 % tighter lists, a la alvin alexander
86 % http://www.devdaily.com/blog/post/latex/control-line-spacing-in-itemize-enumerate-tags/
87
88 \newenvironment{packed_enum}{
89 \begin{enumerate}
90   \setlength{\itemsep}{1pt}
91   \setlength{\parskip}{0pt}
92   \setlength{\parsep}{0pt}
93 }{\end{enumerate}}
94
95 \newenvironment{packed_item}{
96 \begin{itemize}
97   \setlength{\itemsep}{1pt}
98   \setlength{\parskip}{0pt}
99   \setlength{\parsep}{0pt}
100 }{\end{itemize}}