diff options
author | Karl Berry <karl@freefriends.org> | 2019-04-01 21:09:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-04-01 21:09:08 +0000 |
commit | 98766f71d95e3aa7dcf598359ffb0f9902c73797 (patch) | |
tree | 7745f7d6ca9b4ff7de90c62aa1d5147ab262366d /Master/texmf-dist | |
parent | c8f2a113dcdfc0ceb813d1226e800df49a2baf5d (diff) |
mathfont (1apr19)
git-svn-id: svn://tug.org/texlive/trunk@50698 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/mathfont/README.txt | 14 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/mathfont/mathfont.pdf | bin | 291212 -> 297850 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/mathfont/mathfont_example.pdf | bin | 86277 -> 86282 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/mathfont/mathfont_example.tex | 11 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/mathfont/mathfont_greek.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/mathfont/mathfont.dtx | 368 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/mathfont/mathfont.sty | 131 |
7 files changed, 291 insertions, 237 deletions
diff --git a/Master/texmf-dist/doc/latex/mathfont/README.txt b/Master/texmf-dist/doc/latex/mathfont/README.txt index d1d100782f0..5805abdad7e 100644 --- a/Master/texmf-dist/doc/latex/mathfont/README.txt +++ b/Master/texmf-dist/doc/latex/mathfont/README.txt @@ -12,7 +12,7 @@ mathfont. 4. mathfont_example.pdf: an example of mathfont in action. -The mathfont package is Copyright 2018 by Conrad Kosowsky. +The mathfont package is Copyright 2018-2019 by Conrad Kosowsky. This work may be distributed and modified under the terms of the LaTeX Public Project License, version 1.3c or any later version. @@ -22,14 +22,16 @@ The most recent version of this license is available online at This work has the LPPL status "maintained," and the current maintainer is the package author, Conrad Kosowsky. He can be reached at -kosowsky.latex@gmail.com. The work consists of the file mathfont.dtx, +kosowsky.latex@gmail.com. The work consists of the file mathfont.dtx; the derived files mathfont.sty, mathfont_greek.tex, and -mathfont_example.tex, and all other files created through the configuration +mathfont_example.tex; and all other files created through the configuration process such as mathfont.pdf, mathfont.idx, and mathfont.ind. To install mathfont, run mathfont.dtx through LaTeX and move the generated file mathfont.sty into a directory searchable by TeX. Running mathfont.dtx through LaTeX will produce the derived files -mathfont.sty and mathfont_greek.tex. The first of these documents -is the actual package code, and the second is the source code for -mathfont_greek.pdf. +mathfont.sty, mathfont_greek.tex, and mathfont_example.tex. The first +of these documents is the actual package code, and the second and third +are the source code for mathfont_greek.pdf and mathfont_example.pdf, +respectively. + diff --git a/Master/texmf-dist/doc/latex/mathfont/mathfont.pdf b/Master/texmf-dist/doc/latex/mathfont/mathfont.pdf Binary files differindex 27194280adf..b9945378efe 100644 --- a/Master/texmf-dist/doc/latex/mathfont/mathfont.pdf +++ b/Master/texmf-dist/doc/latex/mathfont/mathfont.pdf diff --git a/Master/texmf-dist/doc/latex/mathfont/mathfont_example.pdf b/Master/texmf-dist/doc/latex/mathfont/mathfont_example.pdf Binary files differindex 17c70c713f2..a441a812a4f 100644 --- a/Master/texmf-dist/doc/latex/mathfont/mathfont_example.pdf +++ b/Master/texmf-dist/doc/latex/mathfont/mathfont_example.pdf diff --git a/Master/texmf-dist/doc/latex/mathfont/mathfont_example.tex b/Master/texmf-dist/doc/latex/mathfont/mathfont_example.tex index efb26fe250c..d69aace431e 100644 --- a/Master/texmf-dist/doc/latex/mathfont/mathfont_example.tex +++ b/Master/texmf-dist/doc/latex/mathfont/mathfont_example.tex @@ -6,7 +6,7 @@ %% %% mathfont.dtx (with options: `example') %% -%% Copyright 2018 by Conrad Kosowsky +%% Copyright 2018-2019 by Conrad Kosowsky %% %% This file may be distributed and modified under the terms %% of the LaTeX Public Project License, version 1.3c or any later version. @@ -25,13 +25,10 @@ \documentclass[12pt]{article} \usepackage[margin=72.27pt]{geometry} \usepackage[factor=600,stretch=14,shrink=14,step=1]{microtype} -\usepackage{selnolig} -\usepackage[no-operators]{mathfont} -\mathfont{Times New Roman} +\usepackage{mathfont} +\setfont{Times New Roman} \mathfont[bb]{Symbola} \restoremathinternals -\setmainfont{Times New Roman} -\nolig{Th}{T|h} \hyphenpenalty=10 \exhyphenpenalty=5 \pretolerance=30 @@ -68,7 +65,7 @@ A smooth manifold consists of a topological space $M$ equipped with a smooth max \[ \psi_j^{}\circ f\circ\phi_i^{-1} \] -is itself smooth, where $\leftbrace\psi_i\rightbrace$ is a smooth atlas for $N$. Differentiating $f$ produces the associated tangent map $Df$. The function $Df$ maps the tangent space $TM$ to the tangent space $TN$ and is linear when restricted to individual tangent spaces $T_pM$. If $M$ can be written as a product $M_1\times M_2$, we can consider the partial tangent maps $\partial_1f$ and $\partial_2f$ by considering the compositions $f\circ\iota_1$ and $f\circ\iota_2$, where $\iota_1$ and $\iota_2$ are inclusion maps with respect to a particular point. Combining both maps, we have the equation +is itself smooth, where $\leftbrace\psi_i\rightbrace$ is a smooth atlas for $N$. Differentiating $f$ produces the associated tangent map $Df$. The function $Df$ maps the tangent bundle $TM$ to the tangent bundle $TN$ and is linear when restricted to individual tangent spaces $T_pM$. If $M$ can be written as a product $M_1\times M_2$, we can consider the partial tangent maps $\partial_1f$ and $\partial_2f$ by considering the compositions $f\circ\iota_1$ and $f\circ\iota_2$, where $\iota_1$ and $\iota_2$ are inclusion maps with respect to a particular point. Combining both maps, we have the equation \[ Df(u,v)=\partial_1f(u)+\partial_2f(v), \] diff --git a/Master/texmf-dist/doc/latex/mathfont/mathfont_greek.tex b/Master/texmf-dist/doc/latex/mathfont/mathfont_greek.tex index 0120697eaf1..7f5d9ec66ff 100644 --- a/Master/texmf-dist/doc/latex/mathfont/mathfont_greek.tex +++ b/Master/texmf-dist/doc/latex/mathfont/mathfont_greek.tex @@ -6,7 +6,7 @@ %% %% mathfont.dtx (with options: `greek') %% -%% Copyright 2018 by Conrad Kosowsky +%% Copyright 2018-2019 by Conrad Kosowsky %% %% This file may be distributed and modified under the terms %% of the LaTeX Public Project License, version 1.3c or any later version. @@ -42,7 +42,7 @@ Greek Characters Provided by \textsf{mathfont}, Rendered in Symbola\par\penalty1 \begin{tabular}{llllllll} \toprule \multicolumn{4}{c}{Modern Greek Characters} & \multicolumn{4}{c}{Ancient Greek Characters}\\ -\cmidrule(r{3pt}){1-4}\cmidrule(l{3pt}){5-8} +\cmidrule(r{4pt}){1-4}\cmidrule(l{4pt}){5-8} \multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule} & \multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule}\\ \midrule |\Alpha| & $\Alpha$ & |\alpha| & $\alpha$ & |\Heta| & $\Heta$ & |\heta| & $\heta$ \\ diff --git a/Master/texmf-dist/source/latex/mathfont/mathfont.dtx b/Master/texmf-dist/source/latex/mathfont/mathfont.dtx index 61c9a6ef4dd..a0ed6fab636 100644 --- a/Master/texmf-dist/source/latex/mathfont/mathfont.dtx +++ b/Master/texmf-dist/source/latex/mathfont/mathfont.dtx @@ -5,7 +5,7 @@ % with the XeTeX or LuaTeX engine. Users should run this file through % LaTeX to generate the files and documentation. % -% Copyright 2018 by Conrad Kosowsky +% Copyright 2018-2019 by Conrad Kosowsky % % This work may be distributed and modified under the terms % of the LaTeX Public Project License, version 1.3c or any later version. @@ -35,9 +35,10 @@ \begingroup \input docstrip.tex \keepsilent +\askforoverwritefalse \preamble -Copyright 2018 by Conrad Kosowsky +Copyright 2018-2019 by Conrad Kosowsky This file may be distributed and modified under the terms of the LaTeX Public Project License, version 1.3c or any later version. @@ -100,7 +101,8 @@ information, see the original mathfont.dtx file. % % \fi % -% \CheckSum{2599} +% \CheckSum{2651} +% \init@checksum % % \makeatother\CharacterTable % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z @@ -130,7 +132,8 @@ information, see the original mathfont.dtx file. % \DoNotIndex{\M@symbols,\mathop,\mathbin,\mathrel,\mathopen,\mathclose,\mathpunct} % \DoNotIndex{\M@lower,\M@upper,\M@greeklower,\M@greekupper,\M@digits} % \DoNotIndex{\M@bb,\M@cal,\M@frak,\M@bcal,\M@bfrak,\mathinner} -% \DoNotIndex{\DeclareRobustCommand,\joinrel,\smash} +% \DoNotIndex{\DeclareRobustCommand,\joinrel,\smash,\newtoks,\if,\\,\@nil,\leavevmode} +% \DoNotIndex{\begingroup,\endgroup,\+,\active,\@gobbletwo,\GenericError} % \DoNotIndex{\M@bb@A,\M@bb@B,\M@bb@C,\M@bb@D,\M@bb@E,\M@bb@F} % \DoNotIndex{\M@bb@G,\M@bb@H,\M@bb@I,\M@bb@J,\M@bb@K,\M@bb@L} % \DoNotIndex{\M@bb@M,\M@bb@N,\M@bb@O,\M@bb@P,\M@bb@Q,\M@bb@R} @@ -180,7 +183,6 @@ information, see the original mathfont.dtx file. % \DoNotIndex{\M@bfrak@y,\M@bfrak@z} % % -% % \newenvironment{code} % {\strut\vadjust\bgroup\medskip\parindent=4em\relax\indent\strut\ignorespaces} % {\strut\par\medskip\egroup\hfill\break\strut\ignorespacesafterend} @@ -192,25 +194,26 @@ information, see the original mathfont.dtx file. % \def\XeLaTeX{X\kern-0.1em % \raise-0.5ex\hbox{\rotatebox[origin=c]{180}{E}}\kern-0.13em % \LaTeX} -% \renewcommand\topfraction{0.9} +% \renewcommand\topfraction{1} +% \renewcommand\bottomfraction{1} % % {\large -% \centerline{\Large Package \textsf{mathfont} v.\ 1.3 Documentation}\par +% \centerline{\Large Package \textsf{mathfont} v.\ 1.4 Documentation}\par % \centerline{Conrad Kosowsky}\par -% \centerline{January 2019}\par +% \centerline{April 2019}\par % \centerline{\ttfamily kosowsky.latex@gmail.com}\par} % % \bigskip % % \begin{abstract} -% The \textsf{mathfont} package provides a flexible interface for changing the font of math mode characters. The package allows the user to specify a default unicode font for each of six basic classes of Latin and Greek characters, and it provides additional support for unicode math and alphanumeric symbols. Crucially, \textsf{mathfont} is compatible with both Lua\LaTeX\ and \XeLaTeX, and it provides several font-loading commands that allow the user to change fonts locally or for individual characters within math mode. +% The \textsf{mathfont} package provides a flexible interface for changing the font of math-mode characters. The package allows the user to specify a default unicode font for each of six basic classes of Latin and Greek characters, and it provides additional support for unicode math and alphanumeric symbols, including punctuation. Crucially, \textsf{mathfont} is compatible with both Lua\LaTeX\ and \XeLaTeX, and it provides several font-loading commands that allow the user to change fonts locally or for individual characters within math mode. % \end{abstract} % -% Handling fonts in \TeX\ and \LaTeX\ is a notoriously difficult task. The \TeX\ engine originally supported only fonts designed with Donald Knuth's Metafont, and while subsequent versions of \TeX\ extended this functionality to postscript fonts, Plain \TeX's font-loading capabilities remain limited. Many, if not most, \LaTeX\ users are unfamiliar with the |.fd| files that must be used in font declaration, and the minutiae of \TeX's |\font| primitive can be esoteric and confusing. \LaTeXe's New Font Selection System (\textsc{nfss}) implemented a straightforward syntax for loading and managing fonts, but \LaTeX\ macros overlaying a \TeX\ core face the same versatility issues as Plain \TeX\ itself. Fonts in math mode present a double challenge: even if the user successfully loads a font either in Plain \TeX\ or through the \textsc{nfss}, defining math symbols can be unintuitive for users who are unfamiliar with \TeX's |\mathcode| primitive. Again, \LaTeXe\ simplifies much of the coding challenges with its |\DeclareMathSymbol| macro, but from the computer's perspective, the fundamental aspects of the task remain the same. +% Handling fonts in \TeX\ and \LaTeX\ is a notoriously difficult task. Donald Knuth originally designed \TeX\ to support fonts created with Metafont, and while subsequent versions of \TeX\ extended this functionality to postscript fonts, Plain \TeX's font-loading capabilities remain limited. Many, if not most, \LaTeX\ users are unfamiliar with the |.fd| files that must be used in font declaration, and the minutiae of \TeX's |\font| primitive can be esoteric and confusing. \LaTeXe's New Font Selection System (\textsc{nfss}) implemented a straightforward syntax for loading and managing fonts, but \LaTeX\ macros overlaying a \TeX\ core face the same versatility issues as Plain \TeX\ itself. Fonts in math mode present a double challenge: even if the user successfully loads a font either in Plain \TeX\ or through the \textsc{nfss}, defining math symbols can be unintuitive for users who are unfamiliar with \TeX's |\mathcode| primitive. Again, \LaTeXe\ simplifies much of the coding challenges with its |\DeclareMathSymbol| macro, but from the computer's perspective, the fundamental aspects of the task remain the same. % % More recent engines such as Jonathan Kew's \XeTeX\ and Hans Hagen, et al.'s Lua\TeX\ significantly extend the font-loading capabilities of \TeX.\footnote{Information on \XeTeX\ is available at \texttt{https://tug.org/xetex/}, and information on Lua\TeX\ is available at the official website for Lua\TeX: \texttt{http://www.luatex.org/}.} Both support TrueType and OpenType font formats and provide many additional primitives for managing fonts. The \textsf{fontspec} package by Will Robertson and Khaled Hosny acts as a front-end for the font management built into these two engines.\footnote{Will Robertson and Khaled Hosny, ``\textsf{fontspec}---Advanced font selection in \XeLaTeX\ and Lua\LaTeX,'' \texttt{https://ctan.org/pkg/fontspec}.} It allows users to easily load new fonts and transition between those ones already in memory, and users who are interested in changing text fonts should consult the documentation for that package. Notably, \textsf{fontspec} provides users with the tools to manually adjust OpenType features of the fonts they load, so the package gives equivalent or in some cases superior font management capabilities to a modern WYSIWYG word processor. (Of course, the efficiency depends on the skill of the \LaTeX\ user.) In situations where a font's OpenType features are unclear or difficult to access, \textsf{fontspec}'s typographical advantages can significantly outweigh the accessibility of a word processor. % -% This document is organized as follows. Section~1 presents the basic functionality and related packages. The following two sections explain how to use the default and local font-change commands, and users in a hurry will find the most important information here. Sections~4 and 5 discuss the Greek characters and mathematical symbols that \textsf{mathfont} provides, and section~6 describes the more complicated error messages that \textsf{mathfont} may throw. The remaining five sections detail the implementation. Section~7 lays out the initial implementation for the package, and sections~8 and 9 deal again with default and local font changes, respectively. The following section covers the code for the unicode alphanumeric letterlike symbols, and the final section~11 contains the unicode hex values for every character supported by \textsf{mathfont}. For an example of the package in action, see |mathfont_example.pdf|, which is included with the \textsf{mathfont} installation and available on \textsc{ctan}. +% The \textsf{mathfont} package applies \textsf{fontspec}'s advances in font selection to math-mode typesetting, and this documentation explains \textsf{mathfont} as follows. Section~1 presents the basic functionality and related packages. Sections~2 and 3 explain how to use the default and local font-change commands, and users in a hurry will find the most important information here. Sections~4 and 5 discuss the Greek characters and mathematical symbols that \textsf{mathfont} provides, and section~6 describes the more complicated error messages that \textsf{mathfont} may throw. The remaining five sections detail the implementation. Section~7 lays out the initial implementation for the package, and sections~8 and 9 lay out the \LaTeX\ code for default and local font changes, respectively. Section~10 covers the code for the unicode alphanumeric letterlike symbols, and the final section~11 contains the unicode hex values for every character supported by \textsf{mathfont}. For an example of the package in action, see |mathfont_example.pdf|, which is included with the \textsf{mathfont} installation and is available on \textsc{ctan}. % % \section{Basic Functionality} % @@ -228,25 +231,28 @@ information, see the original mathfont.dtx file. % |\def"#1{\ifmmode| % | \kern|\argtext{dimension}|\relax #1\kern|\argtext{other dimension}|\relax| % | \else| -% | \char`\"%| +% | \char`\"#1%| % | \fi}|\endgroup % \end{code} -% will serve as a hack that very roughly approximates \textsf{mathspec}'s |"|. This code will redefine |"| to typeset a right double quotation mark in horizontal mode, but in math mode, the character will insert \textit{dimension} and \textit{other dimension} of white space on either side respectively of the following character. More advanced users can automate the dimensions by using \TeX's |\if| conditional to test whether the following character needs a particular spacing adjustment. (For example, Computer Modern's math-mode $f$ is notorious for being significantly wider than its italic counterpart.) Future versions of \textsf{mathfont} may provide an automated space-adjustment command, but it is not one of my priorities. +% will serve as a hack that very roughly approximates \textsf{mathspec}'s |"|. This code will redefine |"| to typeset a right double quotation mark in horizontal mode, but in math mode, the character will insert \textit{dimension} and \textit{other dimension} of white space on either side respectively of the following character. More advanced users can automate the dimensions by using \TeX's |\if| conditional to test whether the following character needs a particular spacing adjustment. (For example, Computer Modern's math mode $f$ is notorious for being significantly wider than its italic counterpart.) Future versions of \textsf{mathfont} may provide an automated space-adjustment command, but it is not one of my priorities. % -% The functionality of \textsf{mathfont} is most closely related to that of the \textsf{mathspec} package by Andrew Gilbert Moschou.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,''\hfil\break\texttt{https://ctan.org/pkg/mathspec}.} These two packages incorporate the use of individual unicode characters into math mode, and their symbol declaration process is similar. Both use \textsf{fontspec} as a back end, and both create font-changing commands for math mode characters. However, the functionality differs in three crucial respects: \textsf{mathfont} is compatible with Lua\LaTeX; it can adjust the font of basic mathematical symbols; and its local math-font-changing mechanisms provide a slightly greater level of flexibility than what users can achieve with \textsf{mathspec}. Further, as far as I am aware, this package is the first to provide support for the unicode alphanumeric symbols listed in Table~2, even in the context of fonts without built-in math support. (Please let me know if this is incorrect!) In this way \textsf{mathfont}, like \textsf{mathspec}, is more versatile than the \textsf{unicode-math} package, although potentially less far-reaching.\footnote{Will Robertson, ``\textsf{unicode-math}---Unicode mathematics support for \XeTeX\ and Lua\TeX,''\hfil\break\texttt{https://ctan.org/pkg/unicode-math}.} +% The functionality of \textsf{mathfont} is most closely related to that of the \textsf{mathspec} package by Andrew Gilbert Moschou.\footnote{Andrew Gilbert Moschou, ``\textsf{mathspec}---Specify arbitrary fonts for mathematics in \XeTeX,''\hfil\break\texttt{https://ctan.org/pkg/mathspec}.} These two packages incorporate the use of individual unicode characters into math mode, and their symbol declaration process is similar. Both use \textsf{fontspec} as a back end, and both create font-changing commands for math-mode characters. However, the functionality differs in three crucial respects: \textsf{mathfont} is compatible with Lua\LaTeX; it can adjust the font of basic mathematical symbols such as those in tables~5 and 6; and its local math-font-changing mechanisms provide a slightly greater level of flexibility than what users can achieve with \textsf{mathspec}. Further, as far as I am aware, this package is the first to provide support for the unicode alphanumeric symbols listed in Table~2, even in the context of fonts without built-in math support. (Please let me know if this is incorrect!) In this way \textsf{mathfont}, like \textsf{mathspec}, is more versatile than the \textsf{unicode-math} package, although potentially less far-reaching.\footnote{Will Robertson, ``\textsf{unicode-math}---Unicode mathematics support for \XeTeX\ and Lua\TeX,''\hfil\break\texttt{https://ctan.org/pkg/unicode-math}.} % -% Users who want to stick with pdf\LaTeX\ should consider Jean-Fran\c cois Burnol's \textsf{mathastext} as a useful alternative to \textsf{mathfont}.\footnote{Jean-Fran\c cois Burnol, ``\textsf{mathastext}---Use the text font in maths mode,''\hfil\break\texttt{https://ctan.org/pkg/mathastext}. In several previous versions of this documentation, I mistakenly stated that \textsf{mathastext} distorts \TeX's internal mathematics spacing. In fact the opposite is true: \textsf{mathastext} goes to significant lengths to preserve and even extend rules for space between various math-mode characters.} This package allows the user to specify the math-mode font for a large subset of the ASCII characters and is the most closely related package to \textsf{mathfont} among those packages designed specifically for the \LaTeX\ kernel in conjunction with Plain \TeX. Whereas \textsf{mathfont} works exclusively in the context of unicode fonts, \textsf{mathastext} was designed for the T1 and related encodings of Plain \TeX\ and \LaTeX, and \textsf{mathfont} provides support for a larger class of symbols. However, the \textsf{mathastext} functionality extends beyond that of \textsf{mathfont} in two notable aspects: (1) \textsf{mathastext} makes use of math versions, extra spacing, and italic corrections; and (2) \textsf{mathastext} allows users to change the font for the twenty-five non-alphanumeric characters supported by that package multiple times. After setting the default font, \textsf{mathfont} allows users to change it for only Latin, Greek, and digit characters. +% Users who want to stick with pdf\LaTeX\ should consider Jean-Fran\c cois Burnol's \textsf{mathastext} as a useful alternative to \textsf{mathfont}.\footnote{Jean-Fran\c cois Burnol, ``\textsf{mathastext}---Use the text font in maths mode,''\hfil\break\texttt{https://ctan.org/pkg/mathastext}. In several previous versions of this documentation, I mistakenly stated that \textsf{mathastext} distorts \TeX's internal mathematics spacing. In fact the opposite is true: \textsf{mathastext} goes to significant lengths to preserve and even extend rules for space between various math-mode characters.} This package allows the user to specify the math-mode font for a large subset of the ASCII characters and is the most closely related package to \textsf{mathfont} among those packages designed specifically for the \LaTeX\ kernel in conjunction with Plain \TeX. Whereas \textsf{mathfont} works exclusively in the context of unicode fonts, \textsf{mathastext} was designed for the T1 and related encodings of Plain \TeX\ and \LaTeX, and \textsf{mathfont} provides support for a larger class of symbols. However, the \textsf{mathastext} functionality extends beyond that of \textsf{mathfont} in two notable aspects: (1) \textsf{mathastext} makes use of math versions, extra spacing, and italic corrections; and (2) \textsf{mathastext} allows users to change the font for the twenty-five non-alphanumeric characters supported by that package multiple times. After setting the default font for a class of characters, \textsf{mathfont} allows for that class only the local font changes outlined in section~3. % % \section{Setting the Default Font} % -% The |\mathfont| command sets the default font for certain classes of characters, and it can be called any number of times in the document preamble. Its structure is +% The |\mathfont| command sets the default font for certain classes of characters. Its structure is given by % \begin{code} % |\mathfont[|\argtext{optional character classes}|]{|\argtext{font name}|}|, % \end{code} -% where the \textit{optional character classes} can be any set of keywords from Tables~1 and 2, and the \textit{font name} can be any OpenType or TrueType font in a directory searchable by \TeX. If the user does not specify any optional argument for |\mathfont|, the macro will take all keywords from Table~1 and the |symbols| keyword from Table~2 as the optional argument. When specifying the \textit{font name}, users need to input a name that \textsf{fontspec} will recognize and be able to load. Advanced users will note that |\mathfont| uses |\fontspec_set_family:Nnn| and therefore loads fonts in the same way as |\fontspec| and related macros from that package. Currently, \textsf{mathfont} does not support OpenType features in math mode. -% +% where the \textit{optional character classes} can be any set of keywords from Tables~1 and 2 separated by commas, and the \textit{font name} can be any OpenType or TrueType font in a directory searchable by \TeX. When specifying the \textit{font name}, users need to input a name that \textsf{fontspec} will recognize and be able to load. Advanced users will note that |\mathfont| uses |\fontspec_set_family:Nnn| and therefore loads fonts in the same way as |\fontspec| and related macros from that package. Currently, \textsf{mathfont} does not support OpenType features in math mode. To change both math and text fonts simultaneously, the package provides the command +% \begin{code} +% |\setfont{|\argtext{font name}|}|, +% \end{code} +% which calls both |\mathfont| and \textsf{fontspec}'s |\setmainfont| using the \textit{font name} as arguments. Most users will probably find this command sufficient for most applications. Both |\mathfont| and |\setfont| should appear only in the document preamble. % -% \begin{figure}[ht] +% \begin{figure}[htb] % \centering % Table~1: Math Alphabet Characters\par\penalty\@M\smallskip % \begin{tabular}{lll} @@ -263,24 +269,30 @@ information, see the original mathfont.dtx file. % \end{tabular} % \end{figure} % -% The user should specify any keyword optional arguments for |\mathfont| as entries in a comma-separated list. The order is irrelevant, and for each item in the list, the package will change the math font for that class of characters to the font specified in the mandatory argument. If the user does not specify an optional argument for |\mathfont|, e.g.\ writes +% The user should specify any keyword optional arguments for |\mathfont| as entries in a comma-separated list. The order is irrelevant, and spaces between entries are permitted. For each item in the list, the package will change the math-mode font for that class of characters to the mandatory argument. Leaving out the optional argument will cause the command to revert to its default behavior, and for most applications, that will be sufficient. If the user does not specify an optional argument for |\mathfont|, e.g.\ writes % \begin{code} % |\mathfont{Helvetica}|, % \end{code} -% the package will change all math-mode Latin characters, Greek characters, digits, operators such as $\log$ or $\sin$, and all symbols from Tables~5 and 6 to the font in the mandatory argument. In this example, that would be Helvetica. By default, \textsf{mathfont} will use either an upright or italic shape corresponding to each character-class keyword, but the user can override this setting by writing an equals sign next to the keyword and a shape suboption---either ``|roman|'' or ``|italic|''---following that. Table~1 contains the default shapes for the keywords listed there, while the default shape for all classes of characters in Table~2 is upright. The package interprets the |roman| suboption as specifying an upright shape---normal shape in the language of the \textsc{nfss}---and the |italic| suboption as specifying an italic shape. Currently \textsf{mathfont} does not support default font shapes beyond these two. For example, the command +% the package will change all math-mode Latin characters, Greek characters, digits, operators such as $\log$ or $\sin$, and all symbols from Tables~5 and 6 to the font in the mandatory argument. (Specifically, all keywords from Table~1 and the |symbol| keyword from Table~2.) In this example, the new font would be Helvetica. +% +% By default, \textsf{mathfont} will use either an upright or italic shape corresponding to each character-class keyword, but the user can override this setting by writing an equals sign next to the keyword and a shape suboption---either ``|roman|'' or ``|italic|''---following that. Table~1 contains the default shapes for the keywords listed there, while the default shape for all classes of characters in Table~2 is upright. The package interprets the |roman| suboption as specifying an upright shape---normal shape in the language of the \textsc{nfss}---and the |italic| suboption as specifying an italic shape. Currently \textsf{mathfont} does not support default font shapes beyond these two. For example, the command % \begin{code} % |\mathfont[upper=roman,lower=roman]{Times New Roman}| % \end{code} -% would change all math-mode Latin letters to Times New Roman with upright shape. The optional argument for |\mathfont| should not contain any spaces because \textsf{mathfont} will not be able to parse the text correctly, and if the user mistakenly includes a space after a comma or around an equals sign, the package will issue an ``Invalid option" error. Future versions of \textsf{mathfont} may address this limitation, but it is not a priority. Users should be aware that, in order to limit the number of symbol fonts in memory, |\mathfont| will not change the default font for a class of symbols once it has already done so. +% would change all math-mode Latin letters to Times New Roman with upright shape. As of version 1.4, |\mathfont| ignores all spaces in its optional argument, so the above code snippet is equivalent to +% \begin{code} +% |\mathfont[ upper = roman , lower = roman ]{Times New Roman}|. +% \end{code} +% Technical point: |\mathfont| expands its optional argument inside an |\edef|, so the argument can contain any number of fully expandable control sequences. Users should also be aware that, in order to limit the number of symbol fonts in memory, |\mathfont| will not change the default font for a class of symbols once it has already done so. % -% \begin{figure}[t] +% \begin{figure}[b] % \centering % Table~2: Other Math Symbols\par\penalty\@M\smallskip % \begin{tabular}{ll} % \toprule % Keyword & Meaning\\ % \midrule -% |symbols| & Basic mathematical symbols\\ +% |symbols| & Basic mathematical symbols (includes punctuation)\\ % |bb| & Blackboard Bold (Double-struck)\\ % |cal| & Caligraphic\\ % |frak| & Fraktur\\ @@ -343,40 +355,39 @@ information, see the original mathfont.dtx file. % % \section{Greek Characters} % -% \begin{figure}[ht] -% \centering -% Table 4: Greek Character Control Sequences\par\penalty\@M\smallskip +% \begin{figure}[b] +% \centerline{Table 4: Greek Character Control Sequences}\penalty\@M\smallskip % \begin{tabularx}{\textwidth}{XXXX} % \toprule % \multicolumn{2}{c}{Modern Greek Characters} & \multicolumn{2}{c}{Ancient Greek Characters}\\ -% \cmidrule(r{3pt}){1-2}\cmidrule(l{3pt}){3-4} +% \cmidrule(r{4pt}){1-2}\cmidrule(l{4pt}){3-4} % Capital & Minuscule & Capital & Minuscule\\ % \midrule -% |\Alpha| & |\alpha| & |\Heta| & |\heta| \\ -% |\Beta| & |\beta| & |\Sampi| & |\sampi| \\ +% |\Alpha|* & |\alpha| & |\Heta| & |\heta| \\ +% |\Beta|* & |\beta| & |\Sampi| & |\sampi| \\ % |\Gamma| & |\gamma| & |\Diagamma| & |\diagama| \\ % |\Delta| & |\delta| & |\Koppa| & |\koppa| \\ -% |\Epsilon| & |\epsilon| & |\Stigma| & |\stigma| \\ -% |\Zeta| & |\zeta| & |\Sho| & |\sho| \\ -% |\Eta| & |\eta| & |\San| & |\san| \\ +% |\Epsilon|* & |\epsilon| & |\Stigma| & |\stigma| \\ +% |\Zeta|* & |\zeta| & |\Sho| & |\sho| \\ +% |\Eta|* & |\eta| & |\San| & |\san| \\ % |\Theta| & |\theta| & |\varSampi | & |\varsampi| \\ -% |\Iota| & |\iota| & |\varDiagamma| & |\vardiagamma| \\ -% |\Kappa| & |\kappa| & |\varKoppa| & |\varkoppa| \\ +% |\Iota|* & |\iota| & |\varDiagamma| & |\vardiagamma| \\ +% |\Kappa|* & |\kappa| & |\varKoppa| & |\varkoppa| \\ % |\Lambda| & |\lambda| & & \\ -% |\Mu| & |\mu| & & \\ -% |\Nu| & |\nu| & & \\ +% |\Mu|* & |\mu| & & \\ +% |\Nu|* & |\nu| & & \\ % |\Xi| & |\xi| & & \\ -% |\Omicron| & |\omicron| & & \\ +% |\Omicron|* & |\omicron|* & & \\ % |\Pi| & |\pi| & & \\ -% |\Rho| & |\rho| & & \\ +% |\Rho|* & |\rho| & & \\ % |\Sigma| & |\sigma| & & \\ -% |\Tau| & |\tau| & & \\ +% |\Tau|* & |\tau| & & \\ % |\Upsilon| & |\upsilon| & & \\ % |\Phi| & |\phi| & & \\ -% |\Chi| & |\chi| & & \\ +% |\Chi|* & |\chi| & & \\ % |\Psi| & |\psi| & & \\ % |\Omega| & |\omega| & & \\ -% |\varTheta| & |\varbeta| & & \\ +% |\varTheta|* & |\varbeta|* & & \\ % & |\varepsilon| & & \\ % & |\vartheta| & & \\ % & |\varrho| & & \\ @@ -384,13 +395,15 @@ information, see the original mathfont.dtx file. % & |\varphi| & & \\ % \bottomrule % \end{tabularx} +% \par\penalty\@M\smallskip +% \vbox{\small\hsize=\textwidth\noindent\strut*Starred Modern Greek and all Ancient Greek letters are not provided by default and are defined only when the user calls |\mathfont| for |greekupper| and/or |greeklower| characters.} % \end{figure} % % Unlike Plain \TeX\ and \LaTeXe, \textsf{mathfont} defines control sequences for all characters in the Greek alphabet. (\TeX's OT encodings do not include the capital Greek characters that resemble Latin letters. Presumably Donald Knuth made this decision to conserve encoding slots.) All such control sequences instruct \LaTeX\ to typeset the corresponding unicode Greek character, and \textsf{mathfont} also provides control sequences for several ancient Greek letters. This package's additional Greek character control sequences will become available once the user calls |\mathfont| for the corresponding class of Greek characters. Table~4 lists all such control sequences. I do not include typeset versions of these characters in this documentation because I wanted to avoid potential compilation problems regarding \texttt{mathfont.dtx}. However, see the file \texttt{mathfont\char`\_greek.pdf}, which is included with the \textsf{mathfont} installation and is available on \textsc{ctan}. As with the unicode letterlike symbols, not all fonts contain ancient Greek or even modern Greek characters, and setting \texttt{greekupper} and \texttt{greeklower} to a font without these symbols will produce a document with missing characters. % % \section{Math Symbols} % -% \begin{figure}[ht] +% \begin{figure}[b] % \centering % Table 5: Characters Corresponding to the |symbols| Keyword\par\penalty\@M\smallskip % \begin{tabularx}{\textwidth}{Xp{9em}XXX} @@ -429,60 +442,49 @@ information, see the original mathfont.dtx file. % $\dots$ & |\dots| & |\mathinner| & & \\\bottomrule % \end{tabularx} % \par\penalty\@M\smallskip -% \hbox to \hsize{\strut*If the package option |operators| is enabled.\hfill} -% \end{figure} -% -% \begin{figure}[b] -% \centering -% Table 6: Extra Macros Created with the |symbols| Keyword\par\penalty\@M\smallskip -% \begin{tabularx}{\textwidth}{XllXll} -% \toprule -% Character & Control Sequence & Class & Character & Control Sequence & Class\\\cmidrule(r{4pt}){1-3}\cmidrule(l{4pt}){4-6} -% $\backslash$ & |\mathbackslash| & |\mathord| & $\{$ & |\leftbrace| & |\mathopen|\\ -% $^\circ$ & |\degree| & |\mathord| & $\}$ & |\rightbrace| & |\mathclose|\\\bottomrule -% \end{tabularx} -% \end{figure} -% +% \hbox to \hsize{\small\strut*If the package option |operators| is enabled.\hfill} +% \end{figure} % +% \begin{figure}[bt] +% \centering +% Table 6: Extra Macros Created with the |symbols| Keyword\par\penalty\@M\smallskip +% \begin{tabularx}{\textwidth}{XllXll} +% \toprule +% Character & Control Sequence & Class & Character & Control Sequence & Class\\\cmidrule(r{4pt}){1-3}\cmidrule(l{4pt}){4-6} +% $\backslash$ & |\mathbackslash| & |\mathord| & $\{$ & |\leftbrace| & |\mathopen|\\ +% $^\circ$ & |\degree| & |\mathord| & $\}$ & |\rightbrace| & |\mathclose|\\ +% , & |\comma| & |\mathord| & & & \\ +% \bottomrule +% \end{tabularx} +% \end{figure} % % With the |symbols| keyword, the |\mathfont| command will change the default math-mode font for all characters in Table~5. For the control sequences on the left half of the table that function in both math and horizontal modes, \textsf{mathfont} acts on the character only when it appears in math mode, so the character will be unaffected when used in regular text. The same is true for the punctuation marks on the right side. Notice that by default the package acts on the integral, summation, and product symbols. As stated previously, users can enable or disable this behavior with the optional package arguments |operators| and |no-operators| respectively, and doing so may be desirable depending on which math symbols the user wants and the math font in use. Finally, a technical point: when \textsf{mathfont} acts on the |symbols| characters, it redefines the four macros |\#|, |\$|, |\%|, and |\&| as robust commands more complicated than a single |\char|, so constructs like |\number\#| will need to be rewritten as |\number`\#|. % -% Choosing which unicode characters to recode is something of a delicate task because so few unicode fonts contain more than the most basic mathematics symbols. \vadjust{\clearpage}In designing this portion of \textsf{mathfont}, I attempted to find the largest set of characters that reliably appears in every or nearly every major unicode font, and that's why Table~5 contains no arrows, subset and element symbols, quantifiers, and complicated operation and grouping symbols. Most standard unicode fonts don't contain those glyphs, and I wanted \textsf{mathfont} to be useful for as many fonts as possible. That being said, the package provides the four new control sequences listed in Table~6. The |\degree| command functions as the unicode alternative to the |$^\circ$| construction, and the other three control sequences print the associated unicode character. None of these characters are coded as delimiters, so they will not respond to \LaTeX's |\left| and |\right| sizing commands.\footnote{Because of time constraints, I couldn't figure out how to use Lua\TeX's \texttt{\string\Udelimiter} primitive to code the backslash and braces properly. Any suggestions in this area are welcome.} +% Choosing which unicode characters to recode is something of a delicate task because so few unicode fonts contain more than the most basic mathematics symbols. In designing this portion of \textsf{mathfont}, I attempted to find the largest set of characters that reliably appears in every or nearly every major unicode font, and that's why Table~5 contains no arrows, subset and element symbols, quantifiers, and complicated operation and grouping symbols. Most standard unicode fonts don't contain those glyphs, and I wanted \textsf{mathfont} to be useful for as many fonts as possible. That being said, the package provides the five new control sequences listed in Table~6. The |\degree| command functions as the unicode alternative to the |$^\circ$| construction, and the other four control sequences print the associated unicode character. None of these characters are coded as delimiters, so they will not respond to \LaTeX's |\left| and |\right| sizing commands.\footnote{Because of time constraints, I couldn't figure out how to use Lua\TeX's \texttt{\string\Udelimiter} primitive to code the backslash and braces properly. Any suggestions in this area are welcome.} The package also provides an additional comma character to typeset large integers. \TeX\ users have likely noticed the extra space after commas in math mode, e.g.\ $10,000$ versus $10\mathord,000$, and \textsf{mathfont}'s |\comma| solves this problem. Here the first ten thousand uses a standard~|,|~while the second uses |\comma|. In other words, the control sequence typesets a comma in math mode but does not insert the extra space following it. I recommend using |\comma| basically only for large integers, but I leave the ultimate decision up to the user. % % -% \section{Handling Errors} +% \section{Handling Errors} % -% Most of \textsf{mathfont}'s error messages are self-explanatory, and the help text will contain instructions for how to resolve the message. Nevertheless, some of the possible error messages warrant additional explanation. +% Most of \textsf{mathfont}'s error messages are self-explanatory, and the help text will contain instructions for how to resolve the message. Nevertheless, some of the possible error messages warrant additional explanation. % -% The most salient error is the ``Missing \XeTeX\ or Lua\TeX'' message. If a user tries to load \textsf{mathfont} without one of these two engines, \TeX\ will crash, either through \textsf{mathfont}'s fatal error message or when \textsf{fontspec} performs its own engine checks. Advanced users should note that \textsf{mathfont} doesn't actually determine the typesetting engine. Rather, it checks whether the \XeTeX\ and Lua\TeX\ primitives |\Umathcode| and |\Umathchardef| are defined, so if for some reason these control sequences have definitions when the user loads \textsf{mathfont}, \textsf{fontspec}'s more robust engine checks will cause \TeX\ to abort. The reasoning here is straightforward: \textsf{mathfont} verifies only that the current typesetting engine provides the commands that it directly needs, so its potential functionality remains as broad as possible. If \textsf{fontspec} becomes compatible with a third engine that also provides (analogues of) |\Umathcode| and |\Umathchardef|, there is no reason to prevent \textsf{mathfont} from working with that engine as well. The obvious corollary to this setup is that users with very old \XeTeX\ or Lua\TeX\ distributions could see this fatal error even when running one of these engines, and the solution is probably to upgrade to a more recent version of the engine in question. Unfortunately, I do not know exactly when \XeTeX\ and Lua\TeX\ introduced these primitives.\footnote{However, the manual for a beta version of Lua\TeX, v.\ 0.70.1, includes both primitives, so they are at least as old as May 2011. See\hfill\break \texttt{https://osl.ugr.es/CTAN/obsolete/systems/luatex/base/manual/luatexref-t.pdf}} +% The most salient error is the ``Missing \XeTeX\ or Lua\TeX'' message. If a user tries to load \textsf{mathfont} without one of these two engines, \TeX\ will crash, either through \textsf{mathfont}'s fatal error message or when \textsf{fontspec} performs its own engine checks. Advanced users should note that \textsf{mathfont} doesn't actually determine the typesetting engine. Rather, it checks whether the \XeTeX\ and Lua\TeX\ primitives |\Umathcode| and |\Umathchardef| are defined, so if for some reason these control sequences have definitions when the user loads \textsf{mathfont}, \textsf{fontspec}'s more robust engine checks will cause \TeX\ to abort. The reasoning here is straightforward: \textsf{mathfont} verifies only that the current typesetting engine provides the commands that it directly needs, so its potential functionality remains as broad as possible. If \textsf{fontspec} becomes compatible with a third engine that also provides (analogues of) |\Umathcode| and |\Umathchardef|, there is no reason to prevent \textsf{mathfont} from working with that engine as well. The obvious corollary to this setup is that users with very old \XeTeX\ or Lua\TeX\ distributions may see this fatal error even when running one of these engines, and the solution is probably to upgrade to a more recent version of the engine in question. Unfortunately, I do not know when \XeTeX\ and Lua\TeX\ introduced these primitives.\footnote{However, the manual for a beta version of Lua\TeX, v.\ 0.70.1, includes both primitives, so they are at least as old as May 2011. See\hfill\break \texttt{https://osl.ugr.es/CTAN/obsolete/systems/luatex/base/manual/luatexref-t.pdf}} % -% The \textsf{fontspec} package includes a ``|no-math|'' option, and \textsf{mathfont} expects \textsf{fontspec} to be loaded with this option. As mentioned previously, \textsf{mathfont} loads \textsf{fontspec} by default, but users can load \textsf{fontspec} before \textsf{mathfont} if they want to manually specify the package options. Alternatively, \LaTeX's |\PassOptionsToPackage| may be an even better way to proceed. If \textsf{mathfont} detects that \textsf{fontspec} was loaded without the |no-math| option, it will issue an error message saying so. This error is not paramount in the sense that the document will compile almost normally if a user ignores it, but \textsf{mathfont} will probably have trouble changing the font of certain math-mode characters in this situation. During development, Arabic numerals posed a particular challenge in this regard. +% The \textsf{fontspec} package includes a ``|no-math|'' option, and \textsf{mathfont} expects \textsf{fontspec} to be loaded with this option. As mentioned previously, \textsf{mathfont} loads \textsf{fontspec} by default, but users can load \textsf{fontspec} before \textsf{mathfont} if they want to manually specify the package options. Alternatively, \LaTeX's |\PassOptionsToPackage| may be an even better way to proceed. If \textsf{mathfont} detects that \textsf{fontspec} was loaded without the |no-math| option, it will issue an error message saying so. This error is not paramount in the sense that the document will compile almost normally if a user ignores it, but \textsf{mathfont} will probably have trouble changing the font of certain math-mode characters in this situation. During development, Arabic numerals posed a particular challenge in this regard. % -% The ``internal commands restored'' error arises when the user calls |\mathfont| in a situation where the package already restored the small portion of the \LaTeX\ kernel that it adjusts when loaded. Unless the user loads \textsf{mathfont} with the |packages| option, this process happens when the user next calls |\usepackage|, and \textsf{mathfont} will not carry out any calls to |\mathfont| at that point. As mentioned previously, users who want to manually restore the \LaTeX\ kernel can do so with the |\restoremathinternals| command. +% The ``internal commands restored'' error arises when the user calls |\mathfont| in a situation where the package already restored the small portion of the \LaTeX\ kernel that it adjusts when loaded. Unless the user loads \textsf{mathfont} with the |packages| option, this process happens when the user next calls |\usepackage|, and \textsf{mathfont} will not carry out any calls to |\mathfont| at that point. As mentioned previously, users who want to manually restore the \LaTeX\ kernel can do so with the |\restoremathinternals| command. It is also worth pointing out if the user tries to reset the default font for some characters with |\mathfont|, the package will issue a warning but will not halt the compilation process. % -% Users who receive an ``Invalid option'' error for |\mathfont| should make sure they removed any extra spaces from their list of keywords in the command's optional argument. It is also worth pointing out if the user tries to reset the default font for some characters with |\mathfont|, the package will issue a warning but will not halt the compilation process. +% What should you do if you can't resolve an error? First, always, always make sure that you spelled all of your commands correctly and closed all braces and brackets. Then check the \textsf{mathfont} documentation---you may be trying to do something outside the scope of the package, or you may be dealing with a special case. In particular, read all the sections of the documentation that relate to the command or commands you are having trouble with. The internet is a great resource, and websites such as the \TeX\ StackExchange, Share\LaTeX, and Wikibooks's \LaTeX\ wiki are often invaluable in dealing with \TeX-related issues. Definitely ask another human as well! At that point you should email the author about your code---you might have identified a bug. I welcome emails about \textsf{mathfont} and will make every effort to write back to correspondence about the package, but I cannot guarantee a timely response. % % -% What should you do if you can't resolve an error? First, always, always make sure that you spelled all of your commands correctly and closed all braces and brackets. Then check the \textsf{mathfont} documentation---you may be trying to do something outside the scope of the package, or you may be dealing with a special case. In particular, read all the sections of the documentation that relate to the command or commands you are having trouble with. The internet is a great resource, and websites such as the \TeX\ StackExchange, Share\LaTeX, and Wikibooks's \LaTeX\ wiki are often invaluable in dealing with \TeX-related issues. Definitely ask another human as well! At that point you should email the author about your code---you might have identified a bug. Please include a minimal working example that demonstrates the problem in any such correspondence. I welcome emails about \textsf{mathfont} and will make every effort to write back to emails about the package, but I cannot guarantee a timely response. -% -% -% \init@checksum -% % % \section{Implementation} % -% -% -% \noindent First and foremost, the package needs to declare itself. -% The \texttt{packages} option -% changes the |\if@packages| boolean from false to true. -% +% First and foremost, the package needs to declare itself.\vadjust{\penalty0} The \texttt{packages} option changes the |\if@packages| boolean from false to true. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mathfont}[2019/01/19 v. 1.3 Package mathfont] +\ProvidesPackage{mathfont}[2019/04/01 v. 1.4 Package mathfont] \newif\if@packages \newif\if@operators -\@operatorstrue \DeclareOption{packages}{\@packagestrue} \DeclareOption{operators}{\@operatorstrue} \DeclareOption{no-operators}{\@operatorsfalse} @@ -534,11 +536,21 @@ information, see the original mathfont.dtx file. \def\M@InvalidOptionError#1{\PackageError{mathfont} {Invalid option "#1"\MessageBreak for \string\mathfont} {Hm. Check that you spelled the\MessageBreak - option correctly and didn't include\MessageBreak - any extra spaces. Otherwise, I'm\MessageBreak + option correctly. Otherwise, I'm\MessageBreak not sure what's wrong. Is this\MessageBreak option listed in the package\MessageBreak documentation?}} +\def\M@MissingOptionError{\PackageError{mathfont} + {Missing option for \string\mathfont} + {It looks like you included a , or = in\MessageBreak + the optional argument of \string\mathfont\space\MessageBreak + but didn't put anything before it.}} +\def\M@MissingSuboptionError{\PackageError{mathfont} + {Missing suboption for \string\mathfont} + {It looks like you included an = somewhere\MessageBreak + but didn't put the suboption after it. Either\MessageBreak + that or you typed == instead of = in the\MessageBreak + optional argument of \string\mathfont.}} \def\M@InternalsRestoredError{\PackageError{mathfont} {Internal commands restored} {This package slightly changes two LaTeX\MessageBreak @@ -572,17 +584,34 @@ information, see the original mathfont.dtx file. math mode. I've inserted a \string$\MessageBreak just before your \string#1, so\MessageBreak we should be all good now.}} -\def\M@XeTeXLuaTeXError{\PackageError{mathfont} - {!!FATAL ERROR!! : Missing\MessageBreak XeTeX or LuaTeX} +% \end{macrocode} +% We want to create a salient error message if the engine doesn't define the required \XeTeX\ or Lua\TeX\ primitives. We change |+| to active to force \TeX\ to print the required spaces in the message, and we put the entire production inside a group to make this change local. The |\@gobbletwo| eats the extra period and return that \LaTeX\ adds to the error message. +% \begin{macrocode} +\begingroup +\catcode`\+=\active +\def+{\space} +\def\M@XeTeXLuaTeXError{\GenericError{} + {\MessageBreak\MessageBreak + Package mathfont fatal error: + \MessageBreak\MessageBreak + +*********************\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*++!!FATAL ERROR!!++*\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*+++Missing XeTeX+++*\MessageBreak + +*+++++or LuaTeX+++++*\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*********************\MessageBreak\@gobbletwo} + {See the mathfont package documentation for explanation.} {This package requires either\MessageBreak XeLaTeX or LuaLaTeX. Please\MessageBreak - retypeset this document with\MessageBreak + retypeset your document with\MessageBreak one of those two engines. This\MessageBreak error is fatal, so I'm going\MessageBreak to stop processing once you\MessageBreak push enter.}\@@end} % \end{macrocode} -% Check if the current engine has defined the necessary primitives. +% Check that the engine has defined the necessary primitives. % \begin{macrocode} \ifx\Umathcode\@undefined \else @@ -592,6 +621,7 @@ information, see the original mathfont.dtx file. \fi \fi \M@XeTeXLuaTeXError +\endgroup % \end{macrocode} % We load the \textsf{fontspec} package in order to use % its main font loading mechanism, and we |\let| the @@ -612,7 +642,7 @@ information, see the original mathfont.dtx file. % so we can change their % definitions. We need to adapt these macros for use with unicode fonts, and we % replace |\mathcode| and |\mathchardef| respectively -% with the \XeTeX\ and Lua\TeX primitives |\Umathcode| and |\Umathchardef|. +% with the \XeTeX\ and Lua\TeX\ primitives |\Umathcode| and |\Umathchardef|. % The unicode primitives support decimal input using % a |+| sign, and we take advantage of that feature to avoid hexadecimal conversions. % \begin{macrocode} @@ -628,11 +658,11 @@ information, see the original mathfont.dtx file. \advance\count\z@\count\tw@ \global\Umathchardef#2\mathchar@type#3+#1+\count\z@} % \end{macrocode} -% We need to keep track of the number of times we have loaded a font. -% The count |\M@count| fulfills this role. +% We need to keep track of the number of times we have loaded a font, and the count |\M@count| fulfills this role. We will use the |\M@toks| object to record a message that displays when the user calls |\mathfont|. % \begin{macrocode} \newcount\M@count \M@count\z@ +\newtoks\M@toks % \end{macrocode} % We create necessary booleans and the default math font shapes. % \begin{macrocode} @@ -662,29 +692,7 @@ information, see the original mathfont.dtx file. \def\@bcalshape{roman} \def\@bfrakshape{roman} % \end{macrocode} -% We want to allow the user to specify options using an -% \textsf{xkeyval}-type syntax. However, we do not need the full package; a slim -% 31 lines of code will suffice. The macro |\check@suboption| determines whether the -% user specified a keyword option for |\mathfont| using a |key=value| input and stores both -% the option and corresponding suboption, if applicable, -% in |\@tempa| and |\@tempb| respectively. -% \begin{macrocode} -\def\strip@equals#1={#1} -\def\check@suboption#1=#2\@nil{% - \def\@tempa{#1} - \def\@tempb{#2} - \check@option@valid\@tempa - \ifx\@tempb\@empty - \@suboptionpresentfalse - \else - \edef\@tempb{\expandafter\strip@equals\@tempb} - \check@suboption@valid\@tempb - \@suboptionpresenttrue - \fi} -% \end{macrocode} -% The commands |\check@option@valid| and -% |\check@suboption@valid| confirm that the keyword option and -% suboption are legitimate. If not, \textsf{mathfont} issues an error. +% The command |\check@option@valid| confirms that a user's keyword option is legitimate. The macro defines |\@temperror| to be an invalid option error and loops through all possible options. If the command argument matches one of the correct possibilities, the package changes |\@temperror| to |\relax|. The macro ends this process with a call to |\@temperror|, so the package issues an error if and only if the specified option is invalid. We have to initialize the blackboard, calligraphic, and fraktur commands separately because they don't use the same encoding-alphabet system as the regular letters and digits. The |\define@|\argtext{keyword} macro does this. % \begin{macrocode} \def\check@option@valid#1{% \def\@temperror{\M@InvalidOptionError{#1}} @@ -692,17 +700,15 @@ information, see the original mathfont.dtx file. \ifx\@j#1 \let\@temperror\relax \fi} -% \end{macrocode} -% We have to initialize the blackboard, calligraphic, and fraktur commands separately -% because they don't use the same encoding-alphabet system as the regular letters -% and digits. The |\define@|\argtext{keyword} macro does this. -% \begin{macrocode} \@for\@j:=bb,cal,frak,bcal,bfrak\do{% \ifx\@j#1 \let\@temperror\relax \csname define@\@j\endcsname \fi} \@temperror} +% \end{macrocode} +% Do the same thing for the suboption. +% \begin{macrocode} \def\check@suboption@valid#1{% \def\@temperror{\M@InvalidOptionError{#1}} \@for\@j:=roman,italic\do{% @@ -711,56 +717,86 @@ information, see the original mathfont.dtx file. \fi} \@temperror} % \end{macrocode} +% We want to allow the user to specify options using an \textsf{xkeyval}-type syntax. However, we do not need the full package; a slim 24 lines of code will suffice. We use the next three macros to parse the optional argument of |\mathfont|. The control sequence +% \begin{code} +% |\@gobblesp |\argtext{text}|\@nil|\argtext{macro} +% \end{code} +% takes the first string of consecutive non-space tokens in \textit{text} and sets it to be the contents of \textit{macro}. We remove initial spaces with |\@ifnextchar| and use delimiters in the definition of |\g@bblesp@def| for the token selection and final storage. +% \begin{macrocode} +\def\@gobble@equals#1=#2\@nil{#1} +\def\@gobblesp{\@ifnextchar\@empty\relax\g@bblesp@def} +\def\g@bblesp@def#1 #2\@nil#3{\def#3{#1}} +% \end{macrocode} +% Parse the option and suboption. When |\mathfont| expands, it loops through its optional argument with |\@for|, and for each option-suboption token string, it calls |\parse@suboption| on the token string followed by |=\@nil|. Doing so splits the option and suboption, and |\parse@suboption| handles each separately. All tokens before the first |=| become the option, and all tokens after become the suboption. The macro removes any extra spaces with |\@gobblesp| and puts the option in |\@tempa|. We include the extra |\\| in the argument of |\@gobblesp| because we need to check that the option portion of the token string contains non-space characters. If not, |\@tempa| will become |\\|, and the package issues an error. (If yes, |\g@bblesp@def| will gobble the |\\| and following space, so it won't matter.) +% \begin{macrocode} +\def\parse@suboption#1=#2\@nil{% + \@gobblesp#1 \\ \@nil\@tempa + \def\@tempb{\\} + \ifx\@tempa\@tempb + \M@MissingOptionError + \else + \check@option@valid\@tempa + \fi +% \end{macrocode} +% Adding the |=\@nil| to the token string allows us to see immediately whether the user specified a suboption by checking if |#2| is empty. If not, the macro again removes extra spaces with |\@gobblesp|, and we check whether |\@let@token| from the |\@ifnextchar| is the extra~|=|. That would mean the user typed |=| but didn't follow it with a suboption, and in that case, \textsf{mathfont} issues an error. If the suboption is valid, the macro gobbles the last |=| with |\@gobble@equals| and stores the result in |\@tempb|. +% \begin{macrocode} + \def\@tempb{#2} + \ifx\@tempb\@empty + \@suboptionpresentfalse + \else + \@gobblesp#2 \@nil\@tempb + \if\@let@token= + \M@MissingSuboptionError + \else + \edef\@tempb{\expandafter\@gobble@equals\@tempb=\@nil} + \check@suboption@valid\@tempb + \fi + \@suboptionpresenttrue + \fi} +% \end{macrocode} % % \section{Implementation of Default Font Changes} % -% The user-level command |\mathfont| passes -% its mandatory argument to |\@newfont| through the |\@mathfont| command. If the user -% includes |\mathfont| with an optional argument, |\@mathfont| will loop through -% each item in the optional argument -% using |\@for| and set the math font for each of those classes of -% characters. If the user does not specify an optional argument, |\mathfont| calls |\@mathfont| with the list of entries from Table~1 in brackets. The |\@mathfont| macro proceeds in several steps. First, it checks if |\set@mathchar| has been reset, and if so, the current call to |\mathfont| will do nothing. If not, the macro loads the user's font with |\@newfont| and checks its keyword optional arguments. The command declares the appropriate symbol fonts if necessary, actually sets the math font by calling |\M@|\argtext{keyword}|@set| -% command, and records that the font change occurred by switching the -% appropriate boolean to true. Finally, |\@mathfont| increments |\M@count| by one. +% The user-level\vadjust{\penalty0} command |\mathfont| passes its mandatory argument to |\@newfont| through the |\@mathfont| command. If the user includes |\mathfont| with an optional argument, |\@mathfont| will loop througheach item in the optional argumentusing |\@for| and set the math font for each of those classes of characters. If the user does not specify an optional argument, |\mathfont| calls |\@mathfont| with the list of entries from Table~1 in brackets. The |\@mathfont| macro proceeds in several steps. First, it checks if |\set@mathchar| has been reset, and if so, the current call to |\mathfont| will do nothing. If not, the macro loads the user's font with |\@newfont| and checks its keyword optional arguments. The command declares the appropriate symbol fonts if necessary, actually sets the math font by calling |\M@|\argtext{keyword}|@set| command, and records that the font change occurred by switching the appropriate boolean to true. Finally, |\@mathfont| increments |\M@count| by one. % -% The package stores each new font in a macro of the form -% |\M@font|\argtext{number}, where \textit{number} is given by the -% current value of |\M@count|. The name of the corresponding symbol fonts is -% |M|\argtext{shape}\argtext{number}, where -% \textit{shape} is either \texttt{roman} or \texttt{italic} and \textit{number} is again the value of |\M@count|. For each keyword from Tables~1 and 2, the -% package originally defines |\@|\argtext{keyword}|shape| as the default shape -% for that collection of characters. If the user specifies a suboption for any keyword in the -% optional argument of |\mathfont|, the package overrides the default shape by -% redefining |\@|\argtext{keyword}|shape| to the value of the suboption. For -% example, suppose the user loads \textsf{mathfont} and then immediately writes +% The package stores each new font in a macro of the form |\M@font|\argtext{number}, where \textit{number} is given by the current value of |\M@count|. The name of the corresponding symbol fonts is |M|\argtext{shape}\argtext{number}, where \textit{shape} is either \texttt{roman} or \texttt{italic} and \textit{number} is again the value of |\M@count|. For each keyword from Tables~1 and 2, the package originally defines |\@|\argtext{keyword}|shape| as the default shape for that collection of characters. If the user specifies a suboption for any keyword in the optional argument of |\mathfont|, the package overrides the default shape by redefining |\@|\argtext{keyword}|shape| to the value of the suboption. For example, suppose the user loads \textsf{mathfont} and then immediately writes % \begin{code} % |\mathfont[upper=roman]{Helvetica}|. % \end{code} % In this situation, \textsf{mathfont} would define |\M@font0| to be the internal name of Helvetica, and the corresponding symbol font names would be |Mroman0| and |Mitalic0|. Because the user specified a suboption, |\@mathfont| would redefine |\M@uppershape| to the token string ``\texttt{roman},'' and the package will use |\M@uppershape| later to specify the symbol font for capital Latin characters. % \begin{macrocode} -\def\gobble@equals#1=#2\@nil{#1} \def\mathfont{\@ifnextchar[{\@mathfont} {\@mathfont[upper,lower,greekupper,greeklower,digits,symbols,operator]}} \def\@mathfont[#1]#2{% \ifx\@@set@mathchar\set@mathchar \M@InternalsRestoredError \else + \M@toks{} + \@tempswafalse \expandafter\@newfont\csname M@font\the\M@count\endcsname{}{#2} - \@for\@i:=#1\do{\expandafter\check@suboption\@i=\@nil + \edef\@tempa{#1} + \@for\@i:=\@tempa\do{\expandafter\parse@suboption\@i=\@nil % \end{macrocode} -% If the user calls |\mathfont| and tries -% to reset the font for a certain class of characters, \textsf{mathfont} will issue a warning, -% and the package will not adjust the font for those characters. Notice the particularly awkward syntax with the |\csname|-|\endcsname| pairs. Without this construct, \TeX\ wouldn't realize that |\csname if@\@tempa\endcsname| matches the eventual |\fi|, and the |\@for| loop would break. (\TeX\ does not have a smart if-parser!) +% If the user calls |\mathfont| and tries to reset the font for a certain class of characters, \textsf{mathfont} will issue a warning, and the package will not adjust the font for those characters. Notice the particularly awkward syntax with the |\csname|-|\endcsname| pairs. Without this construct, \TeX\ wouldn't realize that |\csname if@\@tempa\endcsname| matches the eventual |\fi|, and the |\@for| loop would break. (\TeX\ does not have a smart if-parser!) % \begin{macrocode} \expandafter\ifx\csname if@\@tempa\expandafter\endcsname \csname iftrue\endcsname \M@CharsSetWarning{\@tempa} \else + \if@tempswa + \expandafter\M@toks\expandafter{\the\M@toks, } + \else + \@tempswatrue + \fi + \edef\@tempc{\the\M@toks\@tempa} + \expandafter\M@toks\expandafter{\@tempc} % \end{macrocode} % Handle the case with a suboption. % \begin{macrocode} \if@suboptionpresent \expandafter\edef\csname @\@tempa shape\endcsname{\@tempb} + \edef\@tempc{\the\M@toks\space(\@tempb)} + \expandafter\M@toks\expandafter{\@tempc} \fi % \end{macrocode} % For both possible shapes, check whether the package has already declared that version of the current font for use in math mode using |\@ifundefined|. If not, do so. @@ -785,11 +821,16 @@ information, see the original mathfont.dtx file. \csname @\@tempa true\endcsname \fi} \advance\M@count\@ne\relax - \message{^^J:: mathfont :: math font for character keyword classes^^J#1^^J% - changed to #2^^J^^J} + \message{:: mathfont :: following keyword(s) changed to #2:^^J% + --\the\M@toks.^^J} \fi} \@onlypreamble\mathfont % \end{macrocode} +% We end the section by coding |\setfont|. +% \begin{macrocode} +\def\setfont#1{\mathfont{#1}\setmainfont[Ligatures=TeX]{#1}} +\@onlypreamble\setfont +% \end{macrocode} % % \section{Implementation of Local Font Changes} % @@ -832,8 +873,8 @@ information, see the original mathfont.dtx file. \ifmmode \expandafter\@tempa \else - \leavevmode\M@HModeError#1% - \expandafter$\expandafter\@tempa + \M@HModeError#1% + \leavevmode\expandafter$\expandafter\@tempa \fi} \def\process@tokens#1#2{\@tfor\@k:=#1\do{\csname M@#2@\@k\endcsname}} \def\define@bb{% @@ -1030,7 +1071,7 @@ information, see the original mathfont.dtx file. \edef\M@symbols{M\@symbolsshape\the\M@count} \DeclareMathSymbol{.}{\mathord}{\M@symbols}{"2E} \DeclareMathSymbol{@}{\mathord}{\M@symbols}{"40} - \DeclareMathSymbol{\mathpound}{\mathord}{\M@symbols}{"23} + \DeclareMathSymbol{\mathhash}{\mathord}{\M@symbols}{"23} \DeclareMathSymbol{\mathdollar}{\mathord}{\M@symbols}{"24} \DeclareMathSymbol{\mathpercent}{\mathord}{\M@symbols}{"25} \DeclareMathSymbol{\mathand}{\mathord}{\M@symbols}{"26} @@ -1046,6 +1087,7 @@ information, see the original mathfont.dtx file. \DeclareMathSymbol{\Delta}{\mathord}{\M@symbols}{"2206} \DeclareMathSymbol{'}{\mathord}{\M@symbols}{"2032} \DeclareMathSymbol{"}{\mathord}{\M@symbols}{"2033} + \DeclareMathSymbol{\comma}{\mathord}{\M@symbols}{"2C} \if@operators \DeclareMathSymbol{\sum}{\mathop}{\M@symbols}{"2211} \DeclareMathSymbol{\prod}{\mathop}{\M@symbols}{"220F} @@ -1088,30 +1130,12 @@ information, see the original mathfont.dtx file. \let\mathellipsis\@undefined \DeclareMathSymbol{\mathellipsis}{\mathinner}{\M@symbols}{"2026} % \end{macrocode} -% Redefining |\#|, |\$|, |\%|, and |\&| is tricky. We use |\string| to declare robust versions of these commands that expand to previously declared |\mathpound|, etc.\ symbols in math mode and retain their standard |\char| definitions otherwise. Other commands that function in both math and horizontal modes such as |\S| or |\dag| also use this technique. -% \begin{macrocode} - \count@\escapechar - \escapechar\m@ne - \edef\#{\noexpand\protect - \expandafter\noexpand\csname\string\# \endcsname} - \expandafter\def\csname\string\# \endcsname{\ifmmode - \mathpound\else\char"23\fi} - \edef\${\noexpand\protect - \expandafter\noexpand\csname\string\$ \endcsname} - \expandafter\def\csname\string\$ \endcsname{\ifmmode - \mathdollar\else\char"24\fi} - \edef\%{\noexpand\protect - \expandafter\noexpand\csname\string\% \endcsname} - \expandafter\def\csname\string\% \endcsname{\ifmmode - \mathpercent\else\char"25\fi} - \edef\&{\noexpand\protect - \expandafter\noexpand\csname\string\& \endcsname} - \expandafter\def\csname\string\& \endcsname{\ifmmode - \mathand\else\char"26\fi} - \escapechar\count@ -% \end{macrocode} -% Finally a bit of housekeeping. +% Finally a bit of housekeeping. We redefine |\#|, |\$|, |\%|, and |\&| as robust commands that expand to previously declared |\mathhash|, etc.\ commands in math mode and retain their standard |\char| definitions otherwise. Other commands that function in both math and horizontal modes such as |\S| or |\dag| also use this technique. The last three commands defined here preserve the Computer Modern font for charcters used in several math-mode symbols. % \begin{macrocode} + \DeclareRobustCommand\#{\ifmmode\mathhash\else\char"23\fi} + \DeclareRobustCommand\${\ifmmode\mathdollar\else\char"24\fi} + \DeclareRobustCommand\%{\ifmmode\mathpercent\else\char"25\fi} + \DeclareRobustCommand\&{\ifmmode\mathand\else\char"26\fi} \DeclareMathSymbol{\@relbar}{\mathbin}{symbols}{"00} \DeclareMathSymbol{\@Relbar}{\mathrel}{operators}{"3D} \DeclareMathSymbol{\@verticalbar}{\mathord}{symbols}{"6A} @@ -1123,8 +1147,7 @@ information, see the original mathfont.dtx file. % \begin{macrocode} \def\M@operator@set{% \edef\operator@font{\noexpand\mathgroup - \expandafter\noexpand - \csname symM\@operatorshape\the\M@count\endcsname}} + \expandafter\noexpand\csname symM\@operatorshape\the\M@count\endcsname}} % \end{macrocode} % Set blackboard bold characters. % \begin{macrocode} @@ -1475,7 +1498,7 @@ Greek Characters Provided by \textsf{mathfont}, Rendered in Symbola\par\penalty1 \begin{tabular}{llllllll} \toprule \multicolumn{4}{c}{Modern Greek Characters} & \multicolumn{4}{c}{Ancient Greek Characters}\\ -\cmidrule(r{3pt}){1-4}\cmidrule(l{3pt}){5-8} +\cmidrule(r{4pt}){1-4}\cmidrule(l{4pt}){5-8} \multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule} & \multicolumn{2}{c}{Capital} & \multicolumn{2}{c}{Minuscule}\\ \midrule |\Alpha| & $\Alpha$ & |\alpha| & $\alpha$ & |\Heta| & $\Heta$ & |\heta| & $\heta$ \\ @@ -1517,13 +1540,10 @@ Greek Characters Provided by \textsf{mathfont}, Rendered in Symbola\par\penalty1 \documentclass[12pt]{article} \usepackage[margin=72.27pt]{geometry} \usepackage[factor=600,stretch=14,shrink=14,step=1]{microtype} -\usepackage{selnolig} -\usepackage[no-operators]{mathfont} -\mathfont{Times New Roman} +\usepackage{mathfont} +\setfont{Times New Roman} \mathfont[bb]{Symbola} \restoremathinternals -\setmainfont{Times New Roman} -\nolig{Th}{T|h} \hyphenpenalty=10 \exhyphenpenalty=5 \pretolerance=30 @@ -1560,7 +1580,7 @@ A smooth manifold consists of a topological space $M$ equipped with a smooth max \[ \psi_j^{}\circ f\circ\phi_i^{-1} \] -is itself smooth, where $\leftbrace\psi_i\rightbrace$ is a smooth atlas for $N$. Differentiating $f$ produces the associated tangent map $Df$. The function $Df$ maps the tangent space $TM$ to the tangent space $TN$ and is linear when restricted to individual tangent spaces $T_pM$. If $M$ can be written as a product $M_1\times M_2$, we can consider the partial tangent maps $\partial_1f$ and $\partial_2f$ by considering the compositions $f\circ\iota_1$ and $f\circ\iota_2$, where $\iota_1$ and $\iota_2$ are inclusion maps with respect to a particular point. Combining both maps, we have the equation +is itself smooth, where $\leftbrace\psi_i\rightbrace$ is a smooth atlas for $N$. Differentiating $f$ produces the associated tangent map $Df$. The function $Df$ maps the tangent bundle $TM$ to the tangent bundle $TN$ and is linear when restricted to individual tangent spaces $T_pM$. If $M$ can be written as a product $M_1\times M_2$, we can consider the partial tangent maps $\partial_1f$ and $\partial_2f$ by considering the compositions $f\circ\iota_1$ and $f\circ\iota_2$, where $\iota_1$ and $\iota_2$ are inclusion maps with respect to a particular point. Combining both maps, we have the equation \[ Df(u,v)=\partial_1f(u)+\partial_2f(v), \] diff --git a/Master/texmf-dist/tex/latex/mathfont/mathfont.sty b/Master/texmf-dist/tex/latex/mathfont/mathfont.sty index db4e26242a5..b4512aa9d0e 100644 --- a/Master/texmf-dist/tex/latex/mathfont/mathfont.sty +++ b/Master/texmf-dist/tex/latex/mathfont/mathfont.sty @@ -6,7 +6,7 @@ %% %% mathfont.dtx (with options: `package') %% -%% Copyright 2018 by Conrad Kosowsky +%% Copyright 2018-2019 by Conrad Kosowsky %% %% This file may be distributed and modified under the terms %% of the LaTeX Public Project License, version 1.3c or any later version. @@ -23,10 +23,9 @@ %% information, see the original mathfont.dtx file. %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{mathfont}[2019/01/19 v. 1.3 Package mathfont] +\ProvidesPackage{mathfont}[2019/04/01 v. 1.4 Package mathfont] \newif\if@packages \newif\if@operators -\@operatorstrue \DeclareOption{packages}{\@packagestrue} \DeclareOption{operators}{\@operatorstrue} \DeclareOption{no-operators}{\@operatorsfalse} @@ -75,11 +74,21 @@ \def\M@InvalidOptionError#1{\PackageError{mathfont} {Invalid option "#1"\MessageBreak for \string\mathfont} {Hm. Check that you spelled the\MessageBreak - option correctly and didn't include\MessageBreak - any extra spaces. Otherwise, I'm\MessageBreak + option correctly. Otherwise, I'm\MessageBreak not sure what's wrong. Is this\MessageBreak option listed in the package\MessageBreak documentation?}} +\def\M@MissingOptionError{\PackageError{mathfont} + {Missing option for \string\mathfont} + {It looks like you included a , or = in\MessageBreak + the optional argument of \string\mathfont\space\MessageBreak + but didn't put anything before it.}} +\def\M@MissingSuboptionError{\PackageError{mathfont} + {Missing suboption for \string\mathfont} + {It looks like you included an = somewhere\MessageBreak + but didn't put the suboption after it. Either\MessageBreak + that or you typed == instead of = in the\MessageBreak + optional argument of \string\mathfont.}} \def\M@InternalsRestoredError{\PackageError{mathfont} {Internal commands restored} {This package slightly changes two LaTeX\MessageBreak @@ -113,11 +122,25 @@ math mode. I've inserted a \string$\MessageBreak just before your \string#1, so\MessageBreak we should be all good now.}} -\def\M@XeTeXLuaTeXError{\PackageError{mathfont} - {!!FATAL ERROR!! : Missing\MessageBreak XeTeX or LuaTeX} +\begingroup +\catcode`\+=\active +\def+{\space} +\def\M@XeTeXLuaTeXError{\GenericError{} + {\MessageBreak\MessageBreak + Package mathfont fatal error: + \MessageBreak\MessageBreak + +*********************\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*++!!FATAL ERROR!!++*\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*+++Missing XeTeX+++*\MessageBreak + +*+++++or LuaTeX+++++*\MessageBreak + +*+++++++++++++++++++*\MessageBreak + +*********************\MessageBreak\@gobbletwo} + {See the mathfont package documentation for explanation.} {This package requires either\MessageBreak XeLaTeX or LuaLaTeX. Please\MessageBreak - retypeset this document with\MessageBreak + retypeset your document with\MessageBreak one of those two engines. This\MessageBreak error is fatal, so I'm going\MessageBreak to stop processing once you\MessageBreak @@ -130,6 +153,7 @@ \fi \fi \M@XeTeXLuaTeXError +\endgroup \@ifpackageloaded{fontspec} {\ifnum\csname g__fontspec_math_bool\endcsname=1 \M@NoMathError @@ -149,6 +173,7 @@ \global\Umathchardef#2\mathchar@type#3+#1+\count\z@} \newcount\M@count \M@count\z@ +\newtoks\M@toks \newif\if@upper \newif\if@lower \newif\if@greekupper @@ -174,18 +199,6 @@ \def\@frakshape{roman} \def\@bcalshape{roman} \def\@bfrakshape{roman} -\def\strip@equals#1={#1} -\def\check@suboption#1=#2\@nil{% - \def\@tempa{#1} - \def\@tempb{#2} - \check@option@valid\@tempa - \ifx\@tempb\@empty - \@suboptionpresentfalse - \else - \edef\@tempb{\expandafter\strip@equals\@tempb} - \check@suboption@valid\@tempb - \@suboptionpresenttrue - \fi} \def\check@option@valid#1{% \def\@temperror{\M@InvalidOptionError{#1}} \@for\@j:=upper,lower,greekupper,greeklower,digits,symbols,operator\do{% @@ -205,21 +218,56 @@ \let\@temperror\relax \fi} \@temperror} -\def\gobble@equals#1=#2\@nil{#1} +\def\@gobble@equals#1=#2\@nil{#1} +\def\@gobblesp{\@ifnextchar\@empty\relax\g@bblesp@def} +\def\g@bblesp@def#1 #2\@nil#3{\def#3{#1}} +\def\parse@suboption#1=#2\@nil{% + \@gobblesp#1 \\ \@nil\@tempa + \def\@tempb{\\} + \ifx\@tempa\@tempb + \M@MissingOptionError + \else + \check@option@valid\@tempa + \fi + \def\@tempb{#2} + \ifx\@tempb\@empty + \@suboptionpresentfalse + \else + \@gobblesp#2 \@nil\@tempb + \if\@let@token= + \M@MissingSuboptionError + \else + \edef\@tempb{\expandafter\@gobble@equals\@tempb=\@nil} + \check@suboption@valid\@tempb + \fi + \@suboptionpresenttrue + \fi} \def\mathfont{\@ifnextchar[{\@mathfont} {\@mathfont[upper,lower,greekupper,greeklower,digits,symbols,operator]}} \def\@mathfont[#1]#2{% \ifx\@@set@mathchar\set@mathchar \M@InternalsRestoredError \else + \M@toks{} + \@tempswafalse \expandafter\@newfont\csname M@font\the\M@count\endcsname{}{#2} - \@for\@i:=#1\do{\expandafter\check@suboption\@i=\@nil + \edef\@tempa{#1} + \@for\@i:=\@tempa\do{\expandafter\parse@suboption\@i=\@nil \expandafter\ifx\csname if@\@tempa\expandafter\endcsname \csname iftrue\endcsname \M@CharsSetWarning{\@tempa} \else + \if@tempswa + \expandafter\M@toks\expandafter{\the\M@toks, } + \else + \@tempswatrue + \fi + \edef\@tempc{\the\M@toks\@tempa} + \expandafter\M@toks\expandafter{\@tempc} \if@suboptionpresent \expandafter\edef\csname @\@tempa shape\endcsname{\@tempb} + \edef\@tempc{\the\M@toks\space(\@tempb)} + \expandafter\M@toks\expandafter{\@tempc} \fi \def\@tempb{roman} \expandafter\ifx\csname @\@tempa shape\endcsname\@tempb @@ -238,10 +286,12 @@ \csname @\@tempa true\endcsname \fi} \advance\M@count\@ne\relax - \message{^^J:: mathfont :: math font for character keyword classes^^J#1^^J% - changed to #2^^J^^J} + \message{:: mathfont :: following keyword(s) changed to #2:^^J% + --\the\M@toks.^^J} \fi} \@onlypreamble\mathfont +\def\setfont#1{\mathfont{#1}\setmainfont[Ligatures=TeX]{#1}} +\@onlypreamble\setfont \def\check@csarg#1#2#3{% \ifcat\relax\noexpand#2 \def\@tempa{#2} @@ -267,8 +317,8 @@ \ifmmode \expandafter\@tempa \else - \leavevmode\M@HModeError#1% - \expandafter$\expandafter\@tempa + \M@HModeError#1% + \leavevmode\expandafter$\expandafter\@tempa \fi} \def\process@tokens#1#2{\@tfor\@k:=#1\do{\csname M@#2@\@k\endcsname}} \def\define@bb{% @@ -442,7 +492,7 @@ \edef\M@symbols{M\@symbolsshape\the\M@count} \DeclareMathSymbol{.}{\mathord}{\M@symbols}{"2E} \DeclareMathSymbol{@}{\mathord}{\M@symbols}{"40} - \DeclareMathSymbol{\mathpound}{\mathord}{\M@symbols}{"23} + \DeclareMathSymbol{\mathhash}{\mathord}{\M@symbols}{"23} \DeclareMathSymbol{\mathdollar}{\mathord}{\M@symbols}{"24} \DeclareMathSymbol{\mathpercent}{\mathord}{\M@symbols}{"25} \DeclareMathSymbol{\mathand}{\mathord}{\M@symbols}{"26} @@ -458,6 +508,7 @@ \DeclareMathSymbol{\Delta}{\mathord}{\M@symbols}{"2206} \DeclareMathSymbol{'}{\mathord}{\M@symbols}{"2032} \DeclareMathSymbol{"}{\mathord}{\M@symbols}{"2033} + \DeclareMathSymbol{\comma}{\mathord}{\M@symbols}{"2C} \if@operators \DeclareMathSymbol{\sum}{\mathop}{\M@symbols}{"2211} \DeclareMathSymbol{\prod}{\mathop}{\M@symbols}{"220F} @@ -499,25 +550,10 @@ \DeclareMathSymbol{\colon}{\mathpunct}{\M@symbols}{"3A} \let\mathellipsis\@undefined \DeclareMathSymbol{\mathellipsis}{\mathinner}{\M@symbols}{"2026} - \count@\escapechar - \escapechar\m@ne - \edef\#{\noexpand\protect - \expandafter\noexpand\csname\string\# \endcsname} - \expandafter\def\csname\string\# \endcsname{\ifmmode - \mathpound\else\char"23\fi} - \edef\${\noexpand\protect - \expandafter\noexpand\csname\string\$ \endcsname} - \expandafter\def\csname\string\$ \endcsname{\ifmmode - \mathdollar\else\char"24\fi} - \edef\%{\noexpand\protect - \expandafter\noexpand\csname\string\% \endcsname} - \expandafter\def\csname\string\% \endcsname{\ifmmode - \mathpercent\else\char"25\fi} - \edef\&{\noexpand\protect - \expandafter\noexpand\csname\string\& \endcsname} - \expandafter\def\csname\string\& \endcsname{\ifmmode - \mathand\else\char"26\fi} - \escapechar\count@ + \DeclareRobustCommand\#{\ifmmode\mathhash\else\char"23\fi} + \DeclareRobustCommand\${\ifmmode\mathdollar\else\char"24\fi} + \DeclareRobustCommand\%{\ifmmode\mathpercent\else\char"25\fi} + \DeclareRobustCommand\&{\ifmmode\mathand\else\char"26\fi} \DeclareMathSymbol{\@relbar}{\mathbin}{symbols}{"00} \DeclareMathSymbol{\@Relbar}{\mathrel}{operators}{"3D} \DeclareMathSymbol{\@verticalbar}{\mathord}{symbols}{"6A} @@ -526,8 +562,7 @@ \DeclareRobustCommand\models{\mathrel{\@verticalbar}\joinrel\Relbar}} \def\M@operator@set{% \edef\operator@font{\noexpand\mathgroup - \expandafter\noexpand - \csname symM\@operatorshape\the\M@count\endcsname}} + \expandafter\noexpand\csname symM\@operatorshape\the\M@count\endcsname}} \def\M@bb@set{% \edef\M@bb{M\@bbshape\the\M@count} \DeclareMathSymbol{\M@bb@A}{\mathord}{\M@bb}{"1D538} |