diff options
Diffstat (limited to 'fonts/newtx/tex/newtx.sty')
-rw-r--r-- | fonts/newtx/tex/newtx.sty | 303 |
1 files changed, 218 insertions, 85 deletions
diff --git a/fonts/newtx/tex/newtx.sty b/fonts/newtx/tex/newtx.sty index 9279fac137..9cbc246920 100644 --- a/fonts/newtx/tex/newtx.sty +++ b/fonts/newtx/tex/newtx.sty @@ -1,9 +1,9 @@ \NeedsTeXFormat{LaTeX2e} -%: + %Package to simplify loading of newtxmath with a text font family such as newtxtext for all latex engines, or for newtxtext and an otf math package. -\def\fileversion{1.71} -\def\filedate{2022/02/11} +\def\fileversion{1.72} +\def\filedate{2023/07/20} \ProvidesPackage{newtx}[% \filedate\space v\fileversion (Michael Sharpe) latex and unicode latex support for newtxmath and a supported text font family, or for newtxtext and an otf math package] @@ -13,28 +13,98 @@ \RequirePackage{fontenc,fontaxes} \RequirePackage{ifthen,iftex,etoolbox,scalefnt} +% \textfrac macro for type1 libertine and libertinus +\newcommand{\lbtntextfrac}[3][]{% like \lbtntextfrac[1]{7}{8} + \mbox{% + \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] + {\textlf{#1}\kern.1em}{}% + {\sustyle#2}% numerator + \StrRight{#2}{1}[\@digit@]% + % look for 1, 2, 3, 7, 8 + \ifcase\@digit@% 0 + \or%\kern.03em% 1 + \or\kern.04em% 2 + \or%\kern-.01em% 3 + \or\kern.04em% 4 + \or%\kern.01em% 5 + \or%\kern.01em% 6 + \or\kern-.06em% 7 + \or\kern.04em% 8 + %\or\kern-.02em% 9 + \fi% +% \kern\ntx@foresolidus{\fontencoding{TS1}\selectfont\char"2F}% +% \kern\ntx@aftsolidus% + {\fontencoding{TS1}\selectfont\char"2F}% + \StrLeft{#3}{1}[\@digit@]% + % look for 1, 4, 7 + \ifcase\@digit@% 0 + \or%\kern -.02em% 1 + \or% 2 + \or% 3 + \or\kern -.06em% 4 + \or\kern -.02em% 5 + \or\kern-.03em% 6 + \or\kern .01em% 7 + \or%\kern .01em% 8 + \or\kern -.01em% 9 + \fi% + {\destyle #3}% denominator [#3] + }%mbox +} % lbtntextfrac + % options for newtxmath as etoolbox internal list allowing \ifinlist -\def\ntx@mathlstr{vecsep,amsthm,nosubscriptcorrection,subscriptcorrection,timesmathacc,varbb,vvarbb,nosymbolsc,noamssymbols,amssymbols,uprightscript,uprightGreek,slantedGreek,frenchmath,nonewtxmathopt,upint,smallerops,useBImacros,varg,varvw,noOT1} +%\def\ntx@mathlstr{vecsep,amsthm,nosubscriptcorrection,subscriptcorrection,timesmathacc,varbb,vvarbb,nosymbolsc,noamssymbols,amssymbols,uprightscript,uprightGreek,slantedGreek,frenchmath,nonewtxmathopt,upint,smallerops,useBImacros,varg,varvw,noOT1} +\forcsvlist{\listadd\ntx@mathlst}{vecsep,amsthm,nosubscriptcorrection,subscriptcorrection,timesmathacc,varbb,vvarbb,nosymbolsc,noamssymbols,amssymbols,uprightscript,uprightGreek,slantedGreek,frenchmath,nonewtxmathopt,upint,smallerops,useBImacros,varg,varvw,noOT1} +%\show\ntx@mathlst + % Note that subscriptcorrectionfile is not on the list---we process it in this sty file -\def\ntx@mathlst{} -\@for\ntx@opt:=\ntx@mathlstr\do{% -\listeadd{\ntx@mathlst}{\ntx@opt}}% +%\def\ntx@mathlst{} +%\ifinlist{amsthm}{\ntx@mathlst}{% +%\typeout{amsthm YES}}{ \typeout{amsthm NO}} + +%\endinput -%\ifinlist{amsthm}{\ntx@mathlst}{\typeout{YES}}{ \typeout{NO}} +%\DeclareListParser*{\forcsvlist}{,} +%\@for\ntx@opt:=\ntx@mathlstr\do{% +%\listxadd{\ntx@mathlst}{\ntx@opt}}% +%\show\ntx@opt +%\show\ntx@mathlst +\RequirePackage{xstring}% must load this after \@for +% Needed for \StrLeft and \StrRight %Enginecheck %iftex's \iftutex is true for LuaTeX and XeTeX \newif\ifntx@otftext \iftutex\ntx@otftexttrue\fi +\def\ntx@Mopt{} +\def\ntx@Topt{} %%%%%%%%%%%%%%%%%% -\RequirePackage{xkeyval}% - + \RequirePackage{xkeyval}% +%\traceon +\DeclareOptionX*{% what to do with unknown options +\xifinlist{\CurrentOption}{\ntx@mathlst} +% true branch +{\xdef\ntx@Mopt{\ntx@Mopt \CurrentOption,} +\expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{newtxmath}} +{% false branch +\xdef\ntx@Topt{\ntx@Topt \CurrentOption,}\expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{\ntx@TF}} +}% +%\traceoff %%%%StartOptions -\newif\ifntx@nofontspec % default is to load fontspec if unicode engine +%\newif\ifntx@nofontspec +% must load fontspec if unicode engine \newif\ifntx@otfmath %\ntx@otfmathfalse % default is type1 math \def\tx@divide#1#2{\strip@pt\dimexpr 1pt * (\dimexpr #1pt) / \dimexpr #2pt\relax\relax} +\newcommand*{\ntxtext@RM}{1} +\newcommand*{\ntxtext@SF}{1} +\newcommand*{\ntxtext@TT}{.88} +%\newcommand*{\ntxtext@llscale}{1} +%\newcommand*{\ntxtext@ttscale}{.85} +\newcommand*{\ntxtext@rm}{} % not understood by libertinus-otf +\newcommand*{\ntxtext@sf}{}% not understood by libertinus-otf + \newcommand*{\ntxtext@scale}{1} \newcommand*{\ntxmath@scale}{1} @@ -44,14 +114,23 @@ \DeclareOptionX{textscaled}[1]{\renewcommand*{\ntxtext@scale}{#1}} \DeclareOptionX{mathscale}[1]{\renewcommand*{\ntxmath@scale}{#1}} \DeclareOptionX{mathscaled}[1]{\renewcommand*{\ntxmath@scale}{#1}} +\DeclareOptionX{ScaleBaseRM}[]{\renewcommand*{\ntxtext@RM}{#1}} +\DeclareOptionX{ScaleBaseSF}[]{\renewcommand*{\ntxtext@SF}{#1}} +\DeclareOptionX{ScaleBaseTT}[]{\renewcommand*{\ntxtext@TT}{#1}} +\DeclareOptionX{llscale}[]{\renewcommand*{\ntxtext@llscale}{#1}} +\DeclareOptionX{ttscale}[]{\renewcommand*{\ntxtext@ttscale}{#1}} +\DeclareOptionX{rm}[true]{\renewcommand*{\ntxtext@rm}{#1}} +\DeclareOptionX{sf}[true]{\renewcommand*{\ntxtext@sf}{#1}} + +\DeclareOptionX{type1}[true]{}% no effect now +%{%\@nameuse{if#1}\ntx@otftextfalse\fi} -\DeclareOptionX{type1}[true]{% -\@nameuse{if#1}\ntx@otftextfalse\fi} -\DeclareOptionX{type1text}[true]{% same as type1--use type1 for text -\@nameuse{if#1}\ntx@otftextfalse\fi} +\DeclareOptionX{type1text}[true]{} %no effect now +%{% same as type1--use type1 for text +%\@nameuse{if#1}\ntx@otftextfalse\fi} -\DeclareOptionX{nofontspec}[true]{% use type1 for text and math -\@nameuse{if#1}\ntx@nofontspectrue\fi} +\DeclareOptionX{nofontspec}[true]{} % no effect +%{\@nameuse{if#1}\ntx@nofontspectrue\fi} \DeclareOptionX{otfmath}[true]{% \@nameuse{if#1}\iftutex\ntx@otfmathtrue\fi\fi} @@ -74,12 +153,14 @@ \ntx@text % set the default \DeclareOptionX{libertine}[true]{% \@nameuse{if#1}\def\ntx@sc{LinuxLibertineT@scale}% - \def\ntx@TF{libertinus}\def\ntx@MF{libertine} - \def\ntx@id{10}\def\ntx@minfam{minlibertine}\def\textlf##1{{\liningnums##1}}\def\nustyle{\sufigures}\def\destyle{}\def\infigures{}\def\textinf{}\fi} + \def\ntx@TF{libertine}\def\ntx@MF{libertine} + \def\ntx@id{1}\def\ntx@minfam{MinLibertinus}\def\textlf##1{{\liningnums##1}} +\def\infigures{}\def\textinf{} +\def\nustyle{\sufigures}\def\destyle{}\fi} \DeclareOptionX{libertinus}[true]{% - \@nameuse{if#1}\def\ntx@sc{LibertinusSerif@scale}% +\@nameuse{if#1}\def\ntx@sc{LibertinusSerif@scale}% \def\ntx@TF{libertinus}\def\ntx@MF{libertine} - \def\ntx@id{10}\def\ntx@minfam{minlibertine}% +\def\ntx@id{10}\def\ntx@minfam{MinLibertinus} } \DeclareOptionX{etbb}[true]{% \@nameuse{if#1}\def\ntx@TF{ETbb}\def\ntx@MF{libertine} @@ -177,27 +258,25 @@ \def\tx@sfrTH{#1}} \DeclareOptionX{sfracscaling}{% \def\tx@sfrSC{#1}} -\def\ntx@textopt{} -\DeclareOptionX*{% what to do with unknown options -\xifinlist{\CurrentOption}{\ntx@mathlst}% -{\PassOptionsToPackage{\CurrentOption}{newtxmath}}{% -\xdef\ntx@textopt{\ntx@textopt \CurrentOption,} -}} -% \ntx@textopt contains all unknown options that are not math options. It contains no scale options. +% \ntx@Topt contains all unknown options that are not math options. It contains no scale options. \ntx@Mopt lists all the math options. \ProcessOptionsX\relax +%\show\ntx@Mopt +%\show\ntx@Topt %\traceon % Check for conflict between nofontspec and others -\ifntx@nofontspec - \iftutex - \ntx@otfmathfalse - \ntx@otftextfalse - \fi -\fi +%\ifntx@nofontspec +% \iftutex +% \ntx@otfmathfalse +% \ntx@otftextfalse +% \fi +%\fi \ifntx@otfmath \ifnum\ntx@id>0 - \PackageWarning{newtx.sty}{Reverting to newtxtext: newtx is useless when specifying otfmath with any other text package.} + \PackageWarning{newtx.sty}{Reverting to newtxtext: newtx with option {\tt otfmath} can not handle other text packages.} + \ntx@id=0 \ntx@text % revert to newtxtext \fi\fi + %\ifntx@badnof\PackageError{newtx.sty}{Incompatible options, nofontspec and otfmath}{Incompatible options, nofontspec and otfmath}\fi % Set the text scale macros appropriately %\show\ntx@TF @@ -211,24 +290,44 @@ \@tempdima\@ne\p@\@tempdima\ntxtext@scale\@tempdima \expandafter\ifnum\number\@tempdima=0\relax\ntx@iszerotrue\fi % + \newcommand{\PassMathScale}{\ifntx@iszero\gdef\ntxtext@scale{\ntxmath@scale}\gdef\ntxtext@scaled{s*[\ntxtext@scale]}\fi \ifnum\ntx@id=4 % MinionPro \PassOptionsToPackage{scale=\ntxtext@scale}{\ntx@TF} \else \ifnum\ntx@id=10 %libertinus - \PassOptionsToPackage{ScaleRM=\ntxtext@scale}{\ntx@TF} + \@tempdima=\ntxtext@scale\p@ + \@tempdimb=\ntxtext@RM\@tempdima + \PassOptionsToPackage{ScaleRM=\strip@pt\@tempdimb}{\ntx@TF} + \@tempdimb=\ntxtext@SF\@tempdima + \PassOptionsToPackage{ScaleSF=\strip@pt\@tempdimb}{\ntx@TF} + \@tempdimb=\ntxtext@TT\@tempdima + \PassOptionsToPackage{ScaleTT=\strip@pt\@tempdimb}{\ntx@TF} \else - \PassOptionsToPackage{scaled=\ntxtext@scale}{\ntx@TF} + \ifnum\ntx@id=1 %libertine + \@tempdima=\ntxtext@scale\p@ + \@tempdimb=\ntxtext@RM\@tempdima + \PassOptionsToPackage{llscale=\strip@pt\@tempdimb}{\ntx@TF} + \@tempdimb=\ntxtext@SF\@tempdima + \PassOptionsToPackage{scale=\strip@pt\@tempdimb}{\ntx@TF} + \@tempdimb=\ntxtext@TT\@tempdima + \PassOptionsToPackage{ttscale=\strip@pt\@tempdimb}{\ntx@TF} + + \else % + \PassOptionsToPackage{scaled=\ntxtext@scale}{\ntx@TF} + \fi \fi \fi } % -\newcommand{\PassMatchingScale}[1]{\ifntx@iszero% -\@tempdima #1\p@ \@tempdima\ntxmath@scale\@tempdima \xdef\ntxtext@scale{\strip@pt\@tempdima} -\gdef\ntxtext@scaled{s*[\ntxtext@scale]} -\fi -\PassOptionsToPackage{scaled=\ntxtext@scale}{\ntx@TF}% +\newcommand{\PassMatchingScale}[1]{% + \ifntx@iszero% + \@tempdima #1\p@ \@tempdima\ntxmath@scale\@tempdima \xdef\ntxtext@scale{\strip@pt\@tempdima} + \gdef\ntxtext@scaled{s*[\ntxtext@scale]} + \fi + \PassOptionsToPackage{scaled=\ntxtext@scale}{\ntx@TF}% } +%\fi \ifcase\ntx@id % 0, newtxtext \PassMathScale @@ -243,8 +342,8 @@ \@ifundefined{tx@sfrSC}{\def\tx@sfrSC{.8}}{} % scale defigures by this \or %1, libertine \PassMathScale - \PassOptionsToPackage{ttscaled=\ntxtext@scale, - llscaled=\ntxtext@scale}{\ntx@TF} % for tt and serifed in Libertine +% \PassOptionsToPackage{ttscaled=\ntxtext@scale, +% llscaled=\ntxtext@scale}{\ntx@TF} % for tt and serifed in Libertine \@ifundefined{tx@xht}{\def\tx@xht{431}}{} % lowercase letters \@ifundefined{tx@deht}{\def\tx@deht{328}}{} % denominator figures ht \@ifundefined{tx@nubase}{\def\tx@nubase{365}}{} % baseline of numerators @@ -253,7 +352,7 @@ \@ifundefined{tx@sfrVS}{\def\tx@sfrVS{100}}{} % space above/below bar \@ifundefined{tx@sfrTH}{\def\tx@sfrTH{46}}{} % bar thickness \@ifundefined{tx@sfrSC}{\def\tx@sfrSC{.9}}{} % scale defigures by this -\def\destyle{\sufigures} \def\nustyle{\sufigures} +%\def\destyle{\sufigures} \def\nustyle{\sufigures} %\iflibertine@otf% %\providecommand{\textfrac}[3][]{{% %\mbox{% @@ -321,8 +420,6 @@ \PassMatchingScale{.94} \or % 10, libertinus \PassMathScale - \PassOptionsToPackage{ScaleTT=\ntxtext@scale, ScaleSF=\ntxtext@scale, - ScaleRM=\ntxtext@scale}{\ntx@TF} % for tt and serifed in Libertinus \@ifundefined{tx@xht}{\def\tx@xht{431}}{} % lowercase letters \@ifundefined{tx@deht}{\def\tx@deht{324}}{} % denominator figures ht \@ifundefined{tx@nubase}{\def\tx@nubase{364}}{} % baseline of numerators @@ -392,11 +489,11 @@ \@ifundefined{tx@sfrTH}{\def\tx@sfrTH{70}}{} % bar thickness \@ifundefined{tx@sfrSC}{\def\tx@sfrSC{.8}}{} % scale defigures by this \fi - \PassOptionsToPackage{\ntx@MF}{newtxmath} -\ifblank{\ntx@textopt}{}% -{\PassOptionsToPackage{\ntx@textopt}{\ntx@TF}} + +%\ifblank{\ntx@textopt}{}% +%{\PassOptionsToPackage{\ntx@textopt}{\ntx@TF}} \newdimen\tx@sixem\tx@sixem6pt % for checking if a number refers to ex \newdimen\tx@y \newdimen\tx@x @@ -445,43 +542,37 @@ \egroup}} } -\ifntx@otfmath\typeout{otf math}\else\typeout{type1 math}\fi -\ifntx@otftext\typeout{otf text}\else\typeout{type1 text}\fi + +%\ifntx@otfmath\typeout{otf math}\else\typeout{type1 math}\fi + \ifntx@otftext \ifntx@otfmath %I - %\show\xyzI + \typeout{I} \usepackage[]{newtxtext} %may not load fontspec \RequirePackage{fontspec} % just in case \usepackage{unicode-math} %loads amsmath - %\setmathfont{} \else %II: type1 math, otftext - %\show\xyzII - \renewcommand*{\rmdefault}{\ntx@minfam} % Roman and Bold Termes for math + \typeout{II} + \renewcommand*{\rmdefault}{\ntx@minfam} % Roman and Bold text for math \usepackage[]{newtxmath} % options will be as passed from newtx - %\show\xyz \usepackage[no-math]{fontspec} - %\show\textlf \ifnum\ntx@id=10\relax % libertinus - \usepackage[nomath]{\ntx@TF}% was \usepackage[no-math]{\ntx@TF} + \usepackage[nomath]{\ntx@TF} \else \usepackage{\ntx@TF} - \fi - \fi -\else % III, pdflatex - %\show\ntx@minfam - \ifntx@otfmath % type1 text, otf math - \usepackage[type1text]{newtxtext} %may not load fontspec - \RequirePackage{fontspec} % just in case - \usepackage{unicode-math} %loads amsmath - %\setmathfont{} - - \else % IV, type1 tex and math + \fi %\ifnum + \fi %ifntx@otfmath + %\show\ntx@otftexttrue +\else % not otftext + \typeout{IV} +% IV, type1 tex and math \renewcommand*{\rmdefault}{\ntx@minfam}% Roman and Bold for math - \usepackage{newtxmath} % options will be as passed from newtx + \usepackage{newtxmath} % options will be as passed from newtx \usepackage{\ntx@TF} % should load tt and sans math before newtx - \fi \fi + +%\traceoff %%%%%%% End of preamble items \AtEndPreamble{% \providecommand{\textfrac}[3][]{{% @@ -493,11 +584,27 @@ \textde{#3}\fi} }}} + % Finally, add code to extend text packages after they load. % This will depend on the particular package and the state % of \ntx@otftext \ifcase\ntx@id % 0, newtxtext \or % 1, was libertine % switch to libertinus + \let\sustyle\sufigures + \let\nustyle\sufigures + \let\textnu\textsup + \let\textsu\textsup + + \def\minlibfamily{MinLibertinusSerif-Inf} + \def\infigures{\@nomath\infigures\fontfamily{\minlibfamily}\selectfont} + + \let\instyle\infigures + \let\destyle\infigures + \let\defigures\infigures + \DeclareTextFontCommand{\textinf}{\infigures} + \let\textde\textinf + + \let\textfrac\lbtntextfrac \or % 2, etbb \or % 3, ebgaramond \def\destyle{\infigures} \def\nustyle{\sufigures} @@ -516,19 +623,45 @@ \or % 8, baskervaldx \or % 9, heuristica \or % 10, libertinus - \def\nustyle{\textsup}\let\textnu\textsup - \ifntx@otftext% - \def\textlf#1{{\addfontfeature{RawFeature=+lnum,RawFeature=+pnum}#1}} - \def\destyle{\addfontfeature{RawFeature=+subs}} - \else % type1 - \fa@naming@exception{figures}{{inferior}{proportional}}{Inf} - \fa@naming@exception{figures}{{inferior}{tabular}}{Inf} - \def\infigures{\@nomath\infigures\fontfigurestyle{inferior}\selectfont} - \DeclareTextFontCommand{\textinf}{\infigures} - \let\destyle\infigures - \def\textlf#1{{\LibertinusSerifLF#1}} - \fi - \def\textde#1{{\destyle#1}} +\ifntx@otftext% + \def\textlf#1{{\addfontfeature{RawFeature=+lnum,RawFeature=+pnum}#1}} + \let\sustyle\sufigures + \let\nustyle\sufigures + \DeclareTextFontCommand{\textsup}{\sufigures}\def\destyle{\addfontfeature{RawFeature=+subs}} + \def\infstyle\destyle + \let\infigures\infstyle + \DeclareTextFontCommand{\textinf}{\infigures} + \newcommand{\textfrac}[3][]{% + \mbox{% + \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] + {\textlf{#1}\kern.1em}{}\Lfrac{#2/#3}}} + +\else % type1 + \let\sustyle\sufigures + \let\nustyle\sufigures + \let\textnu\textsup + \let\textsu\textsup + + \def\minlibfamily{MinLibertinusSerif-Inf} + \def\infigures{\@nomath\infigures\fontfamily{\minlibfamily}\selectfont} + + \let\instyle\infigures + \let\destyle\infigures + \let\defigures\infigures + \DeclareTextFontCommand{\textinf}{\infigures} + \let\textde\textinf + \def\textlf#1{{\LibertinusSerifLF#1}} + + \let\textfrac\lbtntextfrac +\fi +% \fa@naming@exception{figures}{{inferior}{proportional}}{Inf} +% \fa@naming@exception{figures}{{inferior}{tabular}}{Inf} +% \def\infigures{\@nomath\infigures\fontfigurestyle{inferior}\selectfont} +% \DeclareTextFontCommand{\textinf}{\infigures} +% \let\destyle\infigures +% \let\textde\textinf + % \sufigures and \textsup from libertinus-type1.sty + \or % 11, erewhon \or % 12, XCharter \or % 13, stickstoo |