我想知道如何告诉bm
包裹\mathversion
。使用以下示例使用 \DeclareMathVersion
\documentclass{article}
%%% text fonts
\renewcommand\rmdefault{txr}
\newcommand\gmfamily{\fontfamily{mdugm}\selectfont}
%%% New math versions
\DeclareMathVersion{varnormal}
\DeclareMathVersion{varbold}
\newcommand\txmath{\mathversion{normal}}
\newcommand\txboldmath{\mathversion{bold}}
\newcommand\mdmath{\mathversion{varnormal}}
\newcommand\mdboldmath{\mathversion{varbold}}
%%% Math symbol fonts
%%% some examples only
% Math letters from txfonts and mdugm
\SetSymbolFont{letters}{normal}{OML}{txmi}{m}{it}
\SetSymbolFont{letters}{bold}{OML}{txmi}{bx}{it}
\SetSymbolFont{letters}{varnormal}{OML}{mdugm}{m}{it}
\SetSymbolFont{letters}{varbold}{OML}{mdugm}{b}{it}
% Math operators
\SetSymbolFont{operators}{normal}{OT1}{txr}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{txr}{bx}{n}
\SetSymbolFont{operators}{varnormal}{OT1}{mdugm}{m}{n}
\SetSymbolFont{operators}{varbold}{OT1}{mdugm}{b}{n}
% Math symbols
\SetSymbolFont{symbols}{normal}{OMS}{txsy}{m}{n}
\SetSymbolFont{symbols}{bold}{OMS}{txsy}{bx}{n}
\SetSymbolFont{symbols}{varnormal}{OMS}{mdugm}{m}{n}
\SetSymbolFont{symbols}{varbold}{OMS}{mdugm}{b}{n}
% Large symbols
\SetSymbolFont{largesymbols}{normal}{OMX}{txex}{m}{n}
\SetSymbolFont{largesymbols}{bold}{OMX}{txex}{bx}{n}
\SetSymbolFont{largesymbols}{varnormal}{OMX}{mdugm}{m}{n}
\SetSymbolFont{largesymbols}{varbold}{OMX}{mdugm}{b}{n}
%%% Math alphabets, at most 16 families
%%% some examples only
\SetMathAlphabet{\mathrm}{normal}{OT1}{txr}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{OT1}{txr}{bx}{n}
\SetMathAlphabet{\mathrm}{varnormal}{OT1}{mdugm}{m}{n}
\SetMathAlphabet{\mathrm}{varbold}{OT1}{mdugm}{b}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{txr}{m}{it}
\SetMathAlphabet{\mathit}{bold}{OT1}{txr}{bx}{it}
\SetMathAlphabet{\mathit}{varnormal}{OT1}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{varbold}{OT1}{mdugm}{b}{it}
\usepackage{bm}
\begin{document}
This is Times font. $a^2 + b^2 = c^2$. Math font
\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]
and bold math font
{\txboldmath\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]}
\[
\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\gmfamily\mdmath
This is Garamond font. $a^2 + b^2 = c^2$. Math font
\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]
and bold math font
{\mdboldmath\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]}
\[
\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\end{document}
我希望告诉\mdmath
包\bm
在哪里可以找到当前字体的粗体变体(而不是使用bold
拾取 Times)。
答案1
知道这一点:我不知道自己在做什么......
买者自负...
这使用骨髓用于管理 Times 和变量用于管理 Garamond 粗体字体的软件包。varbm.sty
与 类似,只是bm.sty
它适用于varbold
数学版本而不是版本。但是,它不包含与 中的数学bold
支持相对应的任何内容。heavy
bm.sty
首先举个例子:
\documentclass{article}
%% text fonts
\renewcommand\rmdefault{txr}
\newcommand\gmfamily{\fontfamily{mdugm}\selectfont}
%% New math versions
\DeclareMathVersion{varnormal}
\DeclareMathVersion{varbold}
\makeatletter
\newif\iftx@math
\newif\ifmd@math
\newcommand\txmath{%
\mathversion{normal}%
\ifmd@math
\global\let\bm\oldbm
\fi
\tx@mathtrue
\md@mathfalse
\global\let\oldvarbm\varbm
\global\let\varbm\bm}
\newcommand\mdmath{%
\mathversion{varnormal}%
\iftx@math
\global\let\varbm\oldvarbm
\fi
\md@mathtrue
\tx@mathfalse
\global\let\oldbm\bm
\global\let\bm\varbm}
\AtBeginDocument{\txmath}
\makeatother
\newcommand\varboldmath{\mathversion{varbold}}
% these commands should not be needed and are here just for comparison
\newcommand\txboldmath{\mathversion{bold}}
\newcommand\mdboldmath{\mathversion{varbold}}
%% Math symbol fonts
%% some examples only
%% Math letters from txfonts and mdugm
\SetSymbolFont{letters}{normal}{OML}{txmi}{m}{it}
\SetSymbolFont{letters}{bold}{OML}{txmi}{bx}{it}
\SetSymbolFont{letters}{varnormal}{OML}{mdugm}{m}{it}
\SetSymbolFont{letters}{varbold}{OML}{mdugm}{b}{it}
%% Math operators
\SetSymbolFont{operators}{normal}{OT1}{txr}{m}{n}
\SetSymbolFont{operators}{bold}{OT1}{txr}{bx}{n}
\SetSymbolFont{operators}{varnormal}{OT1}{mdugm}{m}{n}
\SetSymbolFont{operators}{varbold}{OT1}{mdugm}{b}{n}
%% Math symbols
\SetSymbolFont{symbols}{normal}{OMS}{txsy}{m}{n}
\SetSymbolFont{symbols}{bold}{OMS}{txsy}{bx}{n}
\SetSymbolFont{symbols}{varnormal}{OMS}{mdugm}{m}{n}
\SetSymbolFont{symbols}{varbold}{OMS}{mdugm}{b}{n}
%% Large symbols
\SetSymbolFont{largesymbols}{normal}{OMX}{txex}{m}{n}
\SetSymbolFont{largesymbols}{bold}{OMX}{txex}{bx}{n}
\SetSymbolFont{largesymbols}{varnormal}{OMX}{mdugm}{m}{n}
\SetSymbolFont{largesymbols}{varbold}{OMX}{mdugm}{b}{n}
%% Math alphabets, at most 16 families
%% some examples only
\SetMathAlphabet{\mathrm}{normal}{OT1}{txr}{m}{n}
\SetMathAlphabet{\mathrm}{bold}{OT1}{txr}{bx}{n}
\SetMathAlphabet{\mathrm}{varnormal}{OT1}{mdugm}{m}{n}
\SetMathAlphabet{\mathrm}{varbold}{OT1}{mdugm}{b}{n}
\SetMathAlphabet{\mathit}{normal}{OT1}{txr}{m}{it}
\SetMathAlphabet{\mathit}{bold}{OT1}{txr}{bx}{it}
\SetMathAlphabet{\mathit}{varnormal}{OT1}{mdugm}{m}{it}
\SetMathAlphabet{\mathit}{varbold}{OT1}{mdugm}{b}{it}
\usepackage{bm,varbm}
\begin{document}
This is Times font. $a^2 + b^2 = c^2$. Math font
\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]
and bold math font
{\txboldmath\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]}
\[
\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\[
\varbm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\gmfamily\mdmath
This is Garamond font. $a^2 + b^2 = c^2$. Math font
\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]
and bold math font
{\mdboldmath\[
\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0
\]}
\[
\bm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\[
\varbm{\sum_i \int_a^b \left( \frac1{K+1} \oplus\alpha_i \right) \,\mathrm{d}x = 0}
\]
\end{document}
当默认启用 Times 数学或使用 时\txmath
,会发生以下情况:
normal
使用数学版本;\bm
使用时间bold
数学;\varbm
使用时代bold
数学。
当使用 激活 Garamond 数学时\mdmath
,会发生以下情况:
varnormal
使用数学版本;\bm
使用 Garamondvarbold
数学;\varbm
使用 Garamondvarbold
数学。
包代码(所有合法的东西只是因为我复制了文件bm.sty
并做了一些查找和替换,删除了几行并进行了测试 - 因此,它是许可条款下的衍生作品,必须这样指定):
%%
%% This is file `varbm.sty',
%%
%% Additions and changes (mostly find and replace)
%% are copyright 2015 Clea F. Rees
%%
%% Code from bm.sty (see below)
%% bm.sty is copyright 1993-2015
%% The LaTeX3 Project and any individual authors listed elsewhere
%% in this file
%% Copyright 1996 1997 1998 1999 2002 2003 2004 David Carlisle Frank Mittelbach
%% Development of the bm package was commissioned by Y&Y Inc.
%% http://www.yandy.com
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Clea F. Rees.
%
% This work consists of the file varbm.sty.
%
% The file varbm.sty is a derived work under the terms of the
% LPPL. It is based on bm.sty dated 2014/10/28 v1.1c which is part of The
% Standard LaTeX `Tools Bundle'. A copy of that work, including the
% unmodified version of bm.sty is available from http://ctan.org/pkg/bm.
%
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{varbm}
[2015/08/02 v0.00001 Variable Bold Symbol Support]
\def\varbm#1#2{%
\let\varbm@pmb\install@mathalphabet
\let\varbm@pmb@\getanddefine@fonts
\let\varbm@pmb@@\or
\edef\varbm@general{\f@encoding/\f@family/\f@series/\f@shape/\f@size}%
\@tempcnta#2%
\count@-\count18%
\advance\count@-\@tempcnta
\advance\count@15\relax
\ifnum\count@<\z@
\advance\@tempcnta\count@
\fi
\let\or\relax
\expandafter\let\csname varbm@#1table\endcsname\@gobble
\def\varbm@define##1{%
\expandafter\xdef\csname varbm@#1table\endcsname{%
\csname varbm@#1table\endcsname\or##1}}%
\def\getanddefine@fonts##1##2{%
\def\@tempa{##2}%
\def\@tempb####1##1####2####3\@nil{\def\@tempb{####2}}%
\expandafter\expandafter\expandafter
\@tempb\csname mv@#1\endcsname\@nil
\ifx\@tempa\@tempb
\varbm@define\m@ne
\else
\edef\@tempa{sym#1\expandafter\@gobblefour\string##1}%
\ifnum\@tempcnta<%
\expandafter\ifx\csname\@tempa\endcsname\relax
\@ne
\else
\m@ne
\fi
\varbm@define\z@
\else
\expandafter\ifx\csname\@tempa\endcsname\relax
\begingroup
\escapechar\m@ne
\edef\@tempb{\endgroup
\noexpand\split@name
\expandafter\string\@tempb}%
\@tempb/\@nil
\expandafter\ifx
\csname symvarbold\expandafter\@gobblefour\string##1\endcsname
\relax
\expandafter\new@mathgroup\csname\@tempa\endcsname
\expandafter\new@symbolfont\csname\@tempa\endcsname
\f@encoding\f@family\f@series\f@shape
\advance\@tempcnta\m@ne
\else
\def\varbm@expand####1##1####2####3\@nil{\def\varbm@expand{####2}}%
\expandafter\expandafter\expandafter
\varbm@expand\csname mv@varbold\endcsname\@nil
\ifx\varbm@expand\@tempb
\expandafter\let\csname\@tempa\expandafter\endcsname
\csname symvarbold\expandafter
\@gobblefour\string##1\endcsname
\else
\expandafter\new@mathgroup\csname\@tempa\endcsname
\expandafter\new@symbolfont\csname\@tempa\endcsname
\f@encoding\f@family\f@series\f@shape
\advance\@tempcnta\m@ne
\fi
\fi
\else
\PackageInfo{varbm}%
{Symbol font \@tempa\space already defined.\MessageBreak
Not overwriting it}%
\fi
\count@\csname\@tempa\endcsname
\advance\count@-##1%
\varbm@define{\the\count@\relax}%
\fi
\fi}%
\let\install@mathalphabet\@gobbletwo
\mv@normal
\expandafter\xdef\csname varbm@#1table\endcsname{%
\noexpand\ifcase\@tempcnta
\csname varbm@#1table\endcsname
\noexpand\else
\z@
\noexpand\fi}%
\expandafter\split@name\varbm@general\@nil
\let\install@mathalphabet\varbm@pmb
\let\getanddefine@fonts\varbm@pmb@
\let\or\varbm@pmb@@}
\ifx\varbmmax\@undefined
\chardef\varbmmax=4
\fi
\ifx\mv@varbold\@undefined
\def\varbm@varboldtable{\m@ne}
\AtEndOfPackage{%
\def\varbm@gr@up#1#2{%
\varbm@pmb{#2}}}
\else
\varbm{varbold}\varbmmax
\@ifundefined{symvarboldoperators}
{}
{\DeclareSymbolFontAlphabet\mathbf{varboldoperators}}
\fi
\begingroup
\catcode`\'=\active
\@firstofone{\endgroup
\def\varbm@general#1#2#3#4#5{%
\begingroup
\let\varbm\@firstofone
\global\let\varbm@command\@empty
\let\@let@token\@empty
\let\protect\@empty
\let\@typeset@protect\@empty
\def\varbm@mathchoice{\varbm@m@thchoice#1}%
\def\varbm@group{\varbm@gr@up#1}%
\let\varbm@table#2%
\let\left\holdinginserts
\let\right\left
\let\mskip\mkern
\let\hskip\kern
\let\varbm@prime\copy
\def'{\varbm@prime\prime\relax}%
\def\@ifnextchar##1##2##3##4{%
\if##1##4%
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{##2##4}{##3{##4}}}%
\def\GenericWarning##1##2{%
\unvcopy{\GenericWarning{##1}{##2}}}%
\def\GenericError##1##2##3##4{%
\unvcopy{\GenericError{##1}{##2}{##3}{##4}}}%
\let\DN@\copy
\let\FN@\copy
\let\next@\copy
\global\let\varbm@first\@empty
\ifx\uproot@\undefined\else
\def\root##1\of##2{{\root##1\of{##2}}}%
\fi
\def\mathaccentV##1{\mathaccent"\accentclass@}%
\let\@ifnext\@ifnextchar
\let\measure@lhs\copy
\let \rel@break\copy
\let \bin@break\copy
\let \after@open\copy
\let \after@close\copy
\let\ifmmode\iftrue
\let\install@mathalphabet\def
\let\getanddefine@fonts\@gobbletwo
#3%
\def\select@group##1##2##3##4{{%
\protect##1{##4}}}%
\def\use@mathgroup##1##2##3{{%
\protect\use@mathgroup##1{##2}{##3}}}%
\varbm@expand#5\varbm@end
\endgroup
#4}
}
\DeclareRobustCommand\varbm{%
\varbm@general\varboldmath\varbm@varboldtable\mv@varbold\varbm@command}
\protected@edef\varbm#1{\varbm{#1}}
\def\DeclareBoldMathCommand{\@testopt\varbm@declare{varbold}}
\def\varbm@declare[#1]#2{%
\expandafter\varbm@general
\csname #1math\expandafter\endcsname
\csname varbm@#1table\expandafter\endcsname
\csname mv@#1\endcsname
{\varbm@define#2}}
\def\varbmdefine{\DeclareBoldMathCommand[varbold]}
\outer\def\varbm@end{\@@end}
\def\varbm@expand{\afterassignment\varbm@exp@nd\count@`\a}
\def\varbm@exp@nd{\afterassignment\varbm@test\count@`\a}
\def\varbm@test{%
\let\varbm@previous\@let@token
\futurelet\@let@token\varbm@test@}
\def\varbm@test@{%
\ifx\@let@token\bgroup
\expandafter\varbm@group
\else
\expandafter\varbm@test@token
\fi}
\def\varbm@gr@up#1#2{%
\varbm@add{{\varbm@gr@@p#1{{#2}}}}}
\def\varbm@gr@@p#1#2{%
\ifmmode
\varbm@mchoice#1{#2}{#2}{#2}{#2}%
\else
\bfseries#1#2%
\fi}
\def\varbm@test@token#1{%
\let\varbm@next\@empty
\ifx#1\@@end
\else\ifx#1\mathchoice
\let\varbm@next\varbm@mathchoice
\else\ifx#1\mathchar
\afterassignment\varbm@mathchar\count@
\else\ifx#1\mathaccent
\afterassignment\varbm@mathaccent\count@
\else\ifx#1\delimiter
\afterassignment\varbm@delimiter\count@
\else\ifx#1\radical
\afterassignment\varbm@radical\count@
\else\ifx#1\mkern
\varbm@register#1{\muskip\z@}%
\else\ifx#1\kern
\varbm@register#1\skip@
\else\ifx#1\penalty
\varbm@register#1\count@
\else\ifx#1\unvcopy
\let\varbm@next\varbm@add
\else\ifcat\noexpand#1\relax
\xdef\meaning@{\meaning#1}%
\expandafter\varbm@mchar@test\meaning@""\@nil#1%
\else\ifcat.\ifcat a#1.\else#1\fi
\count@\mathcode`#1\relax
\ifnum\count@=\mathcode`\'%
\begingroup\uccode`\~`#1\uppercase{\endgroup
\def\varbm@next{\varbm@expand~}}%
\else
\ifx\varbm@previous\left
\count@\delcode`#1\relax
\varbm@delimiter
\else
\varbm@mathchar
\fi
\fi
\else
\varbm@add{#1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\varbm@next}
\def\varbm@define#1{%
\begingroup
\ifx\varbm@command\@gtempa
\def\mathchar{\global\mathchardef#1}%
\varbm@command
\else
\toks@\expandafter{\varbm@command}%
\xdef#1{\varbm@first\noexpand\varbm@protect\noexpand#1{\the\toks@}}%
\fi
\endgroup}
\def\varbm@protect#1{%
\ifx\protect\@typeset@protect
\expandafter\@firstofone
\else
\protect#1\expandafter\@gobble
\fi}
\def\varbm@mchoice#1#2#3#4#5{%
\mathchoice{\hbox{#1$\displaystyle\m@th#2$}}%
{\hbox{#1$\textstyle\m@th#3$}}%
{\hbox{#1$\scriptstyle\m@th#4$}}%
{\hbox{#1$\scriptscriptstyle\m@th#5$}}}
\def\varbm@m@thchoice#1#2#3#4#5{%
\varbm@add{\varbm@mchoice#1{#2}{#3}{#4}{#5}}}
\def\varbm@register#1#2{%
\def\@tempa{#1\the#2}%
\afterassignment\varbm@r@gister#2}
\def\varbm@r@gister{%
\varbm@xadd{\@tempa\space}}
\def\varbm@mathchar{%
\@tempcntb\count@
\let\@tempa\varbm@group
\varbm@changefam{}%
\ifnum\count@>\@tempcntb
\ifx\varbm@command\@empty
\xdef\@gtempa{\mathchar\the\count@\space}%
\fi
\varbm@xadd{\mathchar\the\count@\space}%
\else
\begingroup
\divide\count@"1000
\let\varbm@expand\relax
\varbm@xadd\varbm@class
\endgroup
\edef\@tempb{%
\noexpand\@tempa{\mathchar\the\count@\space}}%
\@tempb
\fi}
\def\varbm@pmb#1{%
\varbm@add{\varbm@pmb@{#1}}}
\def\varbm@pmb@#1{{%
\setbox\tw@\hbox{$\m@th\mkern.4mu$}%
\mathchoice
\varbm@pmb@@\displaystyle\@empty{#1}%
\varbm@pmb@@\textstyle\@empty{#1}%
\varbm@pmb@@\scriptstyle\defaultscriptratio{#1}%
\varbm@pmb@@\scriptscriptstyle\defaultscriptscriptratio{#1}}}
\def\varbm@pmb@@#1#2#3{{%
\setbox\z@\hbox{$\m@th#1#3$}%
\dimen@#2\wd\tw@
\rlap{\copy\z@}%
\kern\dimen@
\raise1.5\dimen@\rlap{\copy\z@}%
\kern\dimen@
\box\z@}}%
\def\varbm@class{%
\ifcase\count@
\or
\mathop\or
\mathbin\or
\mathrel\or
\mathopen\or
\mathclose\or
\mathpunct\or
\fi}
\def\varbm@add#1{%
\begingroup
\toks@\expandafter{\varbm@command#1}%
\xdef\varbm@command{\the\toks@}%
\endgroup
\varbm@expand}
\def\varbm@xadd#1{%
\begingroup
\toks@\expandafter{\varbm@command}%
\xdef\varbm@command{\the\toks@#1}%
\endgroup
\varbm@expand}
\def\varbm@mathaccent{%
\varbm@changefam{}%
\begingroup
\def\varbm@group##1{\endgroup\varbm@xadd{\bgroup}##1\egroup}%
\def\varbm@test@token{\endgroup\varbm@test@token}%
\let\relax\@empty
\varbm@xadd{\mathaccent\the\count@\space}}
\def\varbm@delimiter{%
\ifnum\count@>\z@
\varbm@changefam{}%
\varbm@changefam{000}%
\fi
\varbm@xadd{\delimiter\the\count@\space}}%
\def\varbm@radical{%
\varbm@changefam{}%
\varbm@changefam{000}%
\varbm@xadd{\radical\the\count@\space}}%
\edef\varbm@mchar@{\meaning\mathchar}
\def\varbm@mchar@test#1"#2"#3\@nil#4{%
\xdef\meaning@{#1}%
\ifx\meaning@\varbm@mchar@
\count@"#2\relax
\varbm@mathchar
\else
\ifx\varbm@previous\@empty
\ifx\relax#4%
\gdef\varbm@first{#4}%
\fi
\fi
\varbm@add{#4}%
\fi}
\def\varbm@changefam#1{%
\@tempcnta\count@
\divide\@tempcnta"1000#1 %
\multiply\@tempcnta"1000#1 %
\advance\@tempcnta-\count@
\divide\@tempcnta-"100#1 %
\@tempcnta\varbm@table
\ifnum\@tempcnta=\m@ne
\let\@tempa\varbm@pmb
\else
\multiply\@tempcnta"100#1 %
\advance\count@\@tempcnta
\fi}
\def\varbm@prime{^\bgroup
\let\varbm@prime'%
\def\prim@s##1\relax{##1\futurelet\@let@token\pr@m@s}%
\prim@s}
\let\varboldsymbol\varbm
\endinput
%%
%% End of file `varbm.sty'.