summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/subdepth/subdepth.dtx
blob: 2edf4c133f0dc52e466430b8b7b126dc8afec27b (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
% \iffalse 
%<*internal>
\iffalse
%</internal>
%<*readme>
____________________
The SUBDEPTH package
v0.1

This package uses some Donald Arseneau code to unify the heights
of math subscripts regardless of the presence of a superscript above.
Compare $M_n$ to $M_n'$ in regular LaTeX for why this can be desirable.

__________________________
Packaged by Will Robertson
wspr 81 [at] gmail [dot] com

Copyright 2007
Distributed under the LaTeX Project Public License
%</readme>
%<*internal>
\fi
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble

  __________________________________
  Copyright (C) 2007  Will Robertson

  License information appended.


\endpreamble
\postamble

Copyright (C) 2007 by Will Robertson <wspr81@gmail.com>

Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
this license is at: http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) 
by Will Robertson.

This work consists of the file  subdepth.dtx
          and the derived files subdepth.pdf,
                                subdepth.sty, and
                                subdepth.ins.

\endpostamble
\askforoverwritefalse
\generate{\file{subdepth.sty}{\from{subdepth.dtx}{package}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\generate{\file{prepare.sh}{\from{\jobname.dtx}{prepare}}}
\endgroup
\immediate\write18{makeindex -s gind.ist -o \jobname.ind  \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls  \jobname.glo}
%</internal>
%
%<*driver>
\documentclass{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
\newsavebox\wspr
\savebox\wspr{\Huge $M_n$ $M_n'$}
\usepackage{subdepth}
\usepackage{url}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
%
%
% \fi
%
% \CheckSum{0}
% \makeatletter
%
% \title{Unify subscript depths}
% \author{Code by Donald Arseneau\\ Packaged by Will Robertson}
% \GetFileInfo{subdepth.sty}
% \date{\filedate \qquad \fileversion}
%
% \maketitle
%
% \begin{quote}\small
% 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.}
% \end{quote}
%
% Consider the standard output of a subscript with and without a superscript above:
% \begin{center}
% \usebox\wspr
% \end{center}
% 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.
%
% In some circumstances, this isn't particularly desirable; this package adjusts \LaTeX's behaviour to unify the position of the subscript in both cases:
% \begin{center}
% \Huge $M_n$ $M_n'$
% \end{center}
%
% 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.
%
% 
% \StopEventually{}
%
% \clearpage
% \part{\textsf{\jobname} implementation}
%\iffalse
%<*package>
%\fi
%
% This is the package.
%
%    \begin{macrocode}
\ProvidesPackage{subdepth}
  [2007/09/02 v0.1 Unify subscript depths]
%    \end{macrocode}
%
% \changes{v0.1}{2007/08/30}{Initial version.}
% \PrintChanges
%
% \section{Loading and package options}
%
% Since this package is extracted from \textsf{dchem}, don't bother if that package is already loaded:
%    \begin{macrocode}
\@ifpackageloaded{dchem}{\PackageWarning{subdepth incorporated within dchem; aborting loading}\endinput}{}
%    \end{macrocode}
%
% Package option to lower the superscript height.
%    \begin{macrocode}
\newif\if@wspr@sup@low@
\DeclareOption{low-sup}{\@wspr@sup@low@true}
\ProcessOptions
%    \end{macrocode}
%
% \section{Don's code}
%
% \textit{The comments that follow are Donald's. His out-commented diagnostic messages have been removed for clarity.}
% 
% Set the fontdimen parameters for subscript and superscript position 
% so that |C_2H_5^+| has both subscripts at the same vertical position. 
% Do this by actually comparing |H_2| with |H_2^+| and adjusting the font's 
% sub-lowering (16, 17) by half the difference and setting the super- 
% raising (13, 14, 15) to the matching position.  The settings (for 
% all three fonts t,s,ss) are determined once per text-font-size and 
% stored in the macro |\dch@sizet<size>| (e.g.\ |\csname dch@sizet12\endcsname|). 
% Since some specific fonts are used in different roles at different 
% text-font-sizes, the original (tfm) settings for each particular font 
% are saved in a macro |\dch@size<size>| (no "t") before they are changed 
% for the first time.  When that font appears in a different role for 
% another text-font size, those original settings are restored first 
% before making changes. 
%
%    \begin{macrocode}
\addto@hook\every@math@size{\dch@scr@hook} 
%    \end{macrocode}
% 
%    \begin{macrocode}
\def\dch@scr@adjust{\@ifundefined{dch@sizet\f@size}% 
  {\expandafter\dch@set@script\csname dch@sizet\f@size\endcsname}% 
  {\csname dch@sizet\f@size\endcsname}} 
%    \end{macrocode}
% textfont done last so it takes precedence in case it is the same as 
% another style (like at \cmd\tiny)
%
% |#1| = single-token command name for executing settings 
%    \begin{macrocode}
\def\dch@set@script#1{%
  \begingroup % fontdimen settings are global anyway 
    \frozen@everymath{}% Prevent recursion! 
    \let#1\@empty 
    \let\dch@do@one\relax 
    \dch@set@one\scriptscriptstyle\scriptscriptfont#1\ssf@size 
    \dch@set@one\scriptstyle\scriptfont#1\sf@size 
    \dch@set@one\textstyle\textfont#1\f@size 
  \endgroup 
  #1} 
%    \end{macrocode}
% ({\itshape Added conditional for the |[low-sup]| package option}):
%    \begin{macrocode}
\def\dch@set@one#1#2#3#4{% 
  \@ifundefined{dch@size#4}% 
   {\expandafter\xdef\csname dch@size#4\endcsname{% 
      \unless\if@wspr@sup@low@
        \fontdimen13\the#2\tw@=\the\fontdimen13#2\tw@ 
        \fontdimen14\the#2\tw@=\the\fontdimen14#2\tw@ 
        \fontdimen15\the#2\tw@=\the\fontdimen15#2\tw@ 
      \fi
      \fontdimen16\the#2\tw@=\the\fontdimen16#2\tw@ 
      \fontdimen17\the#2\tw@=\the\fontdimen17#2\tw@}% 
  }{\csname dch@size#4\endcsname}% 
  \setbox\z@\hbox{$#1H_2$}\@tempdima\dp\z@ 
  \setbox\z@\hbox{$#1H_2^{+\vrule \@height 1em}$}% 
%    \end{macrocode}
% {\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'.}
%    \begin{macrocode}
  \ifdim\@tempdima<\dp\z@ 
    \@tempdima\dimexpr (\@tempdima+\dp\z@)/2 \relax 
    \@tempdimb\dimexpr (\dp\z@-\@tempdima+\ht\z@-1em) \relax
    \xdef#3{#3\dch@do@one#2{\the\@tempdimb}{\the\@tempdima}}% 
  \fi} 
%    \end{macrocode} 
% ({\itshape Added conditional for the |[low-sup]| package option}):
%    \begin{macrocode}
\def\dch@do@one#1#2#3{% 
  \unless\if@wspr@sup@low@
    \fontdimen13#1\tw@#2\relax 
    \fontdimen14#1\tw@\fontdimen13#1\tw@ 
    \fontdimen15#1\tw@\fontdimen13#1\tw@ 
  \fi
  \fontdimen\sixt@@n#1\tw@#3
  \fontdimen17#1\tw@
  \fontdimen\sixt@@n#1\tw@}% 
%    \end{macrocode}
% 
%    \begin{macrocode}
\let\dch@scr@hook\dch@scr@adjust 
\ifx\glb@currsize\f@size 
  \dch@scr@adjust 
\fi 
%    \end{macrocode}
%
%\iffalse
%</package>
%<*prepare>
rm subdepth.zip
latex subdepth.dtx
mv README.txt README
zip subdepth.zip subdepth.dtx subdepth.ins subdepth.pdf README
%</prepare>
%\fi
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the following}
% \typeout{* file into a directory searched by XeTeX:}
% \typeout{*}
% \typeout{* \space\space\space subdepth.sty}
% \typeout{*}
% \typeout{*************************************************************}
%
\endinput