home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!darwin.sura.net!mips!pacbell.com!network.ucsd.edu!mvb.saic.com!info-tex
- From: herschor@math.mcgill.ca (Michael Herschorn)
- Newsgroups: comp.text.tex
- Subject: CRAMPED STYLES & solution to:fraction spacing default_rule_thickness.
- Message-ID: <9207211625.AA07444@Math.McGill.CA>
- Date: Tue, 21 Jul 92 12:25:00 EDT
- Organization: Info-Tex<==>Comp.Text.Tex Gateway
- X-Gateway-Source-Info: Mailing List
- Lines: 374
-
-
- At the end of this submission you will find a solution to the
- problem relating to the minimum separation between the numerator or
- denominator of a fraction and the fraction bar, a question raised and
- discussed in several postings last month. I would like
- to begin with a more general problem which provides the tool
- used for that solution.
-
- PART ONE:
-
- To measure typeset text from a math list in TeX, the material is
- placed in an \hbox. One must then specify the style of
- the text's "free state" inside the box. The horizontal dimension in
- the free state is affected by "actions at infinity" (glue) and is
- intrinsically uncertain; the height and depth are determined
- "quasi-locally", and are fixed once TeX decides on the current style.
- However, if an item is to be set in a cramped style, absent a TeX
- command \cramp{}, how does one measure its height and depth?
-
- I have also felt a need for \cramp for aesthetic reasons when there
- is a repetition of an expression close by the original in a line of
- text, once in an uncramped style, and once in the corresponding
- cramped style. As well, there is a not insignificant amount of space
- that can be saved in a document with multiple occurrences of, e.g.,
- ${\x}^{{\x}^{{\x}^{\cdot^{\cdot^{\cdot^{\x}}}}}}$, if this could
- be set in a cramped style.
-
- I have most of the standard TeX references, but I haven't come across
- any mention of the possibility of obtaining a cramped style "on
- demand". Thus there may be some general interest in the preliminary
- version of my <cramped.sty> macro, and I append it below.
-
- (I also haven't come across any discussion of a "feature" which turns
- cramping off, viz., prefix the material which TeX would normally
- cramp by an explicit style reminder. Compare, for example,
- $\sqrt{X^2+Y^2}$ with $\sqrt{\textstyle X^2+Y^2}$. However, I doubt
- that this is an intended feature since:
- i) TeX is normally insensitive to redundant style commands, and from
- the user's point of view, this is the way it should be; and,
- ii) cramping will be turned off in midstream by an explicit style
- command (e.g., $\sqrt{X^2+\textstyle Y^2} has X^2 in cramped style
- and Y^2 in uncramped style).
- I am completely out of my depth when it comes to understanding the
- details of The Program, and please, no flames (not even for the
- mixing of metaphors!), but it seems to me that this "feature"
- is a result of the cramped_style calculation in section 702 of The
- Program being ignored while section 703 updates only size-dependent
- quantities.
- Although I reserve my rights to priority for the "finder's fee"
- mentioned in the Preface to The Program, I would like to hear the
- opinions of gurus on the net.)
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % cramped.sty Preliminary version July 21,1992
- %
- % Enables the typesetting of material in the cramped styles
- % D', T', S' and SS'.
- %
- % \cramp{<foo.bar>} will set <foo.bar> in the cramped version C' of
- % the current style C.
- %
- % \Cramp{\...style}{<foo.bar>} (where you specify the current style)
- % has been left accessible.
- %
- %
- % Author: Michael Herschorn
- % Departmentof Mathematics and Statistics
- % McGill University
- % 805 Sherbrooke Street West Phone: 514-398-3825
- % Montreal QC CANADA H3A 2K6 FAX: 514-398-3899
- % email: herschor@gauss.math.mcgill.ca
- %
- % Please email me your comments and suggestions as well as informing
- % me directly of any bugs you may find.
- %
- %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \catcode`@=11
- \def\cramp{\mathpalette\Cramp}%
- \def\Cramp#1#2{\setbox0=\hbox{$\m@th#1\cr@mp{#2}$}
- \Ch@p#1 \dimen2=\the\ht0 \advance\dimen2 -\dimen0
- \ht0=\the\dimen2 \box0}
- \def\cr@mp{\kern-\the\nulldelimiterspace\radical"380380}%
- \def\Ch@p#1{\ifx#1\displaystyle
- \dimen0=\the\fontdimen5\textfont2
- \advance\dimen0 -.75\dimen0
- \advance\dimen0\the\fontdimen8\textfont3
- \else
- %% \ifx#1\textstyle
- \dimen0=\the\fontdimen8\textfont3
- \advance\dimen0 .25\dimen0
- \fi}%%%%%%%%% If you have "variations" in family 3,
- %%%%%% comment out the preceding line and "uncomment"
- %%%%%% the 7 lines beginning with "%%".
- %% \else
- %% \ifx#1\scriptstyle\dimen0=\the\fontdimen8\scriptfont3
- %% \advance\dimen0 .25\dimen0
- %% \else \dimen0=\the\fontdimen8\scriptscriptfont3
- %% \advance\dimen0 .25\dimen0
- %% \fi\fi\fi}
- \catcode`@=12
- \endinput
- %%
- % end of file cramped.sty
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
- PART TWO:
-
-
-
- Michael Downes <MJD@MATH.AMS.COM> (22 Jun 1992, Info-TeX@shsu.edu)
- wrote:
-
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- +Dan Luecking wrote (19 Jun 1992, Info-TeX@shsu.edu):
- +
- +> Michael Barr posted a query a while back about the separation
- +> between the numerator/denominator of a fraction and the fraction bar.
- +>
- +> I have not seen a response, so having tried to understand the
- +> TeXbook on this point and made some headway in doing so I thought
- +> I might discuss the problem.
- +
- +> ... I have run into it several times and would like to know if
- +> anyone has defined a fraction making command to deal with it. One
- +> way is to insert a 0 width rule extending below the numerator and
- +> above the denominator, but I do not see a good to make this
- +> automatic. A way I have considered, but rejected, is to increase the
- +> relevant parameter, (something like \fontdimen8\textfont3=1pt
- +> instead of 0.4pt) and then define all \frac's using \above (in which
- +> the thickness of the rule is explicitly given). The problem is that
- +> default_rule_thickness is used in several internal calculations
- +> including the positioning of sub/superscripts.
- +>
- +> Does anybody have anything to say about this?
- +
- + I have observed the same problem in Amer. Math. Soc. publications,
- + although the examples I've happened to notice involved letters with
- + descenders such as p and q, rather than vertical bars. Your analysis
- + of the problem corresponds closely to what I found in some cursory
- + investigations.
- +
- + The problem seems to be slightly worse than you suggest---or maybe you
- + just didn't bother to amplify on results of your experiments: The most
- + significant drawback of the rejected solution of setting \fontdimen 8
- + \textfont 3 to a larger value and using \above instead of \over is
- + not the internal calculations you mention but the fact that the fraction
- + bar thickness and the space around it are always dependent, even in
- + \above, so that if we say $1\above.4pt 2$ the space around the
- + fraction bar is calculated from the .4pt, not from \fontdimen 8 of
- + \textfont 3, and we're back where we started from.
- +
- +> ... Is it worthwhile suggesting
- +> that a major macro package try do something about it? Have any done
- +> anything?
- +
- + If my understanding of the problem is correct, it's impossible for a
- + macro package to provide any reasonable solution. The only reasonable
- + solution is to change TeX, the program. (And my definition of
- + `reasonable' is pretty extreme when it comes to macro writing; I have
- + done or contemplated doing things at the macro level that any
- + `reasonable' programmer would consider unreasonable.)
- +
- +> Is there any real problem at higher resolutions (i.e., does
- +> everything look OK printed at 1000dpi)?
- +
- + In my opinion, there is not enough space around the fraction bar in
- + the problematic combinations (textstyle fractions, vertical bars,
- + letters with descenders), even at high resolution. I'd rather have
- + some control to adjust the space slightly.
- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
-
- The Grand Wizard made his design choices a.e. optimally, and I would
- stick with his implementation of 15d in Appendix G of The TeXbook.
- Apparent differences between the letter-base levels in the numerators
- and in the denominators of fractions in the same line spoil the
- appearance of the line; shifting the numerator up or the denominator
- down in a fraction with adequate clearance so as to match the letter-
- base levels of another fraction in the line introduces ugly white
- space. The more I understand the problem, the better I like the GW's
- balancing act.
-
- Nevertheless, as pointed out by Dan Luecking, Berthold K.P. Horn and
- Michael Downes, it would have been nice to have a free parameter to
- adjust in special circumstances. ("Just so you shouldn't need to
- use it", as the Yiddish expression puts it.)
-
- Once we have <cramped.sty>, it becomes a simple hack to solve this
- problem (and other similar ones). I wrote (and attach a copy of)
- <spreadfraction.sty> as an illustration. (The coding is not elegant,
- but it works.) It should be used only when absolutely necessary,
- and even then, it should be used sparingly.
-
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % spreadfraction.sty Preliminary version July 21,1992
- %
- % If used in a non-cramped context, \xfrac{#1}{#2}{#3} produces
- % {#1\over #2} exactly as TeX would, except that the minimum clearance
- % that will be tolerated between the numerator or denominator of this
- % fraction and the bar line is #3 times the default rule thickness.
- % (See Rule 15d in Appendix G of The TeXbook. TeX hardwires in
- % #3=3 in \displaystyle and #3=1 in the other styles; spreadfraction.sty
- % allows the use of arbitrary values. In other words, .phi. is replaced
- % by #3 times the default rule thickness, everything else is kept
- % constant.)
- %
- % In a cramped context, i.e., if the entire fraction is a Rad atom
- % (under a root sign), an Over atom (from \overline), in the denominator
- % of another fraction, is a subscript, or is a superscript to an
- % entity in cramped style, \xfracc{#1}{#2}{#3} should be used instead
- % of \xfrac{#1}{#2}{#3}. (I may automate the selection of \xfracc in a
- % future version; since spreadfraction.sty is intended for touch-up use,
- % I don't consider automation a priority (and it may be like putting a
- % tiara on a baglady!)).
- %
- % \Xfrac{\...style}{}{}{} (identical to \xfrac{}{}{}, except
- % that you specify the style) and \Xfracc{\...style}{}{}{} (DITTO),
- % have been left accessible to the user.
- %
- % To obtain a version of spreadfraction in which the minimum clearances
- % are #3 times the hardwired ones, declare \DEKtrue after inputting
- % spreadfraction.sty
- %
- %
- % Author: Michael Herschorn
- % Departmentof Mathematics and Statistics
- % McGill University
- % 805 Sherbrooke Street West Phone: 514-398-3825
- % Montreal QC CANADA H3A 2K6 FAX: 514-398-3899
- % email: herschor@gauss.math.mcgill.ca
- %
- % Please email me your comments and suggestions as well as informing
- % me directly of any bugs you may find.
- %
- %
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \newif\ifDEK
- \input cramped.sty
- \catcode`@=11
- \def\xfrac#1#2#3{\M@thpalette\Xfrac{#1}{#2}{#3}}
- \def\M@thpalette#1#2#3#4{%
- \mathchoice{#1\displaystyle{#2}{#3}{#4}}%
- {#1\textstyle{#2}{#3}{#4}}%
- {#1\scriptstyle{#2}{#3}{#4}}%
- {#1\scriptscriptstyle{#2}{#3}{#4}}}
- \def\Xfrac#1#2#3#4{\ifx#1\displaystyle
- \def\C@rr@ntF@nt{\textfont}
- \let\@djSt@le=\textstyle
- \L@rgeS@ze#1{#2}{#3}{#4}
- \else
- \ifx#1\textstyle \def\C@rr@ntF@nt{\textfont}
- \let\@djSt@le=\scriptstyle
- \N@rmalS@ze#1{#2}{#3}{#4}
- \else
- \ifx#1\scriptstyle
- \def\C@rr@ntF@nt{\scriptfont}
- \let\@djSt@le=\scriptscriptstyle
- \N@rmalS@ze#1{#2}{#3}{#4}
- \else
- \def\C@rr@ntF@nt{\scriptscriptfont}
- \let\@djSt@le=\scriptscriptstyle
- \N@rmalS@ze#1{#2}{#3}{#4}
- \fi
- \fi
- \fi}
- \def\L@rgeS@ze#1#2#3#4{\dimen1=\the\fontdimen8\textfont2
- \dimen2=\the\fontdimen11\textfont2
- \N@mer@tor#1{#2}{#3}{#4}}
- \def\N@rmalS@ze#1#2#3#4{%
- \dimen1=\the\fontdimen9\C@rr@ntF@nt2
- \dimen2=\the\fontdimen12\C@rr@ntF@nt2
- \N@mer@tor#1{#2}{#3}{#4}}
- \def\N@mer@tor#1#2#3#4{%
- \dimen3=\the\fontdimen22\C@rr@ntF@nt2
- \dimen4=\the\fontdimen8\C@rr@ntF@nt3
- \dimen5=#4\dimen4
- \ifDEK\ifx#1\displaystyle\advance\dimen5 2\dimen5
- \else
- \fi
- \else
- \fi
- \advance\dimen4 -.5\dimen4
- \setbox1=\hbox{$\m@th\@djSt@le{#2}$}
- \dimen0=\dimen1 \advance\dimen0 -\the\dp1
- \advance\dimen0 -\dimen3
- \advance\dimen0 -\dimen4
- \ifdim\dimen5>\dimen0 \advance\dimen1 \dimen5
- \advance\dimen1 -\dimen0
- \D@nomin@tor#1{#3}
- \else
- \D@nomin@tor#1{#3}
- \fi}
- \def\D@nomin@tor#1#2{%
- \setbox2=\hbox{$\m@th
- \@djSt@le\Cramp\@djSt@le{#2}$}
- \dimen0=\dimen2 \advance\dimen0 \dimen3
- \advance\dimen0 -\the\ht2
- \advance\dimen0 -\dimen4
- \ifdim\dimen5>\dimen0 \advance\dimen2 \dimen5
- \advance\dimen2 -\dimen0 \Qu@ti@nt#1
- \else
- \Qu@ti@nt#1
- \fi}
- \def\Qu@ti@nt#1{%
- \ifdim\wd1<\wd2 \dimen9=\the\wd2
- \setbox3=\hbox to \the\dimen9{%
- $\m@th\hfil\box1\hfil$}
- \setbox1=\box3 \dimen8=\dimen9
- \else \dimen9=\the\wd1
- \setbox3=\hbox to \the\dimen9{%
- $\m@th\hfil\box2\hfil$}
- \setbox2=\box3
- \fi
- \advance\dimen1 -\the\dp1
- \advance\dimen1 -\dimen3
- \advance\dimen1 -\dimen4
- \dimen6=\dimen2 \advance\dimen6 -\the\ht2
- \advance\dimen6 \dimen3
- \advance\dimen6 -\dimen4
- \kern\the\nulldelimiterspace
- \raise-\the\dimen2 \hbox to\the\dimen9{%
- \vbox{\box1\kern\the\dimen1\hrule
- \kern\the\dimen6\box2}}
- \kern\the\nulldelimiterspace}
- \def\Xfracc#1#2#3#4{\ifx#1\displaystyle
- \let\@djSt@l@=\textstyle
- \G@toResult{#1}{#2}{#3}{#4}
- \else
- \ifx#1\textstyle \let\@djSt@l@=\scriptstyle
- \G@toResult{#1}{#2}{#3}{#4}
- \else
- \let\@djSt@l@=\scriptscriptstyle
- \G@toResult{#1}{#2}{#3}{#4}
- \fi
- \fi}
- \def\G@toResult#1#2#3#4{%
- \Xfrac#1{\Cramp\@djSt@l@{#2}}{#3}{#4}}
- \def\xfracc#1#2#3{\mathchoice
- {\Xfrac\displaystyle{\Cramp\textstyle{#1}}{#2}{#3}}%
- {\Xfrac\textstyle{\Cramp\scriptstyle{#1}}{#2}{#3}}%
- {\Xfrac\scriptstyle{\Cramp%
- \scriptscriptstyle{#1}}{#2}{#3}}%
- {\Xfrac\scriptscriptstyle{\Cramp%
- \scriptscriptstyle{#1}}{#2}{#3}}}
- \catcode`@=12
- \endinput
- %%
- %% end spreadfraction.sty
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
- I would appreciate comments and feedback by email and shall
- summarize and post.
-
-
- Michael Herschorn
-
- ***********************************************************************
-
- Michael Herschorn email:herschor@gauss.math.mcgill.ca
- Department of Mathematics and Statistics fax: 514-398-3899
- McGill University phone: 514-398-3825
- 805 Sherbrooke Street West
- Montreal QC CANADA H3A 2K6
-
- ***********************************************************************
-
-