Rename \U to \unit in wtk_cmmds.sty.
[problempack.git] / wtk_cmmds.sty
1 % wtk_cmmds.sty, assorted macros useful to W. Trevor King (mostly for physics)
2 %
3 % Copyright (C) 2009-2012 W. Trevor King <wking@tremily.us>
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}[2012/04/11 0.3 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{\unit}[1]{\textnormal{\ \bareU{#1}}}   % units shortcut
40 \providecommand{\U}[1]{\unit{#1}}
41 \newcommand{\bareU}[1]{\textnormal{#1}}         % units without preceding value
42 \newcommand{\E}[1]{\ensuremath{\cdot 10 ^{#1}}} % exponent shortcut
43 \newcommand{\dg}{\ensuremath{^{\circ}}}         % degree symbol ^o
44 \newcommand{\celsius}{\dg\text{C}}              % degrees Celsius
45 \newcommand{\farenheit}{\dg\text{F}}            % degrees Farenheit
46 \newcommand{\vect}[1]{\ensuremath{\mathbf{#1}}} % make vectors bold
47
48 \newcommand{\Ohm}{\ensuremath{\Omega}} % units of resistance
49 \newcommand{\EMF}{\ensuremath{\mathcal{E}}} % electro-motive force
50
51 \newcommand{\ihat}{\vect{\hat{i}}}
52 \newcommand{\jhat}{\vect{\hat{j}}}
53 \newcommand{\khat}{\vect{\hat{k}}}
54 \newcommand{\rhat}{\vect{\hat{r}}}
55
56 \newcommand{\avg}[1]{\ensuremath{\left\langle {#1} \right\rangle}} % average
57 \newcommand{\dt}[1]{\ensuremath{\dot{#1}}} % first deriv with respect to time
58 \newcommand{\ddt}[1]{\ensuremath{\ddot{#1}}} % 2nd deriv with respect to time
59 % the proper d to be used in derivatives and integrals
60 \newcommand{\dd}{\ensuremath{\mathrm d}}
61 % derivative of #2 with respect to #1
62 \newcommand{\deriv}[2]{\ensuremath{\frac{\dd{#2}}{\dd{#1}}}}
63 % #1th order derivative of #3 with respect to #2
64 \newcommand{\nderiv}[3]{\ensuremath{\frac{\dd^{#1}{#3}}{\dd{#2}^{#1}}}}
65 % partial derivative of #2 with respect to #1
66 \newcommand{\pderiv}[2]{\ensuremath{\frac{\partial#2}{\partial#1}}}
67 % #1th order partial derivative of #3 with respect to #2
68 \newcommand{\npderiv}[3]{\ensuremath{\frac{\partial^{#1}{#3}}{\partial{#2}^{#1}}}}
69
70 % floor operator, for example \floor(2.7) = 2.
71 \newcommand{\floor}{\operatorname{floor}}
72
73 % parenthesis, for example (some stuff] would be \p({some stuff}]
74 \newcommand{\p}[3]{\left#1 #2 \right#3}
75
76 % parts for multi-part problems and solutions (use problempack.sty instead)
77 %\newcommand{\Part}[1]{\textcolor{Red}{(#1)}}
78 % highlight answers in solutions
79 %\newcommand{\ans}[1]{\textcolor{Red}{#1}}
80
81 % struts for table spacing
82 \newcommand{\Tstrut}{\rule{0pt}{2.6ex}}
83 \newcommand{\Bstrut}{\rule[-1.2ex]{0pt}{0pt}}
84
85 % \numberwithin{equation}{section}% number equations by section
86 % \setcounter{secnumdepth}{0}     % turn off section numbering below this level
87
88
89 % tighter lists, a la alvin alexander
90 % http://www.devdaily.com/blog/post/latex/control-line-spacing-in-itemize-enumerate-tags/
91
92 \newenvironment{packed_enum}{
93 \begin{enumerate}
94   \setlength{\itemsep}{1pt}
95   \setlength{\parskip}{0pt}
96   \setlength{\parsep}{0pt}
97 }{\end{enumerate}}
98
99 \newenvironment{packed_item}{
100 \begin{itemize}
101   \setlength{\itemsep}{1pt}
102   \setlength{\parskip}{0pt}
103   \setlength{\parsep}{0pt}
104 }{\end{itemize}}