%% unit.dtx Copyright (C) 2004 Masao Kitano %% % \iffalse %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{unit}[2002/02/15 v4.1 Unit macros] %<*driver> \documentclass{ltxdoc} \usepackage{unit} \setcounter{StandardModuleDepth}{1} \GetFileInfo{unit.sty} \begin{document} \DocInput{unit.dtx} \end{document} % % \fi % % \title{Unit.sty -- small macros for scientific documents} % \author{Masao Kitano} % \date{\filedate} % \maketitle % % \CheckSum{120} % % \changes{v4.1}{2004/02/19} % {bug fix in sub/sur-script} % \changes{v4.0}{2004/02/2} % {\\vct compatible with sub/sur-script (by T. Sato). add \\fracpd. rm \\lesssim, \\gtrsim} % \changes{v3.1}{2002/02/15} % {\\mbox in argument of \\ket, \\bra. Better look for \\ket{-1}$.} % \changes{v3.0}{2001/05/22} % {First dtx version} % % \section{Introduction} % % This style file is a collection of small macros % for writing documents including mathematical and physical formulea. % % % \StopEventually{} % % \section{The Macros} % % \subsection{Units} % Symbols for units should be printed in a roman type in order to % avoid possible confusion with % physical quantities which are to be printed in an italic type. % For example, % \[ % M=3.5\,\U{Mg},\quad V=lhw=24\,\U{ml},\quad f=1/T=4.5\,\U{THz} % \] % In the \TeX\ math mode, however, all characters are printed in % an italic type unless indicated otherwise. % For example, simple typing |$m=10 kg$| gives a wrong result: $m=10kg$. % You should type as |$m=10\,\mathrm{kg}$| and get % $m=10\,\mathrm{kg}$ correctly. % The macro |\U| is basically an abbreviation for % |\mathrm|. % \begin{macro}{\U} % |\U{|\emph{unit}|}|\\ % By simply typing |$10\,\U{kg}$| in the math mode, % you will have $10\,\U{kg}$. % In \emph{unit}, you can use |O| and |u| instead of % |\Omega| and |\mu|, respectively. % Thus, |1.5\,\U{kO}| and |2.1\,\U{uA}| give $1.5\,\U{kO}$ and % $2.1\,\U{uA}$, respectively. % (Use |\O| and |\u| for ``O'' and ``u''; |10\,\U{\O e}| gives % $10\,\U{\O e}$.) % % \begin{macrocode} \def\U#1{{% \def\O{\mbox{O}} \def\u{\mbox{u}} \mathcode`\u=\mu \mathcode`\O=\Omega \mathrm{#1}}} % \end{macrocode} % \end{macro} % \begin{macro}{\degree} % A small circle for the units of temperature and angles. % |t=34\,\U{\degree C}| gives $t=34\,\U{\degree C}$. % \begin{macrocode} \def\degree{\mbox{$^\circ$}} % \end{macrocode} % \end{macro} % \subsection{Literals} % Literals and operators are recommended to be printed in a roman type. % Otherwise a few letters ($d$, $e$, $i$, $j$) will be reserved for % the special purposes and cannot be used for variables. % \begin{macro}{\ii} % The literal for the imaginary unit $\sqrt{-1}$. % |\ii| gives $\ii$. % \begin{macrocode} \def\ii{{\mathrm{i}}} % \end{macrocode} % \end{macro} % \begin{macro}{\jj} % It can also be printed as ``$\jj$'' by typing |\jj|. % (Electrical engineers are still sticking to this notation % for fear of the confusion with $i$, which typically represents a current. % But ``$\ii$'' and ``$i$'' can well be distinguished.) % \begin{macrocode} \def\jj{\,\mathrm{j}} % thin space before j % \end{macrocode} % \end{macro} % \begin{macro}{\ee} % The base of natural logarithm is just a literal. % |\ee^{-x}| gives $\ee^{-x}$. % \begin{macrocode} \def\ee{{\mathrm{e}}} % \end{macrocode} % \end{macro} % \subsection{Operators} % \begin{macro}{\dd} % The differential operator $\dd$ can be typed as % |\dd|. % |\dd f/\dd t| yields $\dd f/\dd t$. % (There may be someone who prefers $d$ to $\dd$, but % how can you express $\dd d/\dd t$ (the time derivative of a variable $d$)?) % \begin{macrocode} \def\dd{{\mathrm{d}}} % \end{macrocode} % \end{macro} % \begin{macro}{\Re} % The real part of a complex number. % |\Re z = (z + \cc)/2| gives $\Re z = (z + \cc)/2$. % \begin{macrocode} \def\Re{\mathop{\mathrm{Re}}} % \end{macrocode} % \end{macro} % \begin{macro}{\Im} % The imaginary part of a complex number. % |\Im z = (z - \cc)/2\ii| gives $\Im z = (z - \cc)/2\ii$. % \begin{macrocode} \def\Im{\mathop{\mathrm{Im}}} % \end{macrocode} % \end{macro} % \begin{macro}{\cc} % The complex conjugate for the previous term is often refered as % $\cc$. % |\cos x =| |(\ee^{\jj x}+\cc)/2| gives $\cos x = (\ee^{\jj x}+\cc)/2$. % \begin{macrocode} \def\cc{\mbox{c.c.}} % \end{macrocode} % \end{macro} % \subsection{Quantum Mechanics} % \begin{macro}{\Hc} % The hermitian conjugate for the previous term is often written as % $\Hc$. % \begin{macrocode} \def\Hc{\mbox{H.c.}} % \end{macrocode} % \end{macro} % \begin{macro}{\bra} % |\bra{|\emph{state}|}|\\ % Dirac's bra vectors; % |$\bra{\phi}$| yields $\bra{\phi}$. % % \begin{macrocode} \def\bra#1{\langle #1|} % \end{macrocode} % \end{macro} % \begin{macro}{\ket} % |\ket{|\emph{state}|}|\\ % Dirac's ket vectors; % |$\ket{\phi}$| yields $\ket{\phi}$. % \begin{macrocode} \def\ket#1{|\mbox{$#1$}\rangle} % \end{macrocode} % \end{macro} % \begin{macro}{\bracket} % |\bracket{|\emph{operator}|}|\\ % Expectation value for an operator. % |$\bracket{A}$| yields $\bracket{A}$. % \begin{macrocode} \def\bracket#1{\langle\mbox{$#1$}\rangle} % \end{macrocode} % \end{macro} % \begin{macro}{\bracketi} % |\bracketi{|\emph{state}|}{|\emph{state}|}|\\ % The inner product of two states. % |$\bracketi{\phi}{\psi}$| yields $\bracketi{\phi}{\psi}$. % \begin{macrocode} \def\bracketi#1#2{\langle\mbox{$#1$}|\mbox{$#2$}\rangle} % \end{macrocode} % \end{macro} % \begin{macro}{\bracketii} % |\bracketii{|\emph{state}|}{|\emph{operator}|}{|\emph{state}|}|\\ % The matrix element for an operator. % |$\bracketi{\phi}{A}{\psi}$| yields $\bracketii{\phi}{A}{\psi}$. % \begin{macrocode} \def\bracketii#1#2#3{\langle\mbox{$#1$}|\mbox{$#2$}|\mbox{$#3$}\rangle} % \end{macrocode} % \end{macro} % % % \subsection{Vector Analysis} % % \begin{macro}{\diver} % Divergence. % |$\diver \vct{D}$| yields $\diver \vct{D}$. % % \begin{macrocode} \def\diver{\mathop{\mathrm{div}}} % \end{macrocode} % \end{macro} % \begin{macro}{\curl} % Curl. % |$\curl\vct{H}$| yields $\curl\vct{H}$. % % \begin{macrocode} \def\curl{\mathop{\mathrm{curl}}} % \end{macrocode} % \end{macro} % \begin{macro}{\rot} % Rotation. % |$\rot\vct{E}$| yields $\rot\vct{E}$. % % \begin{macrocode} \def\rot{\mathop{\mathrm{rot}}} % \end{macrocode} % \end{macro} % \begin{macro}{\grad} % Gradient. % |$\grad\phi$| yields $\grad\phi$. % % \begin{macrocode} \def\grad{\mathop{\mathrm{grad}}} % \end{macrocode} % \end{macro} % % % \subsection{Others} % % \begin{macro}{\sub} % |\sub{|\emph{subscript}|}| % Descriptive subscripts should be printed in a roman type. % |k\sub{B}| for $k\sub{B}$. (``B'' for Boltzmann.) % \begin{macrocode} \def\sub#1{_{\mbox{\scriptsize#1}}} % \end{macrocode} % \end{macro} % \begin{macro}{\sur} % |\sur{|\emph{surscript}|}| % Descriptive surscripts should be printed in a roman type. % |F\sur{(R)}| for $F\sur{(R)}$. % \begin{macrocode} \def\sur#1{^{\mbox{\scriptsize#1}}} % \end{macrocode} % \end{macro} % \begin{macro}{\vct} % |\vct{|\emph{letter}|}| % Vectors should be printed in a bold italic type; % |\vct{A}| for $\vct{A}$. % \begin{macrocode} \def\vct#1{{\mathchoice{\mbox{\boldmath$#1$}}{\mbox{\boldmath$#1$}}% {\mbox{\scriptsize\boldmath$#1$}}{\mbox{\scriptsize\boldmath$#1$}}}} % \end{macrocode} % \end{macro} % \begin{macro}{\defeq} % Define. % |$p \defeq mv$| yields $p \defeq mv$. % % \begin{macrocode} \def\defeq{\stackrel{\rm def}{=}} % \end{macrocode} % \end{macro} % \begin{macro}{\ph} % |\ph{|\emph{variable}|}| % Phasor (private version) % |$\ph{E}$| yields $\ph{E}$. % % \begin{macrocode} \def\ph#1{\tilde{#1}} % phasor % \end{macrocode} % \end{macro} % \begin{macro}{\fracpd} % |\fracpd{|\emph{numerator}|}{|\emph{denominator}|}| % Partial derivative. % |$\displaystyle\fracpd{f}{x}$| yields $\displaystyle\fracpd{f}{x}$. % % \begin{macrocode} \def\fracpd#1#2{\frac{\partial#1}{\partial#2}} % \end{macrocode} % \end{macro} % \section{Summary} % \begin{tabular}{lll} % \hline macro & input & output \\ % \hline % |\U{|\emph{unit}|}| & % |F=27\,\U{N/m^2}| & % $F=27\,\U{N/m^2}$ \\ % & % |I=1.3\,\U{uA}| & % $I=1.3\,\U{uA}$ \\ % & % |R=3.3\,\U{MO}| & % $R=3.3\,\U{MO}$ \\ % & % |H=1.0\,\U{\O e}| & % $H=1.0\,\U{\O e}$ \\ % |\degree| & % |\theta=180\degree| & % $\theta=180\degree$ \\ % |\ii| & % |\exp \ii\omega t| & % $\exp \ii\omega t$ \\ % |\jj| & % |\ee^{\jj\omega t}| & % $\ee^{\jj\omega t}$ \\ % |\ee| & % |\ee^{\ii\pi}=-1| & % $\ee^{\ii\pi}=-1$ \\ % |\dd| & % |\int f(x)\dd x| & % $\int f(x)\dd x$ \\ % |\Re|, |Im| & % |z = \Re z + \ii \Im z| & % $z = \Re z + \ii \Im z$ \\ % |\cc| & % |\cos x = (\ee^{\ii x}+\cc)/2| & % $\cos x = (\ee^{\ii x}+\cc)/2$ \\ % |\bra{|\emph{st}|}|, |\ket{|\emph{st}|}| & % |\bra{\phi}|, |\ket{\psi}| & % $\bra{\phi}$, $\ket{\psi}$ \\ % |\bracket{|\emph{op}|}| & % |\bracket{A}| & % $\bracket{A}$ \\ % |\bracketi{|\emph{st}|}{|\emph{st}|}| & % |\bracketi{\phi}{\psi}| & % $\bracketi{\phi}{\psi}$ \\ % |\bracketii{|\emph{st}|}{|\emph{op}|}{|\emph{st}|}| & % |\bracketii{\phi}{A}{\psi}| & % $\bracketii{\phi}{A}{\psi}$ \\ % |\diver| & % |\diver\vct{B}=0| & % $\diver\vct{B}=0$ \\ % |\curl|, |\rot| & % |\curl\vct{E}=\rot\vct{E}=0| & % $\curl\vct{E}=\rot\vct{E}=0$ \\ % |\grad| & % |\vct{E}=-\grad\phi| & % $\vct{E}=-\grad\phi$ \\ % |\sub{|\emph{subscript}|}| & % |f\sub{max}|, |\theta\sub{B}| & % $f\sub{max}$, $\theta\sub{B}$ \\ % |\sur{|\emph{surscript}|}| & % |f\sur{max}|, |\theta\sur{(R)}| & % $f\sur{max}$, $\theta\sur{(R)}$ \\ % |\vct{|\emph{letter}|}| & % |\vct{K}|, |\vct{\Omega}| & % $\vct{K}$, $\vct{\Omega}$ \\ % & % |\ee^{\ii\vct{k}\cdot\vct{x}| & % $\ee^{\ii\vct{k}\cdot\vct{x}}$ \\ % |\defeq| & % |k_0\defeq \omega_0/c| & % $k_0\defeq \omega_0/c$ \\ % |\fracpd{|\emph{numerator}|}{|\emph{denominator}|}| & % |\displaystyle\fracpd{f}{t}| & % $\displaystyle\fracpd{f}{t}$ \\ % |\ph{|\emph{variable}|}| & % |\ph{V}\ee^{\ii\nu t}+\cc| & % $\ph{V}\ee^{\ii\nu t}+\cc$ \\ % \end{tabular} % % % \Finale