summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/isotope/isotope.dtx
blob: 1aaddeeda24f2e3360dd9e76c4cee88dd2d0d410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
% \iffalse meta-comment
%
% Copyright (C) 2003-2011 by Heiko Bauke <heiko.bauke@mpi-hd.mpg.de>
% -----------------------------------------------------------------------
% 
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.2
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
%    http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{isotope}
%<package>   [2011/08/26 v0.3 for typesetting isotopes] 
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{isotope}
\usepackage{textcomp}
\EnableCrossrefs         
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{isotope.dtx}
\end{document}
%</driver>
% \fi
%
%\CheckSum{47}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \changes{v0.1}{2003/12/31}{Initial version.}
%
% \GetFileInfo{isotope.sty}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
%
% \title{The \textsf{isotope} package\thanks{This document
%   corresponds to \textsf{isotope}~\fileversion, dated \filedate.}}
% \author{Heiko Bauke\thanks{E-mail: \texttt{heiko.bauke@mpi-hd.mpg.de}}}
%
% \maketitle
%
% \section{Introduction}
%
% Despite its powerful typographic capabilities it is surprisingly
% difficult to typeset isotopes with \LaTeX. Ad hoc methods as for 
% example |$^{232}_{90}\mathrm{Th}$| give poor results as 
% $^{232}_{90}\mathrm{Th}$.
% This is not satisfactory because of the wrong alignment of atomic
% and nuclear numbers. The package \textsf{isotope} provides the |\isotope|
% macro for correct typesetting of isotopes.
%
% \section{Usage}
%
% The package \textsf{isotope} has to be included into the preamble of your 
% \LaTeX\ file by:
% \begin{quote}
% |\usepackage{isotope}|
% \end{quote}
% \DescribeMacro{\isotope}
% The usage of the |\isotope| macro is straight forward. Just provide the
% isotope's name and optionally its nucleon number and its atomic number.
% \begin{quote}
% |\isotope|\oarg{nucleon number}\oarg{atomic number}\marg{name}
% \end{quote}
% See \tablename~\ref{tab:example} for some examples. Note that the
% \verb#\alpha# has been enclosed by \verb#\mathnormal#.  Not doing so
% may give unexpected results for some math fonds.
%
% \begin{table}[t]
%   \centering
%   \caption{Examples for \texttt{\textbackslash isotope} macro usage.}
%   \label{tab:example}
%   \begin{tabular}{@{}ll@{}}
%   \hline
%   \hline
%   command & result \\
%   \hline
%   |\isotope{Ra}| & \isotope{Ra} \\
%   |\isotope[228]{Ra}| & \isotope[228]{Ra} \\
%   |\isotope[228][88]{Ra}| & \isotope[228][88]{Ra} \\
%   |$\isotope[A][Z]{X}\to\isotope[A-4][Z-2]{Y}+| & \\
%   |\isotope[4][2]{\mathnormal{\alpha}}$| & 
%   \raisebox{1.5ex}[-1.5ex]{$\isotope[A][Z]{X}\to\isotope[A-4][Z-2]{Y}+\isotope[4][2]{\mathnormal{\alpha}}$}\\
%   \hline
%   \hline
%   \end{tabular}
% \end{table}
% \DescribeMacro{\isotopestyle}
% The macro |\isotopestyle| determines the style which is used to typeset the 
% name of the iostope. It may be redefined. For example, the redefinition
% \begin{quote}
% |\renewcommand{\isotopestyle}{\mathsf}|\\
% |\isotope[228]{Ra}|
% \end{quote}
% gives {\renewcommand{\isotopestyle}{\mathsf}\isotope[228]{Ra}}.
%
% \StopEventually{\PrintChanges\PrintIndex}
%
% \section{Implementation}
%
% \begin{macro}{\isotopestyle}
% \changes{v0.2}{2004/01/04}{\texttt{\textbackslash isotopestyle} determines
%   also the style of nuclear and atomic number.}
% |\isotopestyle| determines the style which is used to typeset the 
% name of an iostope and its nucleon and atomic numbers. 
%    \begin{macrocode}
\newcommand{\isotopestyle}{\mathrm}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\isotope}
% \changes{v0.2}{2004/01/04}{Vertical spacing between nuclear and atomic 
%   number has been improved. The implementation is based no a suggestion
%   of Walter Schmidt in \texttt{de.comp.text.tex}.}
% Now it follows the implementation of the \verb#\isotope# macro.
%    \begin{macrocode}
\newcommand{\isotope@atomicnumber}{}
\newcommand{\isotope@nucleonnumber}{}
\newcommand{\isotope}[1][]{%
  \begingroup%
  \renewcommand{\isotope@nucleonnumber}{#1}%
  \isotope@two}%
  \newcommand{\isotope@two}[2][]{%
  \renewcommand{\isotope@atomicnumber}{#1}%
  {\m@th%
%    \end{macrocode}
%  Determine which has a larger width nucleon number or atomic number.
%    \begin{macrocode}
  \settowidth\@tempdimb{\ensuremath{%
    \scriptstyle\isotope@nucleonnumber}}%
  \settowidth\@tempdimc{\ensuremath{%
    \scriptstyle\isotope@atomicnumber}}%
  \ifdim\@tempdimb<\@tempdimc\@tempdimb=\@tempdimc\fi%
  \ensuremath{{}%
    ^{\makebox[\@tempdimb][r]{\ensuremath{%
       \scriptstyle\isotope@nucleonnumber}}}%
    _{\makebox[\@tempdimb][r]{\ensuremath{%
       \scriptstyle\isotope@atomicnumber}}}%
    \isotopestyle{#2}}%
  }%
  \endgroup%
}%	
%    \end{macrocode}
% \end{macro}
% \changes{v0.3}{2011/08/26}{Changed \texttt{\textbackslash
% isotopestyle} from \texttt{\textbackslash rm} to
% \texttt{\textbackslash mathrm} to improve typographic quality when
% sans serif math fonts are used.} 
% \PrintChanges
% \Finale
\endinput