diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/mh')
-rw-r--r-- | Master/texmf-dist/source/latex/mh/breqn.dtx | 8 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/mh/flexisym.dtx | 13 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/mh/mathtools.dtx | 207 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/mh/xfrac.dtx | 882 |
4 files changed, 722 insertions, 388 deletions
diff --git a/Master/texmf-dist/source/latex/mh/breqn.dtx b/Master/texmf-dist/source/latex/mh/breqn.dtx index 1ab39409a40..524cc0c40d7 100644 --- a/Master/texmf-dist/source/latex/mh/breqn.dtx +++ b/Master/texmf-dist/source/latex/mh/breqn.dtx @@ -644,13 +644,14 @@ and the derived files % \env{darray}, and \env{dseries} environments; some of the options do not % make sense for all of the environments, but if an option is used where % not applicable it is silently ignored rather than treated as an error. +% \changes{v0.98b}{2010/08/27}{replaced relindent with indentstep} % % \begin{verbatim} % \begin{dmath}[style={\small}] % \begin{dmath}[number={BV}] % \begin{dmath}[labelprefix={eq:}] % \begin{dmath}[label={xyz}] -% \begin{dmath}[relindent={1em}] +% \begin{dmath}[indentstep={2em}] % \begin{dmath}[compact] % \begin{dmath}[spread={1pt}] % \begin{dmath}[frame] @@ -679,9 +680,10 @@ and the derived files % its argument to the label (only useful as a global option, really), % and must be called before \opt{label}. % -% Use the \opt{relindent} option to specify something other than the +% \changes{v0.98b}{2010/08/27}{replaced relindent with indentstep} +% Use the \opt{indentstep} option to specify something other than the % default amount for the indention of relation symbols. The default is -% 2em. +% 8pt. % % Use the \opt{compact} option in compound equations to inhibit line % breaks at relation symbols. By default a line break will be taken before diff --git a/Master/texmf-dist/source/latex/mh/flexisym.dtx b/Master/texmf-dist/source/latex/mh/flexisym.dtx index d25bcc0a82a..447e6c4a862 100644 --- a/Master/texmf-dist/source/latex/mh/flexisym.dtx +++ b/Master/texmf-dist/source/latex/mh/flexisym.dtx @@ -72,7 +72,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: flexisym 2010/07/11 v0.97b Flexisym (MH)} +\Msg{* Package: flexisym 2010/09/17 v0.97b Flexisym (MH)} \Msg{************************************************************************} \keepsilent @@ -83,7 +83,7 @@ This is a generated file. Copyright (C) 1997-2003 by Michael J. Downes -Copyright (C) 2007-2008 by Morten Hoegholm <mh.ctan@gmail.com> +Copyright (C) 2007-2010 by Morten Hoegholm <mh.ctan@gmail.com> This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either @@ -138,7 +138,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{flexisym.drv}% - [2010/07/11 v0.97b flexisym (MH)] + [2010/09/17 v0.97b flexisym (MH)] \documentclass{ltxdoc} \CodelineIndex \EnableCrossrefs @@ -180,7 +180,7 @@ and the derived files % \begin{macrocode} %<*package> \RequirePackage{expl3}[2009/08/05] -\ProvidesExplPackage{flexisym}{2009/08/07}{0.97a}{Make math characters macros} +\ProvidesExplPackage{flexisym}{2010/09/17}{0.97b}{Make math characters macros} \edef\do{% \noexpand\AtEndOfPackage{% @@ -524,7 +524,10 @@ and the derived files \catcode\z@=\active \def\DeclareFlexSymbol#1#2#3#4{% \begingroup - \cs_set:Npx\@tempb{\exp_not:N\@sym\exp_not:N#1\exp_not:c{math_sym_#2:Nn}\exp_not:c{mg@#3}{#4}}% + \cs_set_protected:Npx\@tempb{ + \exp_not:N\@sym\exp_not:N#1\exp_not:c{math_sym_#2:Nn} + \exp_not:c{mg@#3}{#4} + } \ifcat\exp_not:N#1\relax \sym@global\let#1\@tempb \else diff --git a/Master/texmf-dist/source/latex/mh/mathtools.dtx b/Master/texmf-dist/source/latex/mh/mathtools.dtx index 5af5ac8c1a0..01e50e611b1 100644 --- a/Master/texmf-dist/source/latex/mh/mathtools.dtx +++ b/Master/texmf-dist/source/latex/mh/mathtools.dtx @@ -259,7 +259,7 @@ and the derived files % % \GetFileInfo{mathtools.drv} % -% \CheckSum{2311} +% \CheckSum{2348} % % \title{The \pkg{mathtools} package\thanks{This file has version number % \fileversion, last revised \filedate.}} @@ -446,7 +446,7 @@ and the derived files % these macros I find it better to read the article; an online % version can be found at % \begin{quote} -% \url{http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf} +% \url{http://www.tug.org/TUboat/Articles/tb22-4/tb72perlS.pdf} % \end{quote} % Note that the definitions shown in the article do not exactly % match the definitions in \pkg{mathtools}. Besides providing an @@ -834,7 +834,28 @@ and the derived files % \FeatureRequest{Rasmus Villemoes}{2008/03/26} % The syntax is somewhat similar to \cs{nocite}. % -% \medskip\noindent\textbf{BUG:} Currently there is a bug between +% \medskip\noindent\textbf{BUG 1:} Unfortunately the use of the +% \key{showonlyref} introduce a bug within amsmath's typesetting +% of formula versus equation number. This bug manifest itself by +% allowing formulas to be typeset close to or over the equation +% number. Currently no general fix is known, other than making sure +% that ones formulas are not long enough to touch the equation +% number. +% +% To make a long story stort, amsmath typesets its math environments +% twice, one time for measuring and one time for the actual +% typesetting. In the measuring part, the width of the equation +% number is recorded such that the formula or the equation number can +% be moved (if necessary) in the typesetting part. When +% \key{showonlyref} is enabled, the width of the equation number +% depend on whether or not this number is refered~to. To determine +% this, we need to know the current label. But the current label is +% \emph{not} known in the measuring phase. Thus the measured width is +% always zero (because no label equals not refered to) and therefore +% the typesetting phase does not take the equation number into +% account. +% +% \medskip\noindent\textbf{BUG 2:} Currently there is a bug between % \key{showonlyrefs} and the \pkg{ntheorem} package, then the % \pkg{ntheorem} option \key{thmmarks} is active. The shown equation % numbers may come out wrong (seems to be multiplied by 2). The @@ -1437,41 +1458,78 @@ and the derived files % % \begin{codesyntax} % \SpecialUsageIndex{\DeclarePairedDelimiterX} -% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\texttt{\%}\\ -% \marg{normal replacement code}\marg{starred replacement code} +% \cs{DeclarePairedDelimiterX}\marg{cmd}\oarg{num args}\marg{left_delim}\marg{right_delim}\marg{code}\\ +% \cs{delimsize} % \end{codesyntax} -% \ProvidedBy{Lars Madsen}{2010/06/15} -% Sometimes \cs{DeclarePairedDelimiter} just is not enough, -% especially if one wants to hide syntax inside the macro. For -% example one might want to implement an inner product taking two -% arguments such that the separator symbol can be hidden inside the -% macro itself (e.g.\ if a journal style require a semi-colon instead -% of a comma). Therefore we have the generalized -% \cs{DeclarePairedDelimiterX}. -% In this setting \verb|\DeclarePairedDelimiter\abs\lvert\rvert| is -% the same as +% \ProvidedBy{Lars Madsen}{2010/06/15} +% Sometimes \cs{DeclarePairedDelimiter} just is not enough. One +% might want to have the capabilities of \cs{DeclarePairedDelimiter}, +% but also want a macro the takes more than one argument. +% +% \cs{DeclarePairedDelimiterX} extends the features of +% \cs{DeclarePairedDelimiter} such that the user will get a macro +% which is fenced off at either end, plus the capability to provide +% the code for what ever the macro should do within these fences. +% +% Inside the \meta{code} part, the macro \cs{delimsize} refer to the +% size of the outer fences. It can then be used inside \meta{code} to +% scale any inner fences. +% +% In this setting +% \cs{DeclarePairedDelimiter}\marg{cmd}\marg{left_delim}\marg{right_delim} is the same thing as +% \begin{center} +% \cs{DeclarePairedDelimiterX}\marg{cmd}\verb|[1]|\marg{left_delim}\marg{right_delim}\verb|{#1}| +% \end{center} +% % +% Let us do some examples. First we want to prepare a macro for inner +% products, with two arguments such that we can hide the character +% separating the arguments (a journal style might require a +% semi-colon, so we will save a lot of hand editing). This can be +% done via % \begin{verbatim} -% \DeclarePairedDelimiterX\abs[1]\lvert\rvert{#2}{#1} +% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2} % \end{verbatim} -% OK, this need some explanation: \oarg{num args} is required, and -% should be 1--8 arguments. The starred and non-starred replacement -% code is a bit special. The starred macro takes \meta{num args}, -% mandatory arguments, so \texttt{\#1}\dots refers to these -% arguments. But the non-starred version also have the optional -% argument which corresponds to \texttt{\#1}, so the mandatory -% arguments start at \texttt{\#2} and stops at \meta{num args} plus one. +% More interestingly we can refer to the size inside the +% \meta{code}. Here we do a weird three argument `braket' % \begin{verbatim} -% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#2,#3}{#1,#2} +% \DeclarePairedDelimiterX\brakket[3]{\langle}{\rangle}% +% {#1\,\delimsize\vert\,#2\,\delimsize\vert\,#3} % \end{verbatim} -% Inside the starred replacement one can use \cs{middle} to scale and -% inner delimiter to the same height as the outer. In the non-starred, -% we get the optional argument in \texttt{\#1} so we can use that if -% needed. As an example let us define a bra-ket: +% Then we can get +% \DeclarePairedDelimiterX\innerp[2]{\langle}{\rangle}{#1,#2} +% \DeclarePairedDelimiterX\brakket[3]{\langle}{\rangle}% +% {#1\,\delimsize\vert\,#2\,\delimsize\vert\,#3} % \begin{verbatim} -% \DeclarePairedDelimiterX\braket[2]{\langle}{\rangle}% -% {#2\,#1\vert\,#3}{#1\,\middle\vert\,#2} +% \[ +% \innerp*{A}{ \frac{1}{2} } \quad +% \brakket[\Big]{B}{\sum_{k} f_k}{C} +% \] % \end{verbatim} +% \[ +% \innerp*{A}{ \frac{1}{2} } \quad +% \brakket[\Big]{B}{\sum_{k}}{C} +% \] +% \iffalse +% \bigskip % +% \noindent +% \textbf{\textit{Side note:}} We have changed the internal code of +% \cs{DeclarePairedDelimiter} and \cs{DeclarePairedDelimiterX} such +% that the starred version does no longer give the odd spacings that +% \cs{left}\dots\cs{right} sometimes give. Compare this +% \begin{verbatim} +% \[ +% 2\innerp{A}{B} \quad 2\innerp*{A}{B} \quad 2\left\langle A,B \right\rangle +% \] +% \end{verbatim} +% \[ +% \sin\innerp{A}{B} \quad +% \sin\innerp*{A}{B} \quad +% \sin\left\langle A,B \right\rangle +% \] +% The spacing in the last one does not behave like other fences (this +% is a feature of the \cs{left}\dots\cs{right} construction). +% \fi % % \subsection{Special symbols} % @@ -2017,10 +2075,10 @@ and the derived files % \begin{macrocode} %<*package> \ProvidesPackage{mathtools}% - [2010/07/11 v1.08 mathematical typesetting tools (MH)] + [2010/07/21 v1.08b mathematical typesetting tools (MH)] % \end{macrocode} % \begin{macrocode} -\RequirePackage{keyval,calc,graphicx} +\RequirePackage{keyval,calc} \RequirePackage{mhsetup}[2007/12/03] \MHInternalSyntaxOn % \end{macrocode} @@ -3031,9 +3089,12 @@ and the derived files % \end{macrocode} % Define the starred command to just put \cs{left} and \cs{right} % before the delimiters. +% \changes{1.08e}{2010/09/02}{`Fixed' \cs{left}\dots\cs{right} bad spacing} +% \changes{1.08e}{2010/09/14}{redid the \cs{left}\dots\cs{right} fix, +% see \cs{DeclarePairedDelimiterX} for details.} % \begin{macrocode} \@namedef{MT_delim_\MH_cs_to_str:N #1 _star:}##1 - {\left#2 ##1 \right #3}% + {\mathopen{}\mathclose\bgroup\left#2 ##1 \aftergroup\egroup\right #3}% % \end{macrocode} % The command with optional argument. It should be \cs{bigg} or % alike. @@ -3070,52 +3131,87 @@ and the derived files % can specify the number of arguments the created macro has, and they % can specify the code for the inner part of the macro. Other than % that the code is fairly similar to \cs{DeclarePairedDelimiter} +% \changes{v1.08e}{2010/09/02}{Provided better implementation of \cs{DeclarePairedDelimiterX}} % \begin{macrocode} \def\MHempty{} -\def\DeclarePairedDelimiterX#1[#2]#3#4#5#6{% +\def\DeclarePairedDelimiterX#1[#2]#3#4#5{% \@ifdefinable{#1}{ % \end{macrocode} -% The constructor takes six arguments, the name of the macro, the -% number of arguments (1-8), the left and right delimiter, the inner -% code for the `normal' macro, and the inner code for the starred -% macro. First we verify that the number of arguments fit. +% The constructor takes five arguments, the name of the macro, the +% number of arguments (1-9), the left and right delimiter, the inner +% code for the two macros. First we verify that the number of arguments fit. % \begin{macrocode} - \ifnum#2>8\relax - \PackageError{mathtools}{No~ more~ than~ 8~ arguments}{} + \ifnum#2>9\relax + \PackageError{mathtools}{No~ more~ than~ 9~ arguments}{} \else \ifnum#2<1\relax \PackageError{mathtools}{Macro~ need~ 1~ or~ more~ arguments}{} \fi \fi % \end{macrocode} -% We store the number of arguments in a temp counter. The starred -% macro has this exact number of arguments, whereas the un-starred -% also have the optional argument. +% We make sure to store the delimiter size in the local variable +% \cs{delimsize}. Then users can refer to the size in the fifth +% argument. In the starred version it will refer to \cs{middle} and in +% the normal version it will hold the provided optional argument. % \begin{macrocode} - % store the argument number in a temp counter - \@tempcnta=#2 \@xp\@xp\@xp \newcommand \@xp\csname MT_delim_\MH_cs_to_str:N #1 _star:\endcsname - [\@tempcnta] + [#2] { - \left#3 #6 \right#4 + \begingroup + \def\delimsize{\middle} +% \end{macrocode} +% This is slightly controversial, \cs{left}\dots\cs{right} are known +% to produce an inner atom, thus may cause different spacing than +% normal delimiters. We `fix' this by introducing \cs{mathopen} and \cs{mathclose}: +% \changes{v1.08e}{2010/09/14}{redid the left/right fix, inspired by +% ctt thread named `spacing after \cs{right}) and before \cs{left})' +% started 2010-08-12.} +% \begin{macrocode} + \mathopen{}\mathclose\bgroup\left#3 #5 \aftergroup\egroup\right#4 + \endgroup } - \advance\@tempcnta by 1 - \@xp\@xp\@xp - \newcommand - \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname % \end{macrocode} +% In order for the starred and non-starred version to have the same +% arguments, we need to introduce an extra macro to catch the optional +% argument (this means that the non-starred version can actually +% support ten arguments!). % Here we do things a little differently than with % \cs{DeclarePairedDelimiter}. The optional argument have \cs{MHempty} % as the default. This is locally changed when we scale the % delimiters, such that it can eat the l/r if needed. % \begin{macrocode} - [\@tempcnta][\MHempty] + \@xp\@xp\@xp + \newcommand + \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar:\endcsname + [1][\MHempty] + { +% \end{macrocode} +% We need to introduce a local group in order to support nesting. It +% is ended inside \verb|\MT_delim_\MH_cs_to_str:N #1 _nostar_inner:| +% \begin{macrocode} + \begingroup + \def\delimsize{##1} + \@nameuse{MT_delim_\MH_cs_to_str:N #1 _nostar_inner:} + } +% \end{macrocode} +% Next we provide the inner workhorse. We need a bit of expansion +% magic to get \cs{delimsize} to work. +% \begin{macrocode} + \@xp\@xp\@xp + \newcommand + \@xp\csname MT_delim_\MH_cs_to_str:N #1 _nostar_inner:\endcsname + [#2] { - \mathopen{\let\MHempty\@gobble\@nameuse {\MH_cs_to_str:N ##1 l} #3} + \mathopen{% + \let\MHempty\@gobble + \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize l\endcsname #3} #5 - \mathclose{\let\MHempty\@gobble\@nameuse {\MH_cs_to_str:N ##1 r} #4} + \mathclose{% + \let\MHempty\@gobble + \@xp\@xp\@xp\csname\@xp\MH_cs_to_str:N \delimsize r\endcsname #4} + \endgroup } \DeclareRobustCommand{#1}{ \@ifstar @@ -3708,8 +3804,11 @@ and the derived files % document. Since they depend on \cs{nrightarrow} and % \cs{nleftarrow} we test for these and let the macros throw an % error if they are missing. +% \changes{v1.08b}{2010/07/21}{Moved graphicx loading down here such +% that we do not get into option clash problems} % \begin{macrocode} \AtBeginDocument{% + \RequirePackage{graphicx}% \@ifundefined{nrightarrow}{% \providecommand\nuparrow{% \PackageError{mathtools}{\string\nuparrow\space~ is~ diff --git a/Master/texmf-dist/source/latex/mh/xfrac.dtx b/Master/texmf-dist/source/latex/mh/xfrac.dtx index 0a4b2e3ad59..f70ba65582c 100644 --- a/Master/texmf-dist/source/latex/mh/xfrac.dtx +++ b/Master/texmf-dist/source/latex/mh/xfrac.dtx @@ -1,14 +1,12 @@ % \iffalse meta-comment % -% Copyright (C) 2004, 2008, 2009 by Morten Hoegholm <mh.ctan@gmail.com> +% Copyright (C) 2004, 2008-2010 by Morten Hoegholm <mh.ctan@gmail.com> % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either -% version 1.3 of this license or (at your option) any later +% version 1.3c 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.3 or later is part of all distributions of -% LaTeX version 2005/12/01 or later. % % This work has the LPPL maintenance status "maintained". % @@ -66,7 +64,7 @@ \input docstrip.tex \Msg{************************************************************************} \Msg{* Installation} -\Msg{* Package: xfrac 2009/08/10 v0.2a textstyle fractions (MH)} +\Msg{* Package: xfrac 2009/08/10 v0.3 textstyle fractions (MH)} \Msg{************************************************************************} \keepsilent @@ -76,15 +74,13 @@ This is a generated file. -Copyright (C) 2004, 2008, 2009 by Morten Hoegholm <mh.ctan@gmail.com> +Copyright (C) 2004, 2008-2010 by Morten Hoegholm <mh.ctan@gmail.com> This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either -version 1.3 of this license or (at your option) any later +version 1.3c 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.3 or later is part of all distributions of -LaTeX version 2005/12/01 or later. This work has the LPPL maintenance status "maintained". @@ -126,7 +122,7 @@ and the derived files %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{xfrac.drv}% - [2009/08/10 v0.2a textstyle fractions (MH)] + [2010/02/02 v0.3 Text style fractions] \RequirePackage{fix-cm} \documentclass{ltxdoc} @@ -174,7 +170,7 @@ and the derived files \providecommand*\pkg[1]{\textsf{#1}} \newcommand*\switch[2]{{\fontfamily{#1}\selectfont #2}} - +\usepackage{lmodern} \begin{document} \catcode`\_=12 \DocInput{xfrac.dtx} @@ -184,6 +180,10 @@ and the derived files % % \GetFileInfo{xfrac.drv} % \CheckSum{249} +% +% \changes{v0.3}{2010/02/02}{Update to new \pkg{xtemplate} system} +% \changes{v0.3}{2010/02/02}{Include custom values for +% \pkg{lmodern}} % % \changes{v0.2a}{2009/08/10}{Update for new version of expl3} % @@ -491,36 +491,36 @@ and the derived files % % \begin{TemplateDescription}{xfrac}{text} % -% \TemplateKey{numerator-font}{n} +% \TemplateKey{numerator-font}{tokenlist} % {Font family specification to use for the numerator.} % {\cs{f@family}} % -% \TemplateKey{numerator-format}{f1} +% \TemplateKey{numerator-format}{function 1 arg} % {Action to be taken on the numerator.} % {Process argument unchanged} % -% \TemplateKey{slash-symbol}{n} +% \TemplateKey{slash-symbol}{tokenlist} % {The separator symbol. If not specified the default value will be % used instead.} % {Solidus (\cs{textfractionsolidus})} % -% \TemplateKey{slash-symbol-font}{n} +% \TemplateKey{slash-symbol-font}{tokenlist} % {Font family specification to use for the separator symbol.} % {\cs{f@family}} % -% \TemplateKey{slash-symbol-format}{f1} +% \TemplateKey{slash-symbol-format}{function 1 arg} % {Action to be taken on the separator symbol.} % {Process argument unchanged} % -% \TemplateKey{denominator-font}{n} +% \TemplateKey{denominator-font}{tokenlist} % {Font family specification to use for the denominator.} % {\cs{f@family}} % -% \TemplateKey{denominator-format}{f1} +% \TemplateKey{denominator-format}{function 1 arg} % {Action to be taken on the denominator.} % {Process argument unchanged} % -% \TemplateKey{h-scale}{n} +% \TemplateKey{h-scale}{tokenlist} % {Factor by which the numerator and denominator should be % horizontally scaled. It should only be used if the real superior % and inferior fonts are not available. For instance Stempel @@ -528,12 +528,12 @@ and the derived files % by a factor of 1.1.} % {1} % -% \TemplateKey{v-scale}{n} +% \TemplateKey{v-scale}{tokenlist} % {Same as \key{h-scale} only vertically. Probably not of much use % but added for completetion.} % {1} % -% \TemplateKey{scale-factor}{n} +% \TemplateKey{scale-factor}{tokenlist} % {Fraction of the size of \key{slash-symbol}. Used for setting the % font size of numerator and denominator. Usually a value of app.\ % \sfrac{5}{6} produces fine results. It should only be used if the @@ -541,54 +541,50 @@ and the derived files % Stempel Garamond looks better if the factor is 0.9.} % {0.83333} % -% \TemplateKey{scale-relative}{s} +% \TemplateKey{scale-relative}{choice} % {If set to `true' the font size of the numerator and denominator % is scaled with respect to the height of the \key{slash-symbol}. If % set to `false' the font is scaled with respect to the total height % of the \key{slash-symbol}.} % {true} % -% \TemplateKey{scaling}{s} +% \TemplateKey{scaling}{choice} % {If set to `true' the fonts are allowed to scale. If set to % `false' they are not. See the `Janson' example for an application.} % {true} % -% \TemplateKey{numerator-top-sep}{L} +% \TemplateKey{numerator-top-sep}{length} % {Dimension specifying the space between the top of the % \key{slash-symbol} and the top of the numerator. If not specified, % the depth of the solidus will be used, because this value will % make the fraction look even.} % {Unspecified} % -% \TemplateKey{numerator-bot-sep}{L} +% \TemplateKey{numerator-bot-sep}{length} % {Dimension specifying the lift of the numerator from the % baseline.} % {Unspecified} % -% \TemplateKey{denominator-bot-sep}{L} +% \TemplateKey{denominator-bot-sep}{length} % {Dimension specifying the lift of the denominator from the % baseline.} % {Unspecified} % -% \TemplateKey{slash-right-kern}{L} +% \TemplateKey{slash-right-kern}{length} % {Dimension specifying the kerning between the \key{slash-symbol} -% and the numerator. If specified in terms of font specific -% dimensions such as \texttt{em} it is better to use -% \cs{DelayEvaluation}.} +% and the numerator.} % {\texttt{0pt}} % -% \TemplateKey{slash-left-kern}{L} +% \TemplateKey{slash-left-kern}{length} % {Dimension specifying the kerning between the \key{slash-symbol} -% and the denominator. If specified in terms of font specific -% dimensions such as \texttt{em} it is better to use -% \cs{DelayEvaluation}.} +% and the denominator.} % {\texttt{0pt}} % -% \TemplateKey{math-mode}{s} +% \TemplateKey{math-mode}{choice} % {Are we in math mode or not?} % {false} % -% \TemplateKey{phantom}{n} +% \TemplateKey{phantom}{tokenlist} % {A character that suits the common cases. As we would mostly want % to use numbers in text mode we choose a `tall' number, while in % math it is somewhat different.} @@ -605,24 +601,24 @@ and the derived files % % \begin{TemplateDescription}{xfrac}{math} % -% \TemplateKey{numerator-font}{n} +% \TemplateKey{numerator-font}{tokenlist} % {Font family specification to use for the numerator.} % {\cs{number}\cs{fam}} % -% \TemplateKey{slash-symbol}{n} +% \TemplateKey{slash-symbol}{tokenlist} % {The separator symbol. If not specified the default value will be % used instead.} % {Virgule ($/$)} % -% \TemplateKey{slash-symbol-font}{n} +% \TemplateKey{slash-symbol-font}{tokenlist} % {Font family specification to use for the separator symbol.} % {\cs{number}\cs{fam}} % -% \TemplateKey{denominator-font}{n} +% \TemplateKey{denominator-font}{tokenlist} % {Font family specification to use for the denominator.} % {\cs{number}\cs{fam}} % -% \TemplateKey{scale-factor}{n} +% \TemplateKey{scale-factor}{tokenlist} % {Fraction of the size of \key{slash-symbol}. In math mode we % cannot rely on the fonts to be able to scale, but giving a default % scale of 0.7 fits into the regular size changing scheme---the @@ -631,47 +627,47 @@ and the derived files % That's close enough.} % {0.7} % -% \TemplateKey{scale-relative}{s} +% \TemplateKey{scale-relative}{choice} % {If set to `true' the font size of the numerator and denominator % is scaled with respect to the height of the \key{slash-symbol}. If % set to `false' the font is scaled with respect to the total height % of the \key{slash-symbol}.} % {false} % -% \TemplateKey{scaling}{s} +% \TemplateKey{scaling}{choice} % {If set to `true' the fonts are allowed to scale. If set to % `false' they are not. See the `plainmath' example for an application.} % {true} % -% \TemplateKey{numerator-top-sep}{L} +% \TemplateKey{numerator-top-sep}{length} % {Dimension specifying the space between the top of the % \key{slash-symbol} and the top of the numerator. If not specified, % the depth of the virgule will be used, because this value will % make the fraction look even.} % {\texttt{0pt}} % -% \TemplateKey{denominator-bot-sep}{L} +% \TemplateKey{denominator-bot-sep}{length} % {Dimension specifying the lift of the denominator from the % baseline.} % {\texttt{0pt}} % -% \TemplateKey{slash-right-mkern}{n} +% \TemplateKey{slash-right-mkern}{tokenlist} % {Same as \key{slash-right-kern} but for math mode only and should % be specified in \texttt{mu} units. This is because \pkg{calc} % can't use mu-expressions.} % {\texttt{-2mu}} % -% \TemplateKey{slash-left-mkern}{n} +% \TemplateKey{slash-left-mkern}{tokenlist} % {Same as \key{slash-left-kern} but for math mode only and should % be specified in \texttt{mu} units. This is because \pkg{calc} % can't use mu-expressions.} % {\texttt{-1mu}} % -% \TemplateKey{math-mode}{s} +% \TemplateKey{math-mode}{choice} % {Are we in math mode or not?} % {true} % -% \TemplateKey{phantom}{n} +% \TemplateKey{phantom}{tokenlist} % {A character that suits the common cases. In math we have a high % risk of using a parenthesis, so we choose that. Text mode is % another story.} @@ -685,354 +681,588 @@ and the derived files % and \key{slash-right-kern} have no meaning in this template. % % \end{TemplateDescription} -% -% -% +% % \StopEventually{} % -% \section{Implementation} +%\section{Implementation} % -% \changes{v0.10b}{2004/04/07}{Now uses \cs{InternalSyntaxOn}} -% \changes{v0.2}{2008/08/04}{Now uses \cs{ProvidesExplPackage}} -% We set up the programming interface. We need the -% \pkg{template} and \pkg{xparse} packages from the -% experimental code, more precisely from the `xbase' bundle. The -% other packages are well-known. +% \begin{macrocode} +%<*package> +% \end{macrocode} +% +% The usual lead-off: provides an experimental package! % \begin{macrocode} \RequirePackage{expl3}[2009/08/05] -\ProvidesExplPackage{xfrac}{2009/08/10}{0.2a}{Text fractions} +\ProvidesExplPackage{xfrac}{2010/02/02}{0.3}{Text fractions} % \end{macrocode} % +% Some support is needed: a bit wider than the normal \pkg{xpackage} +% stuff, but not by much. % \begin{macrocode} -\RequirePackage{textcomp,graphicx,amstext} -\RequirePackage{template}[2008/08/03] -\RequirePackage{xparse}[2008/08/03] -% \end{macrocode} -% With v0.10b the new internal syntax using |_| and |:| was -% introduced. Starting from v0.2 the expl3 code base is used and, -% hence, also its programming setup. White space is ignored as well, -% so any |@|-signs in the code are remnants of old \LaTeX{} coding -% conventions. +\RequirePackage { amstext , graphicx , l3keys2e , textcomp , xtemplate } +% \end{macrocode} % -% An option: +%\begin{macro}{\l_xfrac_cm_std_bool} +% There is one option to support. % \begin{macrocode} -\bool_new:N \g_cm_recommended_bool -\DeclareOption{cm-recommended} - { \bool_gset_true:N \g_cm_recommended_bool } -\DeclareOption{cm-standard} - { \bool_gset_false:N \g_cm_recommended_bool } -\ExecuteOptions{cm-recommended} -\ProcessOptions\relax +\keys_define:nn { xfrac } { + cm-recommended .choice:, + cm-recommended / + false .code:n = + { \bool_set_true:N \l_xfrac_cm_std_bool }, + cm-recommended / + true .code:n = + { \bool_set_false:N \l_xfrac_cm_std_bool }, + cm-recommended .default:n = { true }, + cm-standard .bool_set:N = \l_xfrac_cm_std_bool +} +\ProcessKeysOptions { xfrac } % \end{macrocode} +%\end{macro} % -% \begin{macro}{\l_xfrac_temp_box} -% \begin{macro}{\l_xfrac_slash_box} -% We use two box registers. We could probably get away with using -% scratch boxes, but this feels safer. Anyway we're all using -% \eTeX{} now so why not? +%\begin{macro}{\l_xfrac_slash_box} +%\begin{macro}{\l_xfrac_tmp_box} +% In keeping with the \LaTeX3 philosophy, rather than use generic +% scratch boxes and get confused, \pkg{xfrac} reserves its own named +% working space. % \begin{macrocode} -\box_new:N \l_xfrac_temp_box \box_new:N \l_xfrac_slash_box +\box_new:N \l_xfrac_tmp_box % \end{macrocode} -% \end{macro} -% \end{macro} +%\end{macro} +%\end{macro} % -% \subsection{The Templates} -% Then we declare the template. +%\begin{macro}{\xfrac_tmp:w} +% Used for the raised boxes: weird as it does not take an argument +% but the \cs{raisebox} does. % \begin{macrocode} -\DeclareTemplateType{xfrac}{3} +\cs_new:Npn \xfrac_tmp:w { } % \end{macrocode} -% The template type `text'. Make two separate templates: text and -% math!! It is okay they share keys but it just gets too complicated -% within the template declaration. +%\end{macro} +% +%\subsection{Initialisation of variables} +% +% Variables used in templates have to be set up: there is not +% much to say about these, other than that they must exist. +% +%\begin{macro}{\l_xfrac_denominator_bot_sep_dim} +%\begin{macro}{\l_xfrac_numerator_bot_sep_dim} +%\begin{macro}{\l_xfrac_numerator_top_sep_dim} +%\begin{macro}{\l_xfrac_slash_left_sep_dim} +%\begin{macro}{\l_xfrac_slash_right_sep_dim} +% Fixed lengths. % \begin{macrocode} -\DeclareTemplate{xfrac}{text}{3}{ - numerator-font = n [\f@family] \xfrac_numeratorfont:, - numerator-format = f1 [#1] \xfrac_numeratorformat:n, - slash-symbol = n [\textfractionsolidus] - \xfrac_slashsymbol:, - slash-symbol-font = n [\f@family] \xfrac_slashsymbolfont:, - slash-symbol-format = f1 [#1] \xfrac_slashsymbolformat:n, - denominator-font = n [\f@family] \xfrac_denominatorfont:, - denominator-format = f1 [#1] \xfrac_denominatorformat:n, - h-scale = n [1] \xfrac_hscale:, - v-scale = n [1] \xfrac_vscale:, - scale-factor = n [.83333] \xfrac_scalefactor:, - scale-relative = s [true] - { \cs_set:Npn \xfrac_relscale: {\box_ht:N\l_xfrac_slash_box}} - { \cs_set:Npn \xfrac_relscale: { - \dim_eval:n { \box_ht:N\l_xfrac_temp_box + \box_dp:N\l_xfrac_temp_box }} }, - scaling = s [true] - {\cs_set:Npn\xfrac_fontscale: { - \fontsize{\xfrac_scalefactor: \xfrac_relscale:}{\c_zero_dim}\selectfont}} - { \cs_set_eq:NN \xfrac_fontscale: \prg_do_nothing: }, +\dim_new:N \l_xfrac_denominator_bot_sep_dim +\dim_new:N \l_xfrac_numerator_bot_sep_dim +\dim_new:N \l_xfrac_numerator_top_sep_dim +\dim_new:N \l_xfrac_slash_left_sep_dim +\dim_new:N \l_xfrac_slash_right_sep_dim % \end{macrocode} -% Here comes some fake lengths. I've decided to call them with the -% suffix |_fdim|, so that I will remember to use them right. +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +% +%\begin{macro}{\l_xfrac_denominator_font_tl} +%\begin{macro}{\l_xfrac_hscale_tl} +%\begin{macro}{\l_xfrac_numerator_font_tl} +%\begin{macro}{\l_xfrac_phantom_tl } +%\begin{macro}{\l_xfrac_scale_factor_tl} +%\begin{macro}{\l_xfrac_slash_left_msep_tl} +%\begin{macro}{\l_xfrac_slash_right_msep_tl} +%\begin{macro}{\l_xfrac_slash_symbol_tl} +%\begin{macro}{\l_xfrac_slash_symbol_font_tl} +%\begin{macro}{\l_xfrac_vscale_tl} +% Token lists, which include floating-point numbers and math(s) +% skips. % \begin{macrocode} - numerator-top-sep = L [\c_max_dim] \l_xfrac_numeratortopsep_fdim, - numerator-bot-sep = L [\c_max_dim] \l_xfrac_numeratorbotsep_fdim, - denominator-bot-sep = L [\c_max_dim] \l_xfrac_denominatorbotsep_fdim, - slash-right-kern = L [0pt] \l_xfrac_slashrightsep_fdim, - slash-left-kern = L [0pt] \l_xfrac_slashleftsep_fdim, +\tl_new:N \l_xfrac_denominator_font_tl +\tl_new:N \l_xfrac_hscale_tl +\tl_new:N \l_xfrac_numerator_font_tl +\tl_new:N \l_xfrac_phantom_tl +\tl_new:N \l_xfrac_scale_factor_tl +\tl_new:N \l_xfrac_slash_left_msep_tl +\tl_new:N \l_xfrac_slash_right_msep_tl +\tl_new:N \l_xfrac_slash_symbol_tl +\tl_new:N \l_xfrac_slash_symbol_font_tl +\tl_new:N \l_xfrac_vscale_tl % \end{macrocode} -% As calc can't handle |\muskip|s, I've made them of type `n' and -% added the suffix |_fmu| to indicate `fake mu skip'. +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +% +%\begin{macro}{\xfrac_fontscale:} +%\begin{macro}{\xfrac_math:n} +%\begin{macro}{\xfrac_denominator_font_change:} +%\begin{macro}{\xfrac_denominator_format:n} +%\begin{macro}{\xfrac_numerator_font_change:} +%\begin{macro}{\xfrac_numerator_format:n} +%\begin{macro}{\xfrac_relscale:} +%\begin{macro}{\xfrac_slash_symbol_font_change:} +%\begin{macro}{\xfrac_slash_symbol_format:n} +%\begin{macro}{\xfrac_text_or_math:n} +% Functions, either things which are calculated `on the fly' +% (no argument required) or are functions taking one argument in the +% code. % \begin{macrocode} - slash-right-mkern = n [-2mu] \l_xfrac_slashrightmsep_fmu, - slash-left-mkern = n [-1mu] \l_xfrac_slashleftmsep_fmu, - math-mode = s [false] { \cs_set_eq:NN \xfrac_math: \ensuremath } - { \cs_set_eq:NN \xfrac_math: \use:n }, - phantom = n [8] \xfrac_phantom:, -}{ - \DoParameterAssignments - \mode_if_math:TF{ - \cs_set_eq:NN \xfrac_textormath: \text - \cs_set:Npx \xfrac_slashfontchange: {\tex_fam:D \xfrac_slashsymbolfont: } - \cs_set:Npx \xfrac_numeratorfontchange: {\tex_fam:D \xfrac_numeratorfont: } - \cs_set:Npx \xfrac_denominatorfontchange: {\tex_fam:D \xfrac_denominatorfont: } - }{ - \cs_set_eq:NN \xfrac_textormath: \mbox - \cs_set:Npn\xfrac_slashfontchange: { - \fontfamily{\xfrac_slashsymbolfont: }\selectfont} - \cs_set:Npn\xfrac_numeratorfontchange: { - \fontfamily{\xfrac_numeratorfont: }\selectfont} - \cs_set:Npn\xfrac_denominatorfontchange: { - \fontfamily{\xfrac_denominatorfont: }\selectfont} - } - \xfrac_textormath: { +\cs_new_nopar:Npn \xfrac_fontscale: +\cs_new:Npn \xfrac_math:n #1 { } +\cs_new_nopar:Npn \xfrac_denominator_font_change: { } +\cs_new:Npn \xfrac_denominator_format:n #1 { } +\cs_new_nopar:Npn \xfrac_numerator_font_change: { } +\cs_new:Npn \xfrac_numerator_format:n #1 { } +\cs_new_nopar:Npn \xfrac_relscale: { } +\cs_new_nopar:Npn \xfrac_slash_symbol_font_change: { } +\cs_new:Npn \xfrac_slash_symbol_format:n #1 { } +\cs_new:Npn \xfrac_text_or_math:n #1 { } % \end{macrocode} -% \changes{v0.11a}{2004/08/24}{Added \cs{m@th}} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +%\end{macro} +% +%\subsection{The template} +% +% There is only one object type in \pkg{xfrac}, rather unimaginatively +% named \texttt{xfrac}. % \begin{macrocode} - \m@th - \sbox\l_xfrac_temp_box {\xfrac_math: {\vphantom{(}}} - \sbox\l_xfrac_slash_box { - \xfrac_math: { - \xfrac_slashsymbolformat:n { - \xfrac_math: { - \xfrac_slashfontchange: - \IfValueTF{#2}{#2}{\xfrac_slashsymbol: } - } - } - } - } - \dim_compare:nNnTF \l_xfrac_numeratortopsep_fdim = \c_max_dim - { - \dim_compare:nNnTF \l_xfrac_numeratorbotsep_fdim = \c_max_dim - { +\DeclareObjectType { xfrac } { 3 } % \end{macrocode} -% Both unspecified. +% +% A single template interface is used for both text and math(s), which +% does make a few things a little complex later. % \begin{macrocode} - \cs_set:Npn\xfrac_next: {\raisebox{\box_ht:N\l_xfrac_slash_box - -\box_dp:N\l_xfrac_slash_box-\height}} - }{ +\DeclareTemplateInterface { xfrac } { text } { 3 } { + denominator-bot-sep : length = \c_max_dim , + denominator-font : tokenlist = \f@family , + denominator-format : function 1 = #1 , + h-scale : tokenlist = 1 , + math-mode : choice { false , true } + = false , + numerator-font : tokenlist = \f@family , + numerator-format : function 1 = #1 , + numerator-bot-sep : length = \c_max_dim , + numerator-top-sep : length = \c_max_dim , + phantom : tokenlist = 8 , + scale-factor : tokenlist = 0.83333 , + scale-relative : choice { false , true } + = true , + scaling : choice { false , true } + = true , + slash-left-kern : length = 0 pt , + slash-left-mkern : tokenlist = -2 mu , + slash-right-kern : length = 0 pt , + slash-right-mkern : tokenlist = -1 mu , + slash-symbol : tokenlist = \textfractionsolidus , + slash-symbol-font : tokenlist = \f@family , + slash-symbol-format : function 1 = #1 , + v-scale : tokenlist = 1 , +} % \end{macrocode} -% Use only bottom specification. +% +% Most of the variable binding is quite simple: of course, the choices +% are a little more complicated. That is particularly true where +% these have to set up `on the fly' functions. % \begin{macrocode} - \cs_set:Npn\xfrac_next: {\raisebox{\l_xfrac_numeratorbotsep_fdim }} - } - } - { +\DeclareTemplateCode { xfrac } { text } { 3 } + { + denominator-bot-sep = \l_xfrac_denominator_bot_sep_dim , + denominator-font = \l_xfrac_denominator_font_tl , + denominator-format = \xfrac_denominator_format:n , + h-scale = \l_xfrac_hscale_tl , + math-mode = + { + false = \cs_set_eq:NN \xfrac_math:n \use:n, + true = \cs_set_eq:NN \xfrac_math:n \ensuremath + }, + numerator-font = \l_xfrac_numerator_font_tl , + numerator-format = \xfrac_numerator_format:n , + numerator-bot-sep = \l_xfrac_numerator_bot_sep_dim , + numerator-top-sep = \l_xfrac_numerator_top_sep_dim , + phantom = \l_xfrac_phantom_tl , + scale-factor = \l_xfrac_scale_factor_tl , + scale-relative = + { + false = + \cs_set_nopar:Npn \xfrac_relscale: + { + \dim_eval:n + { + \box_ht:N \l_xfrac_tmp_box + + \box_dp:N \l_xfrac_tmp_box + } + }, + true = + \cs_set_nopar:Npn \xfrac_relscale: + { \box_ht:N \l_xfrac_slash_box } + }, + scaling = + { + false = \cs_set_eq:NN \xfrac_fontscale: \prg_do_nothing:, + true = + \cs_set_nopar:Npn \xfrac_fontscale: + { + \fontsize { \l_xfrac_scale_factor_tl \xfrac_relscale: } + { \c_zero_dim } + \selectfont + } + }, + slash-left-kern = \l_xfrac_slash_left_sep_dim , + slash-left-mkern = \l_xfrac_slash_left_msep_tl , + slash-right-kern = \l_xfrac_slash_right_sep_dim , + slash-right-mkern = \l_xfrac_slash_right_msep_tl , + slash-symbol = \l_xfrac_slash_symbol_tl , + slash-symbol-font = \l_xfrac_slash_symbol_font_tl , + slash-symbol-format = \xfrac_slash_symbol_format:n , + v-scale = \l_xfrac_vscale_tl + } % \end{macrocode} -% Use only top specification. +% The implementation part starts with applying all of the settings +% from above. The first part of the set up is then to determine +% whether the surroundings are text or math(s), and react accordingly. % \begin{macrocode} - \dim_compare:nNnTF \l_xfrac_numeratorbotsep_fdim = \c_max_dim + { + \AssignTemplateKeys + \mode_if_math:TF { - \cs_set:Npn\xfrac_next: { - \raisebox{ - \box_ht:N\l_xfrac_slash_box - \l_xfrac_numeratortopsep_fdim - - \height + \cs_set_eq:NN \xfrac_text_or_math:n \text + \cs_set_nopar:Npx \xfrac_denominator_font_change: + { \tex_fam:D \l_xfrac_denominator_font_tl } + \cs_set_nopar:Npx \xfrac_numerator_font_change: + { \tex_fam:D \l_xfrac_numerator_font_tl } + \cs_set_nopar:Npx \xfrac_slash_symbol_font_change: + { \tex_fam:D \l_xfrac_slash_symbol_font_tl } + } + { + \cs_set_eq:NN \xfrac_text_or_math:n \mbox + \cs_set_nopar:Npn \xfrac_denominator_font_change: + { + \fontfamily { \l_xfrac_denominator_font_tl } + \selectfont + } + \cs_set_nopar:Npn \xfrac_numerator_font_change: + { + \fontfamily { \l_xfrac_numerator_font_tl } + \selectfont + } + \cs_set_nopar:Npn \xfrac_slash_symbol_font_change: + { + \fontfamily { \l_xfrac_slash_symbol_font_tl } + \selectfont } - } } +% \end{macrocode} +%\changes{v0.11a}{2004/08/24}{Added \cs{m@th}} +% Everything is now either inside \cs{text} or an \cs{mbox}, depending +% upon the surroundings. First, there are some boxes to set up. +% \begin{macrocode} + \xfrac_text_or_math:n { + \m@th + \hbox_set:Nn \l_xfrac_tmp_box + { \xfrac_math:n { \vphantom { ( ) } } } + \hbox_set:Nn \l_xfrac_slash_box + { + \xfrac_math:n + { + \xfrac_slash_symbol_format:n + { + \xfrac_math:n + { + \xfrac_slash_symbol_font_change: + \IfNoValueTF {#2} + { \l_xfrac_slash_symbol_tl } {#2} + } + } + } + } % \end{macrocode} -% Over-specification. +% Check on the numerator separator dimensions. The code starts with the +% assumption that neither has been given, as this can then be used to +% set up a default, which is also used when both values are set +% erroneously. % \begin{macrocode} - \PackageError{xfrac} - {You~ have~ specified~ both~ numerator-top-sep~ and~ - numerator-bot-sep} - {I~ will~ pretend~ you~ didn't~ specify~ any~ of ~them} - \cs_set:Npn\xfrac_next: {\raisebox{\box_ht:N\l_xfrac_slash_box - -\box_dp:N\l_xfrac_slash_box-\height}} - } - } + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { + \box_ht:N \l_xfrac_slash_box + - \box_dp:N \l_xfrac_slash_box + - \height + } + } + \dim_compare:nNnTF + { \l_xfrac_numerator_top_sep_dim } = { \c_max_dim } + { + \dim_compare:nNnF + { \l_xfrac_numerator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { \dim_use:N \l_xfrac_numerator_bot_sep_dim } + } + } + } + { + \dim_compare:nNnTF + { \l_xfrac_numerator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { + \box_ht:N \l_xfrac_slash_box + - \dim_use:N \l_xfrac_numerator_top_sep_dim + - \height + } + } + } + { + \msg_error:nn { xfrac } + { over-specified-numerator-sep } + } + } % \end{macrocode} -% Typeset the numerator +% Typeset the numerator. % \begin{macrocode} - \xfrac_next: { - \xfrac_fontscale: - \xfrac_numeratorformat:n { - \scalebox{\xfrac_hscale: }[\xfrac_vscale: ] - { \xfrac_math:{ \xfrac_numeratorfontchange: - {\vphantom{\xfrac_phantom: }#1} } } - } - } - \xfrac_math: { % THIS IS JUST WRONG! - \mode_if_math:TF { \mskip \l_xfrac_slashrightmsep_fmu } - {\hskip \l_xfrac_slashrightsep_fdim} - } + \xfrac_tmp:w + { + \xfrac_fontscale: + \xfrac_numerator_format:n + { + \scalebox { \l_xfrac_hscale_tl } [ \l_xfrac_vscale_tl ] + { + \xfrac_math:n + { + \xfrac_numerator_font_change: + { + \vphantom { \l_xfrac_phantom_tl } + #1 + } + } + } + } + } + \xfrac_math:n + { % THIS IS JUST WRONG! + \mode_if_math:TF + { \tex_mskip:D \l_xfrac_slash_right_msep_tl } + { \tex_hskip:D \l_xfrac_slash_right_sep_dim } + } % \end{macrocode} -% Typeset the separator +% Typeset the separator. % \begin{macrocode} - \usebox\l_xfrac_slash_box - \xfrac_math: { - \mode_if_math:TF { - \mskip \l_xfrac_slashleftmsep_fmu - }{ - \hskip \l_xfrac_slashleftsep_fdim - } } + \box_use:N \l_xfrac_slash_box + \xfrac_math:n + { + \mode_if_math:TF + { \tex_mskip:D \l_xfrac_slash_left_msep_tl } + { \tex_hskip:D \l_xfrac_slash_left_sep_dim } + } % \end{macrocode} -% Typeset the denominator +% Typeset the denominator. % \begin{macrocode} - \dim_compare:nNnTF \l_xfrac_denominatorbotsep_fdim=\c_max_dim - { \raisebox{-\box_dp:N \l_xfrac_slash_box} } - { - \raisebox{\l_xfrac_denominatorbotsep_fdim} - } - { - \xfrac_fontscale: - \xfrac_denominatorformat:n { - \scalebox{\xfrac_hscale:}[\xfrac_vscale:] - { \xfrac_math: { \xfrac_denominatorfontchange: - {\vphantom{\xfrac_phantom: }#3} } } - } - } + \dim_compare:nNnTF + { \l_xfrac_denominator_bot_sep_dim } = { \c_max_dim } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { \raisebox { - \box_dp:N \l_xfrac_slash_box } } + } + { + \cs_set_nopar:Npn \xfrac_tmp:w + { + \raisebox + { \dim_use:N \l_xfrac_denominator_bot_sep_dim } + } + } + \xfrac_tmp:w + { + \xfrac_fontscale: + \xfrac_denominator_format:n + { + \scalebox { \l_xfrac_hscale_tl } [ \l_xfrac_vscale_tl ] + { + \xfrac_math:n + { + \xfrac_denominator_font_change: + { + \vphantom { \l_xfrac_phantom_tl } + #3 + } + } + } + } + } + } } -} % \end{macrocode} -% -% Since math and text mode are wildly different entities we define a -% separate template for each. You already saw the `text' template, -% and here is the `math' template. +% +% Since math(s) and text mode are wildly different entities we define a +% separate template for each. You already saw the `text' +% template, and here is the `math' template. % \begin{macrocode} -\DeclareRestrictedTemplate{xfrac}{math}{text}{ - numerator-font = \number\fam, - slash-symbol = /, - slash-symbol-font = \number\fam, - denominator-font = \number\fam, - scale-factor = 0.7, - scale-relative = false, - scaling = true, - numerator-top-sep = 0pt, - denominator-bot-sep = 0pt, - math-mode = true, - phantom = (, +\DeclareRestrictedTemplate { xfrac } { text } { math } { + numerator-font = \number \fam , + slash-symbol = / , + slash-symbol-font = \number \fam , + denominator-font = \number \fam , + scale-factor = 0.7 , + scale-relative = false , + scaling = true , + numerator-top-sep = 0 pt , + denominator-bot-sep = 0 pt , + math-mode = true , + phantom = ( } % \end{macrocode} +% +%\subsection{The standard instances} % -% \subsection{The Default Instances} -% -% For the default instances we just use the relevant templates with -% the default settings. -% +% For the default instances we just use the relevant templates with +% the default settings. +% % The default `text' instance. % \begin{macrocode} -\DeclareInstance{xfrac}{default}{text}{ } +\DeclareInstance { xfrac } { default } { text } { } % \end{macrocode} -% The default `math' instance. +% +% The default `math(s)' instance. % \begin{macrocode} -\DeclareInstance{xfrac}{mathdefault}{math}{ } +\DeclareInstance { xfrac } { mathdefault } { math } { } % \end{macrocode} % \begin{macrocode} -\DeclareCollectionInstance{plainmath}{xfrac}{mathdefault}{math}{ - denominator-bot-sep=0pt, - numerator-bot-sep=0pt, - numerator-top-sep=\c_max_dim, - scale-factor = 1, - scale-relative = false, - scaling = true, - slash-right-mkern=0mu, - slash-left-mkern=0mu, +\DeclareCollectionInstance { plainmath } { xfrac } { mathdefault } + { math }{ + denominator-bot-sep = 0 pt , + numerator-bot-sep = 0 pt , + numerator-top-sep = \c_max_dim , + scale-factor = 1 , + scale-relative = false , + scaling = true , + slash-right-mkern = 0mu , + slash-left-mkern = 0mu } % \end{macrocode} -% Default Computer Modern setup. Far from optimal, but better than -% nothing. +% +% Default Computer Modern setup. Far from optimal, but better than +% nothing. % \begin{macrocode} -\DeclareInstance{xfrac}{cmr}{text}{ - denominator-bot-sep=0pt, - numerator-top-sep=\DelayEvaluation{.2ex}, - slash-left-kern=\DelayEvaluation{-.1em}, - slash-right-kern=\DelayEvaluation{-.1em}, +\DeclareInstance { xfrac } { cmr } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em } -\DeclareInstance{xfrac}{cmss}{text}{ - denominator-bot-sep=0pt, - numerator-top-sep=\DelayEvaluation{.2ex}, - slash-left-kern=\DelayEvaluation{-.1em}, - slash-right-kern=\DelayEvaluation{-.1em}, +\DeclareInstance { xfrac } { cmss } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em } -\DeclareInstance{xfrac}{cmtt}{text}{ - denominator-bot-sep=0pt, - numerator-top-sep=\DelayEvaluation{.2ex}, - slash-left-kern=\DelayEvaluation{-.1em}, - slash-right-kern=\DelayEvaluation{-.1em}, +\DeclareInstance { xfrac } { cmtt } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.2 ex , + slash-left-kern = -0.1 em , + slash-right-kern = -0.1 em } % \end{macrocode} -% We can do better for the Computer Modern fonts. For the roman -% family we choose Times. +% +% We can do better for the Computer Modern fonts. For cmr and cmss +% we choose Times, and for cmtt use Palatino. % \begin{macrocode} -\DeclareCollectionInstance{cm-recommended}{xfrac}{cmr}{text}{ - slash-symbol-font = ptm, -} +\bool_if:NF \l_xfrac_cm_std_bool + { + \DeclareInstance { xfrac } { cmr } { text } + { slash-symbol-font = ptm } + \DeclareInstance { xfrac } { cmss } { text } + { slash-symbol-font = ptm } + \DeclareInstance { xfrac } { cmtt } { text } + { slash-symbol-font = ppl } + } % \end{macrocode} -% Times also blends well with `cmss'. +% +% Things works slightly better with Latin Modern. % \begin{macrocode} -\DeclareCollectionInstance{cm-recommended}{xfrac}{cmss}{text}{ - slash-symbol-font = ptm, +\DeclareInstance { xfrac } { lmr } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0.1 ex , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em } -% \end{macrocode} -% For `cmtt' we choose the Palatino solidus as it is slightly -% thicker than Times. -% \begin{macrocode} -\DeclareCollectionInstance{cm-recommended}{xfrac}{cmtt}{text}{ - slash-symbol-font = ppl, +\DeclareInstance { xfrac } { lmss } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0 pt , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em +} +\DeclareInstance { xfrac } { lmtt } { text } { + denominator-bot-sep = 0 pt , + numerator-top-sep = 0 pt , + slash-left-kern = -0.15 em , + slash-right-kern = -0.15 em } -% \end{macrocode} -% If we used the \texttt{cm-recommended} setup we activate it. -% \begin{macrocode} -\bool_if:NT \g_cm_recommended_bool - {\UseCollection{xfrac}{cm-recommended}} % \end{macrocode} % -% \subsection{The User Command} +%\subsection{Messages} % -% Currently there is just a single user command. \cs{sfrac} takes -% two mandatory arguments: numerator and denominator. It can take an -% optional argument between the mandatory specifying the separator -% like this: -% \begin{verbatim} -% \sfrac{7}[/]{12} -% \end{verbatim} -% It also has an optional argument that comes before the first -% mandatory argument. If used it will use that instance instead of -% the auto-detected one, so a user who has defined the instance -% `cmr2' may use -% \begin{verbatim} -% \sfrac[cmr2]{7}{12} -% \end{verbatim} -% and get the settings from `cmr2' instead of the settings of the -% current font family. +% Just the one. % \begin{macrocode} -\DeclareDocumentCommand \sfrac {o mom}{ +\msg_new:nnnn { xfrac } { over-specified-numerator-sep } + {You have specified both numerator-top-sep and numerator-bot-sep} + {I will pretend that you didn't specify either of them} +% \end{macrocode} +% +%\subsection{The user command} +% +% Currently there is just a single user command. \cs{sfrac} takes +% two mandatory arguments: numerator and denominator. It can take an +% optional argument between the mandatory specifying the separator +% like this: +%\begin{verbatim} +% \sfrac{7}[/]{12} +%\end{verbatim} +% It also has an optional argument that comes before the first +% mandatory argument. If used it will use that instance instead of +% the auto-detected one, so a user who has defined the instance +% `cmr2' may use +%\begin{verbatim} +% \sfrac[cmr2]{7}{12} +%\end{verbatim} +% and get the settings from `cmr2' instead of the settings of +% the current font family. +% \begin{macrocode} +\NewDocumentCommand \sfrac { o m o m } { \mode_if_math:TF -{ - \cs_set:Npx \xfrac_next: {mathfam\number\fam} - \IfExistsInstanceTF{xfrac}{\xfrac_next: } - {\UseInstance{xfrac}{\xfrac_next: }} - {\UseInstance{xfrac}{mathdefault}} - {#2}{#3}{#4} -} -{ - \IfExistsInstanceTF{xfrac}{#1} - {\UseInstance{xfrac}{#1}{#2}{#3}{#4}} - {\IfExistsInstanceTF{xfrac}{\f@family} - {\UseInstance{xfrac}{\f@family}} - {\UseInstance{xfrac}{default}} - {#2}{#3}{#4} + { + \IfInstanceExistTF { xfrac } { mathfam \number \fam } + { \UseInstance { xfrac } { mathfam \number \fam } } + { \UseInstance { xfrac } { mathdefault } } + {#2} {#3} {#4} + } + { + \IfInstanceExistTF { xfrac } {#1} + { \UseInstance { xfrac } {#1} } + { + \IfInstanceExistTF { xfrac } { \f@family } + { \UseInstance { xfrac } { \f@family } } + { \UseInstance { xfrac } { default } } + } + {#2} {#3} {#4} } - } } -% \end{macrocode} -% -% \Finale -\endinput +% \end{macrocode}
\ No newline at end of file |