| 1 |
% \iffalse |
| 2 |
%<*internal> |
| 3 |
\iffalse |
| 4 |
%</internal> |
| 5 |
%<*readme> |
| 6 |
____________________ |
| 7 |
The SUBDEPTH package |
| 8 |
v0.1 |
| 9 |
|
| 10 |
This package uses some Donald Arseneau code to unify the heights |
| 11 |
of math subscripts regardless of the presence of a superscript above. |
| 12 |
Compare $M_n$ to $M_n'$ in regular LaTeX for why this can be desirable. |
| 13 |
|
| 14 |
__________________________ |
| 15 |
Packaged by Will Robertson |
| 16 |
wspr 81 [at] gmail [dot] com |
| 17 |
|
| 18 |
Copyright 2007 |
| 19 |
Distributed under the LaTeX Project Public License |
| 20 |
%</readme> |
| 21 |
%<*internal> |
| 22 |
\fi |
| 23 |
\begingroup |
| 24 |
%</internal> |
| 25 |
%<*batchfile> |
| 26 |
\input docstrip.tex |
| 27 |
\keepsilent |
| 28 |
\preamble |
| 29 |
|
| 30 |
__________________________________ |
| 31 |
Copyright (C) 2007 Will Robertson |
| 32 |
|
| 33 |
License information appended. |
| 34 |
|
| 35 |
|
| 36 |
\endpreamble |
| 37 |
\postamble |
| 38 |
|
| 39 |
Copyright (C) 2007 by Will Robertson <[email protected]> |
| 40 |
|
| 41 |
Distributable under the LaTeX Project Public License, |
| 42 |
version 1.3c or higher (your choice). The latest version of |
| 43 |
this license is at: http://www.latex-project.org/lppl.txt |
| 44 |
|
| 45 |
This work is "maintained" (as per LPPL maintenance status) |
| 46 |
by Will Robertson. |
| 47 |
|
| 48 |
This work consists of the file subdepth.dtx |
| 49 |
and the derived files subdepth.pdf, |
| 50 |
subdepth.sty, and |
| 51 |
subdepth.ins. |
| 52 |
|
| 53 |
\endpostamble |
| 54 |
\askforoverwritefalse |
| 55 |
\generate{\file{subdepth.sty}{\from{subdepth.dtx}{package}}} |
| 56 |
%</batchfile> |
| 57 |
%<batchfile>\endbatchfile |
| 58 |
%<*internal> |
| 59 |
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}} |
| 60 |
\nopreamble\nopostamble |
| 61 |
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}} |
| 62 |
\generate{\file{prepare.sh}{\from{\jobname.dtx}{prepare}}} |
| 63 |
\endgroup |
| 64 |
\immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx} |
| 65 |
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo} |
| 66 |
%</internal> |
| 67 |
% |
| 68 |
%<*driver> |
| 69 |
\documentclass{ltxdoc} |
| 70 |
\EnableCrossrefs |
| 71 |
\CodelineIndex |
| 72 |
\RecordChanges |
| 73 |
%\OnlyDescription |
| 74 |
\newsavebox\wspr |
| 75 |
\savebox\wspr{\Huge $M_n$ $M_n'$} |
| 76 |
\usepackage{subdepth} |
| 77 |
\usepackage{url} |
| 78 |
\begin{document} |
| 79 |
\DocInput{\jobname.dtx} |
| 80 |
\end{document} |
| 81 |
%</driver> |
| 82 |
% |
| 83 |
% |
| 84 |
% \fi |
| 85 |
% |
| 86 |
% \CheckSum{0} |
| 87 |
% \makeatletter |
| 88 |
% |
| 89 |
% \title{Unify subscript depths} |
| 90 |
% \author{Code by Donald Arseneau\\ Packaged by Will Robertson} |
| 91 |
% \GetFileInfo{subdepth.sty} |
| 92 |
% \date{\filedate \qquad \fileversion} |
| 93 |
% |
| 94 |
% \maketitle |
| 95 |
% |
| 96 |
% \begin{quote}\small |
| 97 |
% This small package comes essentially verbatim from the following |c.t.t.| post by Donald Arseneau: \url{http://groups.google.com/group/comp.text.tex/msg/f207c7535810d2c1}.\footnote{I am distributing this package with the LPPL license, while I assume that Donald's original code to be in the public domain. This license stuff can be a bit messy sometimes.} |
| 98 |
% \end{quote} |
| 99 |
% |
| 100 |
% Consider the standard output of a subscript with and without a superscript above: |
| 101 |
% \begin{center} |
| 102 |
% \usebox\wspr |
| 103 |
% \end{center} |
| 104 |
% The second $n$ is lower due to \TeX's default of jiggling the space when there are both superscripts and subscripts attached to a math symbol. |
| 105 |
% |
| 106 |
% In some circumstances, this isn't particularly desirable; this package adjusts \LaTeX's behaviour to unify the position of the subscript in both cases: |
| 107 |
% \begin{center} |
| 108 |
% \Huge $M_n$ $M_n'$ |
| 109 |
% \end{center} |
| 110 |
% |
| 111 |
% Notice that to compensate for the higher subscript, the superscript position is slightly raised. The |[low-sup]| package option will suppress this change to the height of the superscripts. |
| 112 |
% |
| 113 |
% |
| 114 |
% \StopEventually{} |
| 115 |
% |
| 116 |
% \clearpage |
| 117 |
% \part{\textsf{\jobname} implementation} |
| 118 |
%\iffalse |
| 119 |
%<*package> |
| 120 |
%\fi |
| 121 |
% |
| 122 |
% This is the package. |
| 123 |
% |
| 124 |
% \begin{macrocode} |
| 125 |
\ProvidesPackage{subdepth} |
| 126 |
[2007/09/02 v0.1 Unify subscript depths] |
| 127 |
% \end{macrocode} |
| 128 |
% |
| 129 |
% \changes{v0.1}{2007/08/30}{Initial version.} |
| 130 |
% \PrintChanges |
| 131 |
% |
| 132 |
% \section{Loading and package options} |
| 133 |
% |
| 134 |
% Since this package is extracted from \textsf{dchem}, don't bother if that package is already loaded: |
| 135 |
% \begin{macrocode} |
| 136 |
\@ifpackageloaded{dchem}{\PackageWarning{subdepth incorporated within dchem; aborting loading}\endinput}{} |
| 137 |
% \end{macrocode} |
| 138 |
% |
| 139 |
% Package option to lower the superscript height. |
| 140 |
% \begin{macrocode} |
| 141 |
\newif\if@wspr@sup@low@ |
| 142 |
\DeclareOption{low-sup}{\@wspr@sup@low@true} |
| 143 |
\ProcessOptions |
| 144 |
% \end{macrocode} |
| 145 |
% |
| 146 |
% \section{Don's code} |
| 147 |
% |
| 148 |
% \textit{The comments that follow are Donald's. His out-commented diagnostic messages have been removed for clarity.} |
| 149 |
% |
| 150 |
% Set the fontdimen parameters for subscript and superscript position |
| 151 |
% so that |C_2H_5^+| has both subscripts at the same vertical position. |
| 152 |
% Do this by actually comparing |H_2| with |H_2^+| and adjusting the font's |
| 153 |
% sub-lowering (16, 17) by half the difference and setting the super- |
| 154 |
% raising (13, 14, 15) to the matching position. The settings (for |
| 155 |
% all three fonts t,s,ss) are determined once per text-font-size and |
| 156 |
% stored in the macro |\dch@sizet<size>| (e.g.\ |\csname dch@sizet12\endcsname|). |
| 157 |
% Since some specific fonts are used in different roles at different |
| 158 |
% text-font-sizes, the original (tfm) settings for each particular font |
| 159 |
% are saved in a macro |\dch@size<size>| (no "t") before they are changed |
| 160 |
% for the first time. When that font appears in a different role for |
| 161 |
% another text-font size, those original settings are restored first |
| 162 |
% before making changes. |
| 163 |
% |
| 164 |
% \begin{macrocode} |
| 165 |
\addto@hook\every@math@size{\dch@scr@hook} |
| 166 |
% \end{macrocode} |
| 167 |
% |
| 168 |
% \begin{macrocode} |
| 169 |
\def\dch@scr@adjust{\@ifundefined{dch@sizet\f@size}% |
| 170 |
{\expandafter\dch@set@script\csname dch@sizet\f@size\endcsname}% |
| 171 |
{\csname dch@sizet\f@size\endcsname}} |
| 172 |
% \end{macrocode} |
| 173 |
% textfont done last so it takes precedence in case it is the same as |
| 174 |
% another style (like at \cmd\tiny) |
| 175 |
% |
| 176 |
% |#1| = single-token command name for executing settings |
| 177 |
% \begin{macrocode} |
| 178 |
\def\dch@set@script#1{% |
| 179 |
\begingroup % fontdimen settings are global anyway |
| 180 |
\frozen@everymath{}% Prevent recursion! |
| 181 |
\let#1\@empty |
| 182 |
\let\dch@do@one\relax |
| 183 |
\dch@set@one\scriptscriptstyle\scriptscriptfont#1\ssf@size |
| 184 |
\dch@set@one\scriptstyle\scriptfont#1\sf@size |
| 185 |
\dch@set@one\textstyle\textfont#1\f@size |
| 186 |
\endgroup |
| 187 |
#1} |
| 188 |
% \end{macrocode} |
| 189 |
% ({\itshape Added conditional for the |[low-sup]| package option}): |
| 190 |
% \begin{macrocode} |
| 191 |
\def\dch@set@one#1#2#3#4{% |
| 192 |
\@ifundefined{dch@size#4}% |
| 193 |
{\expandafter\xdef\csname dch@size#4\endcsname{% |
| 194 |
\unless\if@wspr@sup@low@ |
| 195 |
\fontdimen13\the#2\tw@=\the\fontdimen13#2\tw@ |
| 196 |
\fontdimen14\the#2\tw@=\the\fontdimen14#2\tw@ |
| 197 |
\fontdimen15\the#2\tw@=\the\fontdimen15#2\tw@ |
| 198 |
\fi |
| 199 |
\fontdimen16\the#2\tw@=\the\fontdimen16#2\tw@ |
| 200 |
\fontdimen17\the#2\tw@=\the\fontdimen17#2\tw@}% |
| 201 |
}{\csname dch@size#4\endcsname}% |
| 202 |
\setbox\z@\hbox{$#1H_2$}\@tempdima\dp\z@ |
| 203 |
\setbox\z@\hbox{$#1H_2^{+\vrule \@height 1em}$}% |
| 204 |
% \end{macrocode} |
| 205 |
% {\itshape I've adapted Donald's code to use e\TeX\ methods for dimension calculating. \cmd\@tempdima\ is the `new sub lowering'. In \cmd\@tempdimb, the first two terms are the `adjustment', the second two the `new super raising'.} |
| 206 |
% \begin{macrocode} |
| 207 |
\ifdim\@tempdima<\dp\z@ |
| 208 |
\@tempdima\dimexpr (\@tempdima+\dp\z@)/2 \relax |
| 209 |
\@tempdimb\dimexpr (\dp\z@-\@tempdima+\ht\z@-1em) \relax |
| 210 |
\xdef#3{#3\dch@do@one#2{\the\@tempdimb}{\the\@tempdima}}% |
| 211 |
\fi} |
| 212 |
% \end{macrocode} |
| 213 |
% ({\itshape Added conditional for the |[low-sup]| package option}): |
| 214 |
% \begin{macrocode} |
| 215 |
\def\dch@do@one#1#2#3{% |
| 216 |
\unless\if@wspr@sup@low@ |
| 217 |
\fontdimen13#1\tw@#2\relax |
| 218 |
\fontdimen14#1\tw@\fontdimen13#1\tw@ |
| 219 |
\fontdimen15#1\tw@\fontdimen13#1\tw@ |
| 220 |
\fi |
| 221 |
\fontdimen\sixt@@n#1\tw@#3 |
| 222 |
\fontdimen17#1\tw@ |
| 223 |
\fontdimen\sixt@@n#1\tw@}% |
| 224 |
% \end{macrocode} |
| 225 |
% |
| 226 |
% \begin{macrocode} |
| 227 |
\let\dch@scr@hook\dch@scr@adjust |
| 228 |
\ifx\glb@currsize\f@size |
| 229 |
\dch@scr@adjust |
| 230 |
\fi |
| 231 |
% \end{macrocode} |
| 232 |
% |
| 233 |
%\iffalse |
| 234 |
%</package> |
| 235 |
%<*prepare> |
| 236 |
rm subdepth.zip |
| 237 |
latex subdepth.dtx |
| 238 |
mv README.txt README |
| 239 |
zip subdepth.zip subdepth.dtx subdepth.ins subdepth.pdf README |
| 240 |
%</prepare> |
| 241 |
%\fi |
| 242 |
% |
| 243 |
% \typeout{*************************************************************} |
| 244 |
% \typeout{*} |
| 245 |
% \typeout{* To finish the installation you have to move the following} |
| 246 |
% \typeout{* file into a directory searched by XeTeX:} |
| 247 |
% \typeout{*} |
| 248 |
% \typeout{* \space\space\space subdepth.sty} |
| 249 |
% \typeout{*} |
| 250 |
% \typeout{*************************************************************} |
| 251 |
% |
| 252 |
\endinput |