diff options
author | Karl Berry <karl@freefriends.org> | 2023-01-28 21:06:35 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-01-28 21:06:35 +0000 |
commit | d0f36fadec57f074d0303a9f12ffec97377bf1d1 (patch) | |
tree | e21ced6599c70cfe339d28714c5b8156134f2434 /Master | |
parent | 4d78187b0ebd2ca024d2e9ae9c5e82c39eea3912 (diff) |
fixdif (28jan23)
git-svn-id: svn://tug.org/texlive/trunk@65658 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.pdf | bin | 163584 -> 159497 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.tex | 75 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/fixdif/fixdif.pdf | bin | 97610 -> 92154 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/fixdif/fixdif.dtx | 191 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/fixdif/fixdif.sty | 92 |
5 files changed, 159 insertions, 199 deletions
diff --git a/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.pdf b/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.pdf Binary files differindex 576280efef9..079be1bc7f7 100644 --- a/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.pdf +++ b/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.pdf diff --git a/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.tex b/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.tex index 4c4793742d5..851065ebc8f 100644 --- a/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.tex +++ b/Master/texmf-dist/doc/latex/fixdif/fixdif-zh-cn.tex @@ -1,10 +1,12 @@ \documentclass[letterpaper,11pt]{article} -\date{2023/01/27\quad Version 1.6% +\usepackage{fixdif} +\date{2023/01/31\quad Version 2.0% \thanks{源代码见~\hyperref{https://github.com/AlphaZTX/fixdif}{}{}{GitHub} 或~\hyperref{https://www.ctan.org/pkg/fixdif}{}{}{CTAN}。} } \ifcsname XeTeXversion\endcsname\else\errmessage{本文档需使用 xelatex 编译}\fi -\usepackage{indentfirst,enumitem} +\usepackage{indentfirst,enumitem,multicol} +\columnsep20pt\columnseprule.4pt \usepackage{manfnt,marginnote} \newcounter{fixdifattention} \newcommand\attention[1][1]{\setcounter{fixdifattention}{1}% @@ -27,8 +29,8 @@ \renewcommand\abstractname{摘\hskip.8em 要} \renewcommand\contentsname{目\hskip.8em 录} \DeclareRobustCommand\zhemph{\CJKunderdot} -\usepackage{unicode-math} -\setmathfont{STIX Two Math} +%\usepackage{unicode-math} +%\setmathfont{STIX Two Math} \usepackage{hyperref} \hypersetup{pdffitwindow, pdftitle = {fixdif 宏包}, @@ -71,7 +73,6 @@ \gdef\@author{\Uchar"5F20\Uchar"5EAD\Uchar"7444} \makeatother \pagestyle{plain} -\usepackage{fixdif} \linespread{1.2} \parskip8pt plus 4pt minus 2pt \parindent2em @@ -87,14 +88,18 @@ 本宏包在 \xelatex{} 和 \lualatex{} 下兼容 \pkg{unicode-math} 宏包。 \end{abstract} -{\parskip0pt\tableofcontents} +\section*{\contentsname} +\begin{multicols}{2} +\parskip0pt +\csname @starttoc\endcsname{toc} +\end{multicols} \section{背景} 我们一般更推荐在微分算符与前面的内容之间留出一个比较小的间距\footnote{% 见 \hyperref{https://tex.stackexchange.com/questions/14821/whats-the-% proper-way-to-typeset-a-differential-operator}{}{}{\TeX.SX}。},比如在下面展示的 两种情况中,右边的比左边的更好: -\[f(x)\mathrm{d}x\qquad\text{\&}\qquad f(x)\d x.\] +\[f(x)\mathrm{d}x \qquad\hbox{\&}\qquad f(x)\d x.\] 微分算符 $\d{}$ 与其前面的表达式之间的间距可认为是乘积的一种表示。 有些用户习惯使用下面的方法定义一个宏: @@ -191,41 +196,16 @@ texhash 会得到 \[f(x)\d x,\quad \frac{\d y}{\d x},\quad \d y/\d x,\quad a^{y\d x}.\] -\subsection{对 \pkg{unicode-math} 宏包的兼容} -如果你在文档中使用了 \pkg{unicode-math} 宏包(编译方式为 \xelatex{} 或 -\lualatex{}),需注意以下几点: -\begin{itemize} -\item 如需使用 \pkg{amsmath} 宏包,请在 \pkg{unicode-math} \zhemph{之前}% -载入 \pkg{amsmath}。 - -\item 在载入 \pkg{unicode-math} 后通过 \cs{setmathfont} 指定数学字体。 -若使用默认的数学字体,建议显式指明 |\setmathfont{Latin Modern Math}|, -这样可以避免在用斜杠表示的分式中产生不好的间距; - -\item \pkg{fixdif} 宏包需要在 \pkg{unicode-math} 宏包\zhemph{后}载入。 -\end{itemize} -从而,导言区正确的顺序是: -\begin{Verbatim} -\usepackage[..]{amsmath} -\usepackage[..]{unicode-math} -\setmathfont{...}[...] -\usepackage{fixdif} -\end{Verbatim} - -\subsection{对 \pkg{hyperref} 宏包的兼容} -如果你使用了 \pkg{hyperref} 宏包,需注意 \pkg{fixdif} 宏包需要在 \pkg{hyperref} -之后载入,否则会引起冲突。 - -\subsection{基本命令及宏包选项} -\DescribeMacro{\d} -\pkg{fixdif} 宏包提供了 \cs{d} 命令用于在数学模式中得到微分算符“$\d{}$”。 +\subsection{基本的 \cs{d} 命令} +\DescribeMacro{\d}% +\pkg{fixdif} 宏包提供了 \cs{d} 命令用于在数学模式中得到微分算符“$\d$”。 在正文中,\cs{d} 会保留其原有的重音符号的功能。例如: \begin{Verbatim} $\d x$ 和 \d x \end{Verbatim} 以上代码会得到“$\d x$ 和 \d x”。 -\paragraph{设置 \cs{d} 的字体} +\subsection{设置 \cs{d} 的字体} 本宏包提供了两个选项来控制 \cs{d} 的字体,分别为 \opt{rm} 和 \opt{normal}。 其中,\opt{rm} 为默认值,表示 \cs{d} 的字体为罗马体(\cs{mathrm}); \opt{normal} 表示 \cs{d} 的字体为数学模式下的常规体(\cs{mathnormal}), @@ -243,8 +223,8 @@ $\d x$ 和 \d x \end{Verbatim} 在此设置下,正文中的 |\d x| 会得到 $\mathsf{d}x$。 -\paragraph{\cs{partial} 的行为} -\DescribeMacro{\partial} +\subsection{\cs{partial} 的行为} +\DescribeMacro{\partial}% \pkg{fixdif} 宏包将 \cs{partial} 归为微分算符,正文中的 \cs{partial} 前面也会有 自动的间距。例如 |$\partial x\partial y$| 会得到 $\partial x\partial y$。 若不需要将 \cs{partial} 视为微分算符,可以开启 \opt{nopartial} 选项: @@ -310,7 +290,7 @@ $\d x$ 和 \d x \noindent\textcolor{titlecolor}{\cs{newdif}\marg{cmd}\marg{multi-cmd}}% \DescribeMacro{\newdif}\hfill(仅限在导言区使用,后无矫正)\\ \noindent\textcolor{titlecolor}{\cs{newdif*}\marg{cmd}\marg{multi-cmd}}% -\DescribeMacro{\newdif*}\hfill(仅限在导言区使用,后有矫正) +\hfill(仅限在导言区使用,后有矫正) 上面两个命令的第一个参数 \meta{cmd} 是新定义的微分算符命令,第二个参数 \meta{multi-cmd} 是超过一个字(token)的命令组合或字符串。举个例子,在 @@ -331,9 +311,9 @@ $\d x$ 和 \d x \cs{newdif}(\texttt{*}) 会检查第一个参数 \meta{cmd} 是否已经被定义,若 \meta{cmd} 已被定义,则会报错。 -\noindent\textcolor{titlecolor}{\cs{renewdif}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif} -\hfill(仅限在导言区使用,后无矫正)\\ -\noindent\textcolor{titlecolor}{\cs{renewdif*}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif*} +\noindent\textcolor{titlecolor}{\cs{renewdif}\marg{cmd}\marg{multi-cmd}}% +\DescribeMacro{\renewdif}\hfill(仅限在导言区使用,后无矫正)\\ +\noindent\textcolor{titlecolor}{\cs{renewdif*}\marg{cmd}\marg{multi-cmd}}% \hfill(仅限在导言区使用,后有矫正) 这两个命令用于将 \meta{cmd} 重定义为微分算符命令。 @@ -343,7 +323,7 @@ $\d x$ 和 \d x \noindent\textcolor{titlecolor}{\cs{mathdif}\marg{symbol}}% \DescribeMacro{\mathdif}\hfill(仅限在数学模式使用,后无矫正)\\ \noindent\textcolor{titlecolor}{\cs{mathdif*}\marg{symbol}}% -\DescribeMacro{\mathdif*}\hfill(仅限在数学模式使用,后有矫正) +\hfill(仅限在数学模式使用,后有矫正) 如需在正文中少量使用某一数学符号作为微分算符,可以使用上面的两个命令。 例如,\verb|$x\mathdif{\Delta}\psi$| 会得到 $x\mathdif{\Delta}\psi$。 @@ -367,15 +347,6 @@ $\d x$ 和 \d x \begin{Verbatim} \letdif{\laplacian}{Delta} \end{Verbatim} -如果你比较擅长使用 \pkg{xparse} 宏包(2020 年 10 月后已被集成进 \LaTeXe{} 内核) -的接口,你也可以采用下面的方法: -\begin{Verbatim} -\letdif{\nabla}{nabla} -\DeclareDocumentCommand{ \laplacian }{ s }{ - \IfBooleanTF { #1 } { \mathdif{\Delta} } { \nabla^2 } -} -\end{Verbatim} -这样,|\laplacian| 会得到 $\nabla^2$,|\laplacian*| 会得到 $\Delta$。 \paragraph{处理正负号与微分算符之间的间距} 输入 |$-\d x$| 会得到 $-\d x$。如果你不希望在正负号与微分算符之间保留 diff --git a/Master/texmf-dist/doc/latex/fixdif/fixdif.pdf b/Master/texmf-dist/doc/latex/fixdif/fixdif.pdf Binary files differindex c01f1bc78f3..8e80606dd32 100644 --- a/Master/texmf-dist/doc/latex/fixdif/fixdif.pdf +++ b/Master/texmf-dist/doc/latex/fixdif/fixdif.pdf diff --git a/Master/texmf-dist/source/latex/fixdif/fixdif.dtx b/Master/texmf-dist/source/latex/fixdif/fixdif.dtx index c6dfc5a236e..e6f37a330ff 100644 --- a/Master/texmf-dist/source/latex/fixdif/fixdif.dtx +++ b/Master/texmf-dist/source/latex/fixdif/fixdif.dtx @@ -131,7 +131,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. %</internal> % %<*driver> -\ProvidesFile{fixdif.dtx}[2023/01/27 (c) Copyright 2022-2023 by Zhang Tingxuan] +\ProvidesFile{fixdif.dtx}[2023/01/31 (c) Copyright 2022-2023 by Zhang Tingxuan] \documentclass{ltxdoc} \usepackage{xcolor} @@ -150,7 +150,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. \title{The \pkg{fixdif} Package} \author{Zhang Tingxuan} -\date{2023/01/27\quad Version 1.6\thanks{\url{https://github.com/AlphaZTX/fixdif}}} +\date{2023/01/31\quad Version 2.0\thanks{\url{https://github.com/AlphaZTX/fixdif}}} \usepackage{hyperref} \hypersetup{ @@ -188,7 +188,6 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. \g@addto@macro{\UrlBreaks}{\UrlDigits} \ifdefined\Umathcode \usepackage{unicode-math} - \setmathfont{Latin Modern Math} \fi \makeatother @@ -215,7 +214,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % in \XeTeX{} and \LuaTeX. % \end{abstract} % -% \tableofcontents +% {\parskip1pt plus 1pt\tableofcontents} % % \section{The background} % It's usually recommended that one should reserve a small skip between @@ -258,39 +257,14 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % \begin{Verbatim} % \usepackage{fixdif} % \end{Verbatim} -% in the preamble. In your document, +% in the preamble (\pkg{fixdif} allows you to write this line anywhere in the +% preamble since version 2.0). In your document, % \begin{Verbatim} % \[ f(x)\d x,\quad\frac{\d y}{\d x},\quad\d y/\d x,\quad a^{y\d x}. \] % \end{Verbatim} % will produce % \[f(x)\d x,\quad \frac{\d y}{\d x},\quad \d y/\d x,\quad a^{y\d x}.\] % -% \subsection{When using \pkg{unicode-math}} -% If you are using \pkg{unicode-math} package with \XeTeX/\LuaTeX{} -% in your document, you must pay attention to the following items: -% \begin{itemize} -% \item If you want to use \pkg{amsmath} package, make sure that the -% \pkg{unicode-math} package is loaded \emph{after} \pkg{amsmath}. -% -% \item You had better specify the math font through the \cs{setmathfont} -% command provided by \pkg{unicode-math} in order to avoid bad skip in -% text fraction like $\d y/\d x$. -% -% \item Load the \pkg{fixdif} package \emph{after} \pkg{unicode-math}. -% \end{itemize} -% Therefore the correct order is -% \begin{Verbatim} -% \usepackage{amsmath} -% \usepackage{unicode-math} -% \setmathfont{...}[...] -% \usepackage{fixdif} -% \end{Verbatim} -% -% \subsection{When using \pkg{hyperref}} -% If you want to use the \pkg{hyperref} package simultaneously, -% remember to load \pkg{hyperref} \emph{before} the \pkg{fixdif} package, -% otherwise the \pkg{hyperref} package will cause conflicts. -% % \subsection{Basic commands and package options} % \DescribeMacro{\d} % The \pkg{fixdif} package provides a \cs{d} command for the differential @@ -362,7 +336,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % For example, in default, \DescribeMacro{\partialnondif}\cs{partialnondif} % yields the old partial symbol ``$\partialnondif$''. % -% \noindent\textcolor{titlecolor}{\cs{letdif*}\marg{cmd}\marg{csname}}\DescribeMacro{\letdif*} +% \noindent\textcolor{titlecolor}{\cs{letdif*}\marg{cmd}\marg{csname}} % \hfill(preamble only) % % This command is basically the same as \cs{letdif}, but this command will @@ -385,7 +359,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % % \noindent\textcolor{titlecolor}{\cs{newdif}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\newdif} % \hfill(without correction, preamble only)\\ -% \noindent\textcolor{titlecolor}{\cs{newdif*}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\newdif*} +% \noindent\textcolor{titlecolor}{\cs{newdif*}\marg{cmd}\marg{multi-cmd}} % \hfill(with correction, preamble only) % % The first argument of these commands is the newly-defined command; and the @@ -409,7 +383,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % % \noindent\textcolor{titlecolor}{\cs{renewdif}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif} % \hfill(without correction, preamble only)\\ -% \noindent\textcolor{titlecolor}{\cs{renewdif*}\marg{cmd}\marg{multi-cmd}}\DescribeMacro{\renewdif*} +% \noindent\textcolor{titlecolor}{\cs{renewdif*}\marg{cmd}\marg{multi-cmd}} % \hfill(with correction, preamble only) % % These two commands are basically the same as \cs{newdif} and \cs{newdif*}. @@ -421,7 +395,7 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % % \noindent\textcolor{titlecolor}{\cs{mathdif}\marg{symbol}}\DescribeMacro{\mathdif} % \hfill(without correction, in math mode only)\\ -%\noindent\textcolor{titlecolor}{\cs{mathdif*}\marg{symbol}}\DescribeMacro{\mathdif*} +%\noindent\textcolor{titlecolor}{\cs{mathdif*}\marg{symbol}} % \hfill(with correction, in math mode only) % % These two commands can be used in math mode only, more specifically, @@ -473,62 +447,68 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % Check the \TeX{} format and provides the package name. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fixdif}[2023/01/27 Interface for defining differential operators.] +\ProvidesPackage{fixdif}[2023/01/31 Interface for defining differential operators.] % \end{macrocode} % % \subsection{Control the skip between slashes and differential operator} % Change the math code of slash ($/$) and backslash ($\backslash$) so that the skip % between slashes and differential operators can be ignored. -% \begin{macrocode} -\@ifpackageloaded{unicode-math}{\AtBeginDocument{% -% \end{macrocode} -% If the \pkg{unicode-math} package has been loaded, use the \XeTeX/\LuaTeX{} primitive +% +% If the \pkg{unicode-math} package was loaded, use the \XeTeX/\LuaTeX{} primitive % \cs{Umathcode} to change the type of slashes. The numeral ``4'' stands for ``open''. +% If \pkg{unicode-math} was not loaded but \pkg{fontspec} loaded, check if +% \pkg{fontspec} had reset math fonts, that is to say, the |no-math| option. % \begin{macrocode} - \Umathcode`\/="4 \symoperators "002F - \Umathcode"2044="4 \symoperators "2044 - \Umathcode"2215="4 \symoperators "2215 - \Umathcode"2F98="4 \symoperators "2F98 - \Umathcode`\\="4 \symoperators "005C - \Umathcode"2216="4 \symoperators "2216 - \Umathcode"29F5="4 \symoperators "29F5 - \Umathcode"29F9="4 \symoperators "29F9 -}}{ +\AtBeginDocument{% +\ifcsname symbf\endcsname% + \csname bool_if:cF\endcsname{g__um_main_font_defined_bool}% + {\csname __um_load_lm:\endcsname}% + \Umathcode`\/="4 \symoperators "002F% + \Umathcode"2044="4 \symoperators "2044% + \Umathcode"2215="4 \symoperators "2215% + \Umathcode"2F98="4 \symoperators "2F98% + \Umathcode`\\="4 \symoperators "005C% + \Umathcode"2216="4 \symoperators "2216% + \Umathcode"29F5="4 \symoperators "29F5% + \Umathcode"29F9="4 \symoperators "29F9% +\else\ifcsname fontspec\endcsname + \csname bool_if:cT\endcsname{g__fontspec_math_bool}% + {% + \everymath{\mathcode`\/="413D\relax}% + \PackageWarning{fixdif}{Requires `no-math' option of fontspec!\MessageBreak}% + }% fontspec only influences "/" +\fi\fi} % \end{macrocode} -% If the \pkg{unicode-math} package has not been loaded, use the \TeX{} primitive -% \cs{mathcode} to change the type of slashes. The \cs{backslash} needs to be redefined -% through \cs{delimiter} primitive too. +% Use \cs{mathcode} to change the type of slashes. The \cs{backslash} needs to be +% redefined through \cs{delimiter} too. % \begin{macrocode} - \mathcode`\/="413D - \mathcode`\\="426E % \backslash - \def\backslash{\delimiter"426E30F\relax} -} +\mathcode`\/="413D +\mathcode`\\="426E% \backslash +\protected\def\backslash{\delimiter"426E30F\relax} % \end{macrocode} % % \subsection{Patch the skips around the differential operator} -% \DescribeMacro{\mup@tch} -% The following \cs{mup@tch} patches the skip after the differential operator. +% \DescribeMacro{\fd@mu@p} +% The following \cs{fd@mu@p} patches the skip after the differential operator. % \begin{macrocode} -\def\mup@tch{\mathchoice{\mskip-\thinmuskip}{\mskip-\thinmuskip}{}{}{}} +\def\fd@mu@p{\mathchoice{\mskip-\thinmuskip}{\mskip-\thinmuskip}{}{}{}} % \end{macrocode} -% The \cs{s@beforep@tch} patches the commands with star (\cs{letdif*}, etc). +% The \cs{s@fd@mu@p} patches the commands with star (\cs{letdif*}, etc). % \begin{macrocode} -\def\s@beforep@tch{\mathchoice{}{}{\mbox{}}{\mbox{}}} +\def\s@fd@mu@p{\mathchoice{}{}{\hbox{}}{\hbox{}}} % \end{macrocode} % % \subsection{Declare the package options} -% Declare the options of the package and execute them. % \begin{macrocode} -\DeclareOption{rm}{\@ifpackageloaded{unicode-math} - {\def\@@dif{\symrm{d}}}{\def\@@dif{\mathrm{d}}}} -\DeclareOption{normal}{\def\@@dif{d}} +\DeclareOption{rm}{% + \AtBeginDocument{\ifcsname symbf\endcsname% + \gdef\@fd@dif{\symrm{d}}\fi}% + \gdef\@fd@dif{\mathrm{d}}} +\DeclareOption{normal}{\gdef\@fd@dif{d}} \DeclareOption{partial}{\@tempswatrue} \DeclareOption{nopartial}{\@tempswafalse} \ExecuteOptions{rm,partial} \ProcessOptions\relax -% \end{macrocode} -% Control the behavior of \cs{partial}. -% \begin{macrocode} \if@tempswa \AtEndOfPackage{\letdif{\partial}{partial}} \fi @@ -536,47 +516,41 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. % \DescribeMacro{\resetdfont} % Define the \cs{resetdfont} command. % \begin{macrocode} -\gdef\resetdfont#1{\let\@@dif\relax% - \def\@@dif{#1{d}}} +\gdef\resetdfont#1{\AtBeginDocument{\let\@fd@dif\relax\gdef\@fd@dif{#1{d}}}} % \end{macrocode} % % \subsection{Deal with the \cs{d} command} -% \DescribeMacro{\@dif} -% \cs{@dif} is the differential operator produced by \cs{d} in math mode. +% \DescribeMacro{\fd@dif} +% \cs{fd@dif} is the differential operator produced by \cs{d} in math mode. % Here we prefer \cs{mathinner} to |\mathbin| to make the skip. % \begin{macrocode} -\def\@dif{\mathinner{\@@dif}\mup@tch} +\def\fd@dif{\mathinner{\@fd@dif}\fd@mu@p} % \end{macrocode} -% \DescribeMacro{\d@accent} -% Restore the \cs{d} command in text by \cs{d@accent} with the \cs{let} -% primitive. +% \DescribeMacro{\fd@d@acc} +% Restore the \cs{d} command in text by \cs{fd@d@acc} with \cs{let}. % \begin{macrocode} -\AtBeginDocument{\let\d@accent\d +\AtBeginDocument{\let\fd@d@acc\d % \end{macrocode} % \DescribeMacro{\d} % Redefine the \cs{d} command. In text, we need to expand the stuffs after \cs{d} % \begin{macrocode} - \DeclareRobustCommand\d{\ifmmode\@dif\else\expandafter\d@accent\fi}} + \DeclareRobustCommand\d{\ifmmode\fd@dif\else\expandafter\fd@d@acc\fi}} % \end{macrocode} % % \subsection{User's interface for defining new differential operators} -% \DescribeMacro{\letdif}\DescribeMacro{\letdif*} -% Define the \cs{letdif} and \cs{letdif*} command. The internal version of \cs{letdif} -% is \cs{@letdif}, of \cs{letdif*} is \cs{s@letdif}. -% \begin{macrocode} -\def\@letdif#1#2{\AtBeginDocument{% -% \end{macrocode} +% \DescribeMacro{\letdif} +% Define the \cs{letdif} command. The internal version of \cs{letdif} +% is \cs{@letdif} and \cs{s@letdif}. +% % |#1| is the final command; |#2| is the ``control sequence name'' of |#1|'s initial definition. % Here we create a command (\cs{csname}|#2nonfif|\cs{endcsname}) to restore |#2|. % \begin{macrocode} +\def\@letdif#1#2{\AtBeginDocument{% \ifcsname #2nondif\endcsname\else% \expandafter\let\csname #2nondif\expandafter\endcsname \csname #2\endcsname% \fi% -% \end{macrocode} -% Finally let |#1| be the new command. -% \begin{macrocode} - \gdef#1{\mathinner{\csname #2nondif\endcsname}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{\csname #2nondif\endcsname}\fd@mu@p}% }} % \end{macrocode} % The definition of \cs{s@letdif} is similar, but with the patch for negative skips. @@ -586,56 +560,59 @@ Copyright (C) 2022-2023 by Zhang Tingxuan <alphaztx@163.com>. \expandafter\let\csname #2nondif\expandafter\endcsname \csname #2\endcsname% \fi% - \gdef#1{\mathinner{\s@beforep@tch\csname #2nondif\endcsname\hbox{}}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{\s@fd@mu@p\csname #2nondif\endcsname\hbox{}}\fd@mu@p}% }} -\def\letdif{\@ifstar\s@letdif\@letdif} +\DeclareRobustCommand\letdif{\@ifstar\s@letdif\@letdif} +\@onlypreamble\letdif % \end{macrocode} -% \DescribeMacro{\newdif}\DescribeMacro{\newdif*} -% Define the \cs{newdif} and \cs{newdif*} commands. |#1| is the final command; |#2| is the ``long'' argument. +% \DescribeMacro{\newdif} +% Define the \cs{newdif} command. |#1| is the final command; |#2| is the ``long'' argument. % \begin{macrocode} \long\def\@newdif#1#2{\AtBeginDocument{% \ifdefined#1 - \PackageError{fixdif}{\string#1 is already defined.} + \PackageError{fixdif}{\string#1 is already defined} {Try another command instead of \string#1.}% \else - \long\gdef#1{\mathinner{#2}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}% \fi% }} \long\def\s@newdif#1#2{\AtBeginDocument{% \ifdefined#1 - \PackageError{fixdif}{\string#1 is already defined.} + \PackageError{fixdif}{\string#1 is already defined} {Try another command instead of \string#1.}% \else - \long\gdef#1{\s@beforep@tch\mathinner{#2\mbox{}}\mup@tch}% + \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}% \fi% }} -\def\newdif{\@ifstar\s@newdif\@newdif} +\DeclareRobustCommand\newdif{\@ifstar\s@newdif\@newdif} +\@onlypreamble\newdif % \end{macrocode} -% \DescribeMacro{\renewdif}\DescribeMacro{\renewdif*} -% Define the \cs{renewdif} and \cs{renewdif*} commands. +% \DescribeMacro{\renewdif} +% Define the \cs{renewdif} command. % \begin{macrocode} \long\def\@renewdif#1#2{\AtBeginDocument{% \ifdefined#1 - \long\gdef#1{\mathinner{#2}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}% \else - \PackageError{fixdif}{\string#1 has not been defined yet.} + \PackageError{fixdif}{\string#1 has not been defined yet} {You should use \string\newdif instead of \string\renewdif.}% \fi% }} \long\def\s@renewdif#1#2{\AtBeginDocument{% \ifdefined#1 - \long\gdef#1{\s@beforep@tch\mathinner{#2\mbox{}}\mup@tch}% + \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}% \else - \PackageError{fixdif}{\string#1 has not been defined yet.} + \PackageError{fixdif}{\string#1 has not been defined yet} {You should use \string\newdif instead of \string\renewdif.}% \fi% }} -\def\renewdif{\@ifstar\s@renewdif\@renewdif} +\DeclareRobustCommand\renewdif{\@ifstar\s@renewdif\@renewdif} +\@onlypreamble\renewdif % \end{macrocode} -% \subsection{In-document commands: \cs{mathdif} and \cs{mathdif*}} +% \subsection{In-document commands: \cs{mathdif}} % \begin{macrocode} -\def\@mathdif#1{\mathinner{#1}\mup@tch} -\def\s@mathdif#1{\s@beforep@tch\mathinner{#1\mbox{}}\mup@tch} +\def\@mathdif#1{\mathinner{#1}\fd@mu@p} +\def\s@mathdif#1{\s@fd@mu@p\mathinner{#1\mbox{}}\fd@mu@p} \DeclareRobustCommand\mathdif{\@ifstar\s@mathdif\@mathdif} % \end{macrocode} % End of the package. diff --git a/Master/texmf-dist/tex/latex/fixdif/fixdif.sty b/Master/texmf-dist/tex/latex/fixdif/fixdif.sty index 1ee4651fd98..3d2cc4f208a 100644 --- a/Master/texmf-dist/tex/latex/fixdif/fixdif.sty +++ b/Master/texmf-dist/tex/latex/fixdif/fixdif.sty @@ -29,26 +29,36 @@ %% and README.md. %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{fixdif}[2023/01/27 Interface for defining differential operators.] -\@ifpackageloaded{unicode-math}{\AtBeginDocument{% - \Umathcode`\/="4 \symoperators "002F - \Umathcode"2044="4 \symoperators "2044 - \Umathcode"2215="4 \symoperators "2215 - \Umathcode"2F98="4 \symoperators "2F98 - \Umathcode`\\="4 \symoperators "005C - \Umathcode"2216="4 \symoperators "2216 - \Umathcode"29F5="4 \symoperators "29F5 - \Umathcode"29F9="4 \symoperators "29F9 -}}{ - \mathcode`\/="413D - \mathcode`\\="426E % \backslash - \def\backslash{\delimiter"426E30F\relax} -} -\def\mup@tch{\mathchoice{\mskip-\thinmuskip}{\mskip-\thinmuskip}{}{}{}} -\def\s@beforep@tch{\mathchoice{}{}{\mbox{}}{\mbox{}}} -\DeclareOption{rm}{\@ifpackageloaded{unicode-math} - {\def\@@dif{\symrm{d}}}{\def\@@dif{\mathrm{d}}}} -\DeclareOption{normal}{\def\@@dif{d}} +\ProvidesPackage{fixdif}[2023/01/31 Interface for defining differential operators.] +\AtBeginDocument{% +\ifcsname symbf\endcsname% + \csname bool_if:cF\endcsname{g__um_main_font_defined_bool}% + {\csname __um_load_lm:\endcsname}% + \Umathcode`\/="4 \symoperators "002F% + \Umathcode"2044="4 \symoperators "2044% + \Umathcode"2215="4 \symoperators "2215% + \Umathcode"2F98="4 \symoperators "2F98% + \Umathcode`\\="4 \symoperators "005C% + \Umathcode"2216="4 \symoperators "2216% + \Umathcode"29F5="4 \symoperators "29F5% + \Umathcode"29F9="4 \symoperators "29F9% +\else\ifcsname fontspec\endcsname + \csname bool_if:cT\endcsname{g__fontspec_math_bool}% + {% + \everymath{\mathcode`\/="413D\relax}% + \PackageWarning{fixdif}{Requires `no-math' option of fontspec!\MessageBreak}% + }% fontspec only influences "/" +\fi\fi} +\mathcode`\/="413D +\mathcode`\\="426E% \backslash +\protected\def\backslash{\delimiter"426E30F\relax} +\def\fd@mu@p{\mathchoice{\mskip-\thinmuskip}{\mskip-\thinmuskip}{}{}{}} +\def\s@fd@mu@p{\mathchoice{}{}{\hbox{}}{\hbox{}}} +\DeclareOption{rm}{% + \AtBeginDocument{\ifcsname symbf\endcsname% + \gdef\@fd@dif{\symrm{d}}\fi}% + \gdef\@fd@dif{\mathrm{d}}} +\DeclareOption{normal}{\gdef\@fd@dif{d}} \DeclareOption{partial}{\@tempswatrue} \DeclareOption{nopartial}{\@tempswafalse} \ExecuteOptions{rm,partial} @@ -56,62 +66,64 @@ \if@tempswa \AtEndOfPackage{\letdif{\partial}{partial}} \fi -\gdef\resetdfont#1{\let\@@dif\relax% - \def\@@dif{#1{d}}} -\def\@dif{\mathinner{\@@dif}\mup@tch} -\AtBeginDocument{\let\d@accent\d - \DeclareRobustCommand\d{\ifmmode\@dif\else\expandafter\d@accent\fi}} +\gdef\resetdfont#1{\AtBeginDocument{\let\@fd@dif\relax\gdef\@fd@dif{#1{d}}}} +\def\fd@dif{\mathinner{\@fd@dif}\fd@mu@p} +\AtBeginDocument{\let\fd@d@acc\d + \DeclareRobustCommand\d{\ifmmode\fd@dif\else\expandafter\fd@d@acc\fi}} \def\@letdif#1#2{\AtBeginDocument{% \ifcsname #2nondif\endcsname\else% \expandafter\let\csname #2nondif\expandafter\endcsname \csname #2\endcsname% \fi% - \gdef#1{\mathinner{\csname #2nondif\endcsname}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{\csname #2nondif\endcsname}\fd@mu@p}% }} \def\s@letdif#1#2{\AtBeginDocument{% \ifcsname #2nondif\endcsname\else% \expandafter\let\csname #2nondif\expandafter\endcsname \csname #2\endcsname% \fi% - \gdef#1{\mathinner{\s@beforep@tch\csname #2nondif\endcsname\hbox{}}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{\s@fd@mu@p\csname #2nondif\endcsname\hbox{}}\fd@mu@p}% }} -\def\letdif{\@ifstar\s@letdif\@letdif} +\DeclareRobustCommand\letdif{\@ifstar\s@letdif\@letdif} +\@onlypreamble\letdif \long\def\@newdif#1#2{\AtBeginDocument{% \ifdefined#1 - \PackageError{fixdif}{\string#1 is already defined.} + \PackageError{fixdif}{\string#1 is already defined} {Try another command instead of \string#1.}% \else - \long\gdef#1{\mathinner{#2}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}% \fi% }} \long\def\s@newdif#1#2{\AtBeginDocument{% \ifdefined#1 - \PackageError{fixdif}{\string#1 is already defined.} + \PackageError{fixdif}{\string#1 is already defined} {Try another command instead of \string#1.}% \else - \long\gdef#1{\s@beforep@tch\mathinner{#2\mbox{}}\mup@tch}% + \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}% \fi% }} -\def\newdif{\@ifstar\s@newdif\@newdif} +\DeclareRobustCommand\newdif{\@ifstar\s@newdif\@newdif} +\@onlypreamble\newdif \long\def\@renewdif#1#2{\AtBeginDocument{% \ifdefined#1 - \long\gdef#1{\mathinner{#2}\mup@tch}% + \DeclareRobustCommand#1{\mathinner{#2}\fd@mu@p}% \else - \PackageError{fixdif}{\string#1 has not been defined yet.} + \PackageError{fixdif}{\string#1 has not been defined yet} {You should use \string\newdif instead of \string\renewdif.}% \fi% }} \long\def\s@renewdif#1#2{\AtBeginDocument{% \ifdefined#1 - \long\gdef#1{\s@beforep@tch\mathinner{#2\mbox{}}\mup@tch}% + \DeclareRobustCommand#1{\s@fd@mu@p\mathinner{#2\hbox{}}\fd@mu@p}% \else - \PackageError{fixdif}{\string#1 has not been defined yet.} + \PackageError{fixdif}{\string#1 has not been defined yet} {You should use \string\newdif instead of \string\renewdif.}% \fi% }} -\def\renewdif{\@ifstar\s@renewdif\@renewdif} -\def\@mathdif#1{\mathinner{#1}\mup@tch} -\def\s@mathdif#1{\s@beforep@tch\mathinner{#1\mbox{}}\mup@tch} +\DeclareRobustCommand\renewdif{\@ifstar\s@renewdif\@renewdif} +\@onlypreamble\renewdif +\def\@mathdif#1{\mathinner{#1}\fd@mu@p} +\def\s@mathdif#1{\s@fd@mu@p\mathinner{#1\mbox{}}\fd@mu@p} \DeclareRobustCommand\mathdif{\@ifstar\s@mathdif\@mathdif} \endinput %% |