| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (c) 2025 by Michael Ummels <[email protected]> |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the |
| 6 |
% conditions of the LaTeX Project Public License, either version 1.3c |
| 7 |
% of this license or (at your option) any later version. |
| 8 |
% The latest version of this license is in |
| 9 |
% https://www.latex-project.org/lppl.txt |
| 10 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 11 |
% version 2008 or later. |
| 12 |
% |
| 13 |
% This work has the LPPL maintenance status `maintained'. |
| 14 |
% |
| 15 |
% The Current Maintainer of this work is Michael Ummels. |
| 16 |
% |
| 17 |
% This work consists of the files figureversions.dtx, figureversions.ins and |
| 18 |
% the derived files figureversions.sty and figureversions.pdf. |
| 19 |
% |
| 20 |
%<*driver> |
| 21 |
\documentclass[a4paper,onlydoc]{l3doc} |
| 22 |
|
| 23 |
\usepackage[nottoc]{tocbibind} |
| 24 |
\usepackage{figureversions} |
| 25 |
\usepackage[toc,enum,bib]{tabfigures} |
| 26 |
\usepackage[scale=0.95]{cantarell} |
| 27 |
\usepackage[narrow]{inconsolata} |
| 28 |
\usepackage{microtype} |
| 29 |
|
| 30 |
\hypersetup{ |
| 31 |
bookmarksnumbered, |
| 32 |
colorlinks=false, |
| 33 |
pdfborder={0 0 0} |
| 34 |
} |
| 35 |
|
| 36 |
% Hack in order to get quotes in verbatim mode right |
| 37 |
\DeclareEncodingSubset{TS1}{zi4}{1} |
| 38 |
|
| 39 |
\renewcommand{\sfdefault}{cantarell-OsF} |
| 40 |
\renewcommand{\familydefault}{\sfdefault} |
| 41 |
\renewcommand{\MacroLongFont}{\fontfamily{zi4}\scriptsize} |
| 42 |
\renewcommand{\baselinestretch}{1.1} |
| 43 |
\makeatletter |
| 44 |
\renewcommand{\meta@font@select}{\sffamily\itshape} |
| 45 |
\makeatother |
| 46 |
|
| 47 |
\EnableCrossrefs |
| 48 |
\CodelineIndex |
| 49 |
\RecordChanges |
| 50 |
|
| 51 |
\begin{document} |
| 52 |
\DocInput{figureversions.dtx} |
| 53 |
\end{document} |
| 54 |
%</driver> |
| 55 |
%<*package> |
| 56 |
\NeedsTeXFormat{LaTeX2e}[2024-11-01] |
| 57 |
\ProvidesExplPackage {figureversions} {2025-04-29} {1.0.1} {Figure versions} |
| 58 |
%</package> |
| 59 |
% \fi |
| 60 |
% |
| 61 |
% \changes{v1.0}{2025-04-05}{Initial version} |
| 62 |
% |
| 63 |
% \GetFileInfo{figureversions.sty} |
| 64 |
% |
| 65 |
% \title{How Do You Like Your Figures?} |
| 66 |
% \author{Michael Ummels} |
| 67 |
% \date{\fileversion\quad\filedate} |
| 68 |
% \maketitle |
| 69 |
% |
| 70 |
% \begin{abstract} |
| 71 |
% The \pkg{figureversions} package defines several commands to switch between |
| 72 |
% figure versions, which determine the appearance of numbers in your |
| 73 |
% document. The package works with many font packages available on CTAN |
| 74 |
% as well as with most OpenType fonts under \XeTeX\ and \LuaTeX\ in combination |
| 75 |
% with \pkg{fontspec}. |
| 76 |
% \end{abstract} |
| 77 |
% |
| 78 |
% \begin{documentation} |
| 79 |
% |
| 80 |
% \tableofcontents |
| 81 |
% |
| 82 |
% \section{Introduction} |
| 83 |
% |
| 84 |
% While basic fonts only have \emph{lining} figures (aka numbers), which extend |
| 85 |
% from the base line to the height of capital letters, advanced fonts may come |
| 86 |
% with several other \emph{figure versions}, the most prominent being |
| 87 |
% \emph{old-style} or \emph{text} figures which look more like lowercase letters |
| 88 |
% and therefore fit nicely into a block of lower/mixed-case text: compare |
| 89 |
% \liningfigures{1234567890} to \textfigures{1234567890}.% |
| 90 |
% \marginpar{% |
| 91 |
% \raggedleft\LARGE |
| 92 |
% \begin{tabular}{r} |
| 93 |
% \liningfigures{1234567890} \\ |
| 94 |
% \textfigures{1234567890} |
| 95 |
% \end{tabular} |
| 96 |
% } |
| 97 |
% |
| 98 |
% Since \LaTeX's font selection system \cite{nfss} has no support |
| 99 |
% for figure versions, font package authors have resorted to define one |
| 100 |
% \LaTeX\ font family for each figure version, so you can switch between |
| 101 |
% different figure versions by invoking the low-level \cs{fontfamily} command, |
| 102 |
% followed by a call to \cs{selectfont}. This is not only cumbersome, but also |
| 103 |
% ties the font family to the figure version, so you cannot change them |
| 104 |
% independently. |
| 105 |
% |
| 106 |
% The \pkg{figureversions} package not only makes it easier to switch figure |
| 107 |
% versions, but it also lets you change the two dimensions of a figure version |
| 108 |
% separately: \emph{figure style} and \emph{figure alignment}. While figure |
| 109 |
% style is solely about the the appearance of figures, figure alignment |
| 110 |
% is concerned with the width of figures. In particular, \emph{tabular} |
| 111 |
% figures all have the same width, so multiple-digit numbers nicely line up |
| 112 |
% when stacked on top of each other.% |
| 113 |
% \marginpar{% |
| 114 |
% \raggedleft\LARGE |
| 115 |
% \begin{tabular}{rr} |
| 116 |
% 12345 & \tbfigures{12345} \\ |
| 117 |
% 67890 & \tbfigures{67890} |
| 118 |
% \end{tabular} |
| 119 |
% } |
| 120 |
% |
| 121 |
% \subsection{History} |
| 122 |
% |
| 123 |
% Most commands defined by this package first appeared in the |
| 124 |
% \pkg{MinionPro} package\footnote{\url{https://ctan.org/pkg/minionpro}} by |
| 125 |
% Achim Blumensath et al., a package that made the professional |
| 126 |
% Minion\texttrademark\ Pro font family by Adobe accessible to all |
| 127 |
% \LaTeX\ users (i.e.\ not only when using \XeTeX\ or \LuaTeX). |
| 128 |
% Since the concept of figure versions is not specific to Minion Pro, the |
| 129 |
% corresponding functionality was then incorporated by Andreas Bühmann into a |
| 130 |
% separate package called \pkg{fontaxes}.\kern-0.15em% |
| 131 |
% \footnote{\url{https://ctan.org/pkg/fontaxes}} The \pkg{fontaxes} |
| 132 |
% package does not only support different figure versions, but has also split |
| 133 |
% the \emph{shape} of a font into two dimensions (`axes'), which can be |
| 134 |
% changed independently of each other. For instance, \cs{itshape} operates on |
| 135 |
% the first dimension, while \cs{scshape} operates on the second. With |
| 136 |
% \LaTeX\ release 2020-02-02, that functionality was integrated into the |
| 137 |
% kernel \cite{ltnews31}, so -- with the exception of the functionality |
| 138 |
% dealing with figure versions -- the \pkg{fontaxes} package has been made |
| 139 |
% redundant. Hence, its current maintainer decided to undertake a modern |
| 140 |
% rewrite and strip off all functionality that has been integrated into the |
| 141 |
% kernel, thereby adding support for |
| 142 |
% \pkg{fontspec}\footnote{\url{https://ctan.org/pkg/fontspec}} under |
| 143 |
% \XeTeX\ and \LuaTeX. |
| 144 |
% |
| 145 |
% \section{Usage} |
| 146 |
% |
| 147 |
% You can load this package by adding |
| 148 |
% \begin{quote} |
| 149 |
% |\usepackage{figureversions}| |
| 150 |
% \end{quote} |
| 151 |
% to the preamble of your document. |
| 152 |
% |
| 153 |
% \subsection{High-level document commands} |
| 154 |
% |
| 155 |
% \begin{function}{\lnfigures,\txfigures,\liningfigures,\textfigures} |
| 156 |
% \begin{syntax} |
| 157 |
% \cs{lnfigures} |
| 158 |
% \cs{txfigures} |
| 159 |
% \cs{liningfigures}\marg{text} |
| 160 |
% \cs{textfigures}\marg{text} |
| 161 |
% \end{syntax} |
| 162 |
% By default, the \pkg{figureversions} package knows two figure styles, `text' |
| 163 |
% and `lining', which can be accessed using the commands \cs{txfigures} and |
| 164 |
% \cs{lnfigures} respectively. Similar to commands like \cs{itshape}, |
| 165 |
% these commands are \emph{declarations} and remain in effect until the end of |
| 166 |
% the current group or environment. If you only want to change the figure |
| 167 |
% style for a short amount of text, you can use the corresponding \emph{text |
| 168 |
% font commands} \cs{liningfigures} and \cs{textfigures}, which take as |
| 169 |
% argument the text to which the figure style should apply. |
| 170 |
% \end{function} |
| 171 |
% |
| 172 |
% \begin{function}{\prfigures,\tbfigures,\proportionalfigures,\tabularfigures} |
| 173 |
% \begin{syntax} |
| 174 |
% \cs{prfigures} |
| 175 |
% \cs{tbfigures} |
| 176 |
% \cs{proportionalfigures}\marg{text} |
| 177 |
% \cs{tabularfigures}\marg{text} |
| 178 |
% \end{syntax} |
| 179 |
% For changing the figure alignment, use the commands \cs{prfigures} and |
| 180 |
% \cs{tbfigures}: while \cs{prfigures} changes to proportional figures, which |
| 181 |
% vary in width, \cs{tbfigures} changes to tabular or \emph{monospaced} figures. |
| 182 |
% As for \cs{linfigures} and \cs{txfigures}, the selected figure |
| 183 |
% alignment remains in effect until the end of the current group or environment; |
| 184 |
% the corresponding text font commands are \cs{proportionalfigures} and |
| 185 |
% \cs{tabularfigures}. |
| 186 |
% \end{function} |
| 187 |
% |
| 188 |
% \begin{function}{\boldmath,\unboldmath,\tabularmath,\proportionalmath} |
| 189 |
% \begin{syntax} |
| 190 |
% \cs{boldmath} |
| 191 |
% \cs{unboldmath} |
| 192 |
% \cs{tabularmath} |
| 193 |
% \cs{proportionalmath} |
| 194 |
% \end{syntax} |
| 195 |
% By default, \LaTeX\ provides two \emph{math versions}, `normal' and `bold', |
| 196 |
% as well as commands \cs{boldmath} and \cs{unboldmath} for switching between |
| 197 |
% them. The \pkg{figureversions} packages redefines these commands to only |
| 198 |
% change the math font's weight and provides commands \cs{tabularmath} and |
| 199 |
% \cs{proportionalmath} to switch between tabular and proportional figures |
| 200 |
% in math mode.\footnote{Note that these commands have to be executed outside |
| 201 |
% of math mode.} This functionality assumes the presence of additional math |
| 202 |
% versions `tabular' and `boldtabular'; the package will copy the setups of math |
| 203 |
% versions `normal' and `bold' if you do not provide your own declarations. |
| 204 |
% \end{function} |
| 205 |
% |
| 206 |
% \begin{function}{\figureversion} |
| 207 |
% \begin{syntax} |
| 208 |
% \cs{figureversion}\marg{comma-separated list} |
| 209 |
% \end{syntax} |
| 210 |
% The \cs{figureversion} command can be used to change the figure version by a |
| 211 |
% single command. It takes as argument a comma-separated list of one or more |
| 212 |
% of the following options:\footnote{More options can be added by package |
| 213 |
% authors; see Section~\ref{sect:code-interface}.} |
| 214 |
% \begin{quote} |
| 215 |
% \begin{tabular}{@{}ll} |
| 216 |
% |text|, |osf| & for text figures,\\ |
| 217 |
% |lining|, |lf| & for lining figures,\\ |
| 218 |
% |tabular|, |tab| & for tabular figures (also in math mode),\\ |
| 219 |
% |proportional|, |prop| & for proportional figures (also in math mode). |
| 220 |
% \end{tabular} |
| 221 |
% \end{quote} |
| 222 |
% \end{function} |
| 223 |
% |
| 224 |
% \subsection{Low-level document commands} |
| 225 |
% |
| 226 |
% The low-level commands described in this section are mostly relevant for |
| 227 |
% package authors. They are meant to be be combined with other low-level font |
| 228 |
% selection commands like \cs{fontshape} and \cs{fontseries} and a subsequent |
| 229 |
% call to \cs{selectfont}. |
| 230 |
% Finally, since they rely on the classical \LaTeXe\ font selection scheme -- |
| 231 |
% with the exception of \cs{mathweight} and \cs{mathfigurealignment} -- they |
| 232 |
% would normally not work with \pkg{fontspec}. |
| 233 |
% |
| 234 |
% \begin{function}{\fontfigurestyle} |
| 235 |
% \begin{syntax} |
| 236 |
% \cs{fontfigurestyle}\marg{figure style} |
| 237 |
% \end{syntax} |
| 238 |
% By default, the \pkg{figureversions} package knows two figure styles: `text' |
| 239 |
% and `lining', but package authors can define additional figure styles; see |
| 240 |
% Section~\ref{sect:code-interface}. |
| 241 |
% \end{function} |
| 242 |
% |
| 243 |
% \begin{function}{\fontfigurealignment} |
| 244 |
% \begin{syntax} |
| 245 |
% \cs{fontfigurealignment}\marg{figure alignment} |
| 246 |
% \end{syntax} |
| 247 |
% Using this command, you can choose either `proportional' or `tabular' figures. |
| 248 |
% \end{function} |
| 249 |
% |
| 250 |
% \begin{function}{\fontbasefamily} |
| 251 |
% \begin{syntax} |
| 252 |
% \cs{fontbasefamily}\marg{family name} |
| 253 |
% \end{syntax} |
| 254 |
% Recall that figure versions are implemented on top of the \LaTeXe\ font |
| 255 |
% selection scheme by amending the family name. For instance, |
| 256 |
% |\fontfamily{cantarell-TLF}| selects \emph{Cantarell} with tabular lining |
| 257 |
% figures. |
| 258 |
% The \cs{fontbasefamily} command thus allows you to select the |
| 259 |
% font family independently of the figure version. Hence, |
| 260 |
% |\fontbasefamily{cantarell}| switches to Cantarell, but does not change the |
| 261 |
% current figure style or alignment. |
| 262 |
% \end{function} |
| 263 |
% |
| 264 |
% \begin{function}{\mathweight} |
| 265 |
% \begin{syntax} |
| 266 |
% \cs{mathweight}\marg{font weight} |
| 267 |
% \end{syntax} |
| 268 |
% The package knows two different math weights `normal' and `bold', which can |
| 269 |
% be accessed by this command. Note that -- like \cs{mathversion} -- this |
| 270 |
% command does \emph{not} work in math mode and takes effect immediately, |
| 271 |
% i.e.\ for all following invocations of math mode. |
| 272 |
% \end{function} |
| 273 |
% |
| 274 |
% \begin{function}{\mathfigurealignment} |
| 275 |
% \begin{syntax} |
| 276 |
% \cs{mathfigurealignment}\marg{figure alignment} |
| 277 |
% \end{syntax} |
| 278 |
% To change the math figure alignment, use this command. As for |
| 279 |
% \cs{fontfigurealignment}, valid arguments are `proportional` and `tabular`. |
| 280 |
% Like \cs{mathweight}, this command does not work in math mode and takes |
| 281 |
% effect immediately. |
| 282 |
% \end{function} |
| 283 |
% |
| 284 |
% \subsection{Code-level interface}\label{sect:code-interface} |
| 285 |
% |
| 286 |
% Like other packages implemented in \LaTeX3, this package defines several |
| 287 |
% commands at \emph{code level}, i.e.\ with \cs{ExplSyntaxOn}, which can be |
| 288 |
% used to extend the functionality of this package. |
| 289 |
% |
| 290 |
% \begin{function}{\figureversions_new_figurestyle:nnn,\figureversions_new_figurestyle:Vnn} |
| 291 |
% \begin{syntax} |
| 292 |
% \cs{figureversions_new_figurestyle:nnn} \marg{name} \marg{proportional suffixes} \marg{tabular suffixes} |
| 293 |
% \end{syntax} |
| 294 |
% Defines a new figure style named \meta{name} with corresponding font family |
| 295 |
% suffixes (given as comma-separated lists) for proportional and |
| 296 |
% tabular figure alignment. For instance, the existing figure style `text' |
| 297 |
% is defined by |
| 298 |
% \begin{quote} |
| 299 |
% |\figureversions_new_figurestyle:nnn {text} {OsF} {TOsF}| |
| 300 |
% \end{quote} |
| 301 |
% \end{function} |
| 302 |
% |
| 303 |
% \begin{function}{\figureversions_new_figureversion:nn} |
| 304 |
% \begin{syntax} |
| 305 |
% \cs{figureversions_new_figureversion:nn} \marg{option} \marg{code} |
| 306 |
% \end{syntax} |
| 307 |
% Defines a new option for the \cs{figureversion} command: Expands to |
| 308 |
% \meta{code} when \cs{figureversion} is called with \meta{option} among |
| 309 |
% its arguments. |
| 310 |
% \end{function} |
| 311 |
% |
| 312 |
% \section{Compatibility} |
| 313 |
% |
| 314 |
% \subsection{Font support} |
| 315 |
% |
| 316 |
% Within the \LaTeXe\ font selection scheme, the package supports the two most |
| 317 |
% common naming schemes for font families: |
| 318 |
% \begin{enumerate} |
| 319 |
% \item \meta{family}|-|\meta{suffix} where the suffix is e.g. |OsF| for |
| 320 |
% proportional text figures or |TLF| for tabular lining figures. |
| 321 |
% \item \meta{family}\meta{style} where the family is given by a |
| 322 |
% three-letter lowercase identifier and \emph{style} is either |
| 323 |
% |j| for text figures or |x| for lining figures.\footnote{Note that |
| 324 |
% this scheme does not support different figure alignments.} |
| 325 |
% \end{enumerate} |
| 326 |
% Almost all of the many font packages available on CTAN adhere to one of these |
| 327 |
% conventions, so \pkg{figureversions} works with all of them. |
| 328 |
% |
| 329 |
% Even more fonts are supported with \pkg{fontspec}: Since the |
| 330 |
% \pkg{figureversions} package simply maps commands like \cs{tbfigures} to the |
| 331 |
% corresponding OpenType feature, the package works with any OpenType font that |
| 332 |
% implements one or more of these features. |
| 333 |
% |
| 334 |
% \subsection{Interplay with other packages} |
| 335 |
% |
| 336 |
% Since this package defines the \cs{tbfigures} command to switch to tabular |
| 337 |
% figures, it plays well and -- in some sense -- enables the |
| 338 |
% \pkg{tabfigures} package\footnote{https://ctan.org/pkg/tabfigures}, which |
| 339 |
% patches several \LaTeX\ commands and environments to use tabular figures. If |
| 340 |
% you are a document author who uses a font with proportional figures by |
| 341 |
% default, then the \pkg{tabfigures} package is warmly recommended (also used |
| 342 |
% in this document for e.g.\ the table of contents). |
| 343 |
% |
| 344 |
% As mentioned in the introduction, this package replaces the \pkg{fontaxes} |
| 345 |
% package, which -- as of version~2 -- is just a wrapper around |
| 346 |
% this package, adding some internal commands that |
| 347 |
% have historically been used by package authors to define new figure styles. |
| 348 |
% If you are the author of a package that depends on \pkg{fontaxes}, please |
| 349 |
% consider updating you package to depend on this package instead, using the |
| 350 |
% commands described in Section~\ref{sect:code-interface} to define additional |
| 351 |
% figure styles if necessary. |
| 352 |
% |
| 353 |
% \end{documentation} |
| 354 |
% |
| 355 |
% \begin{implementation} |
| 356 |
% \AddToHook{sffamily}{\fontfigurealignment{tabular}} |
| 357 |
% |
| 358 |
% \section{Implementation} |
| 359 |
% |
| 360 |
% \begin{macrocode} |
| 361 |
%<*package> |
| 362 |
%<@@=figureversions> |
| 363 |
% \end{macrocode} |
| 364 |
% |
| 365 |
% \subsection{Variables and Constants} |
| 366 |
% |
| 367 |
% First, some constants. |
| 368 |
% \begin{macrocode} |
| 369 |
\str_const:Nn \c_@@_text_str {text} |
| 370 |
\str_const:Nn \c_@@_lining_str {lining} |
| 371 |
\str_const:Nn \c_@@_proportional_str {proportional} |
| 372 |
\str_const:Nn \c_@@_tabular_str {tabular} |
| 373 |
\str_const:Nn \c_@@_normal_str {normal} |
| 374 |
\str_const:Nn \c_@@_bold_str {bold} |
| 375 |
\str_const:Nn \c_@@_lf_str {LF} |
| 376 |
\str_const:Nn \c_@@_osf_str {OsF} |
| 377 |
\str_const:Nn \c_@@_tlf_str {TLF} |
| 378 |
\str_const:Nn \c_@@_tosf_str {TOsF} |
| 379 |
% \end{macrocode} |
| 380 |
% This global boolean is set to true when \pkg{fontspec} is loaded. |
| 381 |
% \begin{macrocode} |
| 382 |
\bool_new:N \g_@@_fontspec_bool |
| 383 |
% \end{macrocode} |
| 384 |
% The following string variables will hold the current value of the font base |
| 385 |
% family, the font figure style, and the figure alignment, respectively. We |
| 386 |
% initialize them with default values, although these will almost surely be |
| 387 |
% overwritten once a figure style selection command is executed. |
| 388 |
% \begin{macrocode} |
| 389 |
\str_new:N \l_@@_fontbasefamily_str |
| 390 |
\str_new:N \l_@@_fontfigurestyle_str |
| 391 |
\str_new:N \l_@@_fontfigurealignment_str |
| 392 |
\str_set:Nn \l_@@_fontbasefamily_str {cmr} |
| 393 |
\str_set_eq:NN \l_@@_fontfigurestyle_str \c_@@_lining_str |
| 394 |
\str_set_eq:NN \l_@@_fontfigurealignment_str \c_@@_proportional_str |
| 395 |
% \end{macrocode} |
| 396 |
% The defined figure styles are held in two maps, one each for the two |
| 397 |
% supported figure alignments `proportional' and `tabular'. Those |
| 398 |
% maps take as key the name of the figure style and as value the corresponding |
| 399 |
% suffix of the font family (think |OsF| or |TOsF|). |
| 400 |
% \begin{macrocode} |
| 401 |
\prop_new:N \g_@@_figurestyles_proportional_prop |
| 402 |
\prop_new:N \g_@@_figurestyles_tabular_prop |
| 403 |
% \end{macrocode} |
| 404 |
% The possible inputs for the \cs{figureversion} commands and their meanings are |
| 405 |
% held in a map as well. |
| 406 |
% \begin{macrocode} |
| 407 |
\prop_new:N \g_@@_figureversions_prop |
| 408 |
% \end{macrocode} |
| 409 |
% For math fonts, we only support changing the weight or the figure alignment. |
| 410 |
% The following two variables will hold the current value of each axis. |
| 411 |
% \begin{macrocode} |
| 412 |
\str_new:N \l_@@_mathweight_str |
| 413 |
\str_new:N \l_@@_mathalign_str |
| 414 |
% \end{macrocode} |
| 415 |
% |
| 416 |
% \subsection{Messages} |
| 417 |
% |
| 418 |
% \begin{macrocode} |
| 419 |
\msg_new:nnn { figureversions } { unknown-figurestyle } |
| 420 |
{ Ignoring~unknown~figure~style~`#1'~\msg_line_context: } |
| 421 |
\msg_new:nnn { figureversions } { unknown-figurealignment } |
| 422 |
{ Ignoring~unknown~figure~alignment~`#1'~\msg_line_context: } |
| 423 |
\msg_new:nnn { figureversions } { unknown-mathweight } |
| 424 |
{ Ignoring~unknown~math~weight~`#1'~\msg_line_context: } |
| 425 |
\msg_new:nnn { figureversions } { unknown-mathfigurealignment } |
| 426 |
{ Ignoring~unknown~math~figure~alignment~`#1'~\msg_line_context: } |
| 427 |
\msg_new:nnn { figureversions } { unknown-figureversion } |
| 428 |
{ Ignoring~unknown~figure~version~`#1'~\msg_line_context: } |
| 429 |
% \end{macrocode} |
| 430 |
% \subsection{Utility functions} |
| 431 |
% |
| 432 |
% \begin{macro}{\@@_warning:nn} |
| 433 |
% Issues a warning. |
| 434 |
% \begin{macrocode} |
| 435 |
\cs_new:Nn \@@_warning:nn |
| 436 |
{ \msg_warning:nnn {figureversions} {#1} {#2} } |
| 437 |
% \end{macrocode} |
| 438 |
% \end{macro} |
| 439 |
% \begin{macro}{\@@_if_family_exists:nTF} |
| 440 |
% Used to test whether a given font family exists or not. |
| 441 |
% \begin{macrocode} |
| 442 |
\prg_new_protected_conditional:Nnn \@@_if_family_exists:n { TF } |
| 443 |
{ |
| 444 |
\group_begin: |
| 445 |
\fontfamily {#1} |
| 446 |
\try@load@fontshape |
| 447 |
\cs_if_eq:cNTF \curr@fontshape \relax |
| 448 |
{ \group_insert_after:N \prg_return_false: } |
| 449 |
{ \group_insert_after:N \prg_return_true: } |
| 450 |
\group_end: |
| 451 |
} |
| 452 |
% \end{macrocode} |
| 453 |
% \end{macro} |
| 454 |
% |
| 455 |
% \begin{macro}{\@@_split_family:nNNTF, |
| 456 |
% \@@_split_family:VNNTF, |
| 457 |
% \@@_split_family_aux:w} |
| 458 |
% Tries to split the font family name given by the \meta{token list}~|#1| |
| 459 |
% into the base name and a variant suffix, delimited by |-|. Sets |
| 460 |
% \meta{string variable}~|#2| to the base name and \meta{string variable}~|#3| |
| 461 |
% to the suffix if the split succeeds. |
| 462 |
% \begin{macrocode} |
| 463 |
\prg_new_protected_conditional:Nnn \@@_split_family:nNN { TF } |
| 464 |
{ \@@_split_family_aux:w #1 - - \q_stop #2 #3 } |
| 465 |
\prg_generate_conditional_variant:Nnn \@@_split_family:nNN { V } { TF } |
| 466 |
% \end{macrocode} |
| 467 |
% \begin{macrocode} |
| 468 |
\cs_new_protected:Npn \@@_split_family_aux:w #1-#2-#3 \q_stop #4 #5 |
| 469 |
{ |
| 470 |
\tl_if_empty:nTF {#2} |
| 471 |
{ \prg_return_false: } |
| 472 |
{ |
| 473 |
\str_set:Nn #4 {#1} |
| 474 |
\str_set:Nn #5 {#2} |
| 475 |
\prg_return_true: |
| 476 |
} |
| 477 |
} |
| 478 |
% \end{macrocode} |
| 479 |
% \end{macro} |
| 480 |
% |
| 481 |
% \begin{macro}{\@@_copy_mathversion_if_undefined:nn} |
| 482 |
% Declare math version |#1| to be a copy of math version |#2| if |#1| does not |
| 483 |
% exist already. To accomplish this, we have to know that a math version's |
| 484 |
% configuration is basically stored in a macro |\mv@|\meta{name}. |
| 485 |
% \begin{macrocode} |
| 486 |
\cs_new_protected:Nn \@@_copy_mathversion_if_undefined:nn |
| 487 |
{ |
| 488 |
\cs_if_exist:cF {mv@#1} |
| 489 |
{ |
| 490 |
\DeclareMathVersion {#1} |
| 491 |
\cs_set_eq:cc {mv@#1} {mv@#2} |
| 492 |
} |
| 493 |
} |
| 494 |
% \end{macrocode} |
| 495 |
% \end{macro} |
| 496 |
% |
| 497 |
% \subsection{Encoding} |
| 498 |
% |
| 499 |
% \begin{macro}{\@@_encode_suffix_proportional:N} |
| 500 |
% Determines the possible proportional font family suffixes for the |
| 501 |
% current figure style and places the result in the given \meta{seq variable} |
| 502 |
% |#1|. Since some figure styles may only exist in a tabular version, use that |
| 503 |
% as a fallback. Finally, fall back to |LF|, |OsF|, |TLF| and |TOsF| (in that |
| 504 |
% order). |
| 505 |
% \changes{v1.0.1}{2025-04-28}{Fix bug that could lead to infinite loop} |
| 506 |
% \begin{macrocode} |
| 507 |
\cs_new_protected:Nn \@@_encode_suffix_proportional:N |
| 508 |
{ |
| 509 |
\seq_clear:N #1 |
| 510 |
\prop_get:NVN \g_@@_figurestyles_proportional_prop |
| 511 |
\l_@@_fontfigurestyle_str \l_tmpa_clist |
| 512 |
\tl_if_eq:NNF \l_tmpa_clist \q_no_value |
| 513 |
{ |
| 514 |
\clist_map_inline:Nn \l_tmpa_clist |
| 515 |
{ \seq_if_in:NnF #1 {##1} { \seq_put_right:Nn #1 {##1} } } |
| 516 |
} |
| 517 |
\prop_get:NVN \g_@@_figurestyles_tabular_prop |
| 518 |
\l_@@_fontfigurestyle_str \l_tmpa_clist |
| 519 |
\tl_if_eq:NNF \l_tmpa_clist \q_no_value |
| 520 |
{ |
| 521 |
\clist_map_inline:Nn \l_tmpa_clist |
| 522 |
{ \seq_if_in:NnF #1 {##1} { \seq_put_right:Nn #1 {##1} } } |
| 523 |
} |
| 524 |
% \end{macrocode} |
| 525 |
% Since any given font family might have only a restricted number of figure |
| 526 |
% versions (maybe even only tabular ones), we add the well-known suffixes |
| 527 |
% |LF|, |OsF|, |TLF| and |TOsF| to the end of the seq. |
| 528 |
% \begin{macrocode} |
| 529 |
\seq_if_in:NVF #1 \c_@@_lf_str { \seq_put_right:NV #1 \c_@@_lf_str } |
| 530 |
\seq_if_in:NVF #1 \c_@@_osf_str { \seq_put_right:NV #1 \c_@@_osf_str } |
| 531 |
\seq_if_in:NVF #1 \c_@@_tlf_str { \seq_put_right:NV #1 \c_@@_tlf_str } |
| 532 |
\seq_if_in:NVF #1 \c_@@_tosf_str { \seq_put_right:NV #1 \c_@@_tosf_str } |
| 533 |
} |
| 534 |
% \end{macrocode} |
| 535 |
% \end{macro} |
| 536 |
% |
| 537 |
% \begin{macro}{\@@_encode_suffix_tabular:N} |
| 538 |
% Determines the possible tabular font family suffixes for the current figure |
| 539 |
% style and places the result in the given \meta{seq variable} |#1|. |
| 540 |
% Since some figure styles may only exist in a proportional version, use that |
| 541 |
% as a fallback. |
| 542 |
% \begin{macrocode} |
| 543 |
\cs_new_protected:Nn \@@_encode_suffix_tabular:N |
| 544 |
{ |
| 545 |
\seq_clear:N #1 |
| 546 |
\prop_get:NVN \g_@@_figurestyles_tabular_prop |
| 547 |
\l_@@_fontfigurestyle_str \l_tmpa_clist |
| 548 |
\tl_if_eq:NNF \l_tmpa_clist \q_no_value |
| 549 |
{ |
| 550 |
\clist_map_inline:Nn \l_tmpa_clist |
| 551 |
{ \seq_if_in:NnF #1 {##1} { \seq_put_right:Nn #1 {##1} } } |
| 552 |
} |
| 553 |
\prop_get:NVN \g_@@_figurestyles_proportional_prop |
| 554 |
\l_@@_fontfigurestyle_str \l_tmpa_clist |
| 555 |
\tl_if_eq:NNF \l_tmpa_clist \q_no_value |
| 556 |
{ |
| 557 |
\clist_map_inline:Nn \l_tmpa_clist |
| 558 |
{ \seq_if_in:NnF #1 {##1} { \seq_put_right:Nn #1 {##1} } } |
| 559 |
} |
| 560 |
% \end{macrocode} |
| 561 |
% Since any given font family might have only a restricted number of figure |
| 562 |
% versions (maybe even only proportional ones), we add the well-known suffixes |
| 563 |
% |TLF|, |TOsF|, |LF| and |OsF| to the end of the seq. |
| 564 |
% \begin{macrocode} |
| 565 |
\seq_if_in:NVF #1 \c_@@_tlf_str { \seq_put_right:NV #1 \c_@@_tlf_str } |
| 566 |
\seq_if_in:NVF #1 \c_@@_tosf_str { \seq_put_right:NV #1 \c_@@_tosf_str } |
| 567 |
\seq_if_in:NVF #1 \c_@@_lf_str { \seq_put_right:NV #1 \c_@@_lf_str } |
| 568 |
\seq_if_in:NVF #1 \c_@@_osf_str { \seq_put_right:NV #1 \c_@@_osf_str } |
| 569 |
} |
| 570 |
% \end{macrocode} |
| 571 |
% \end{macro} |
| 572 |
% |
| 573 |
% \begin{macro}{\@@_encode_suffix:N} |
| 574 |
% Determines the possible font family suffixes corresponding to the current |
| 575 |
% figure style/alignment and places the result in the given |
| 576 |
% \meta{seq variable} |#1|. |
| 577 |
% \begin{macrocode} |
| 578 |
\cs_new_protected:Nn \@@_encode_suffix:N |
| 579 |
{ |
| 580 |
\str_if_eq:NNTF \l_@@_fontfigurealignment_str \c_@@_tabular_str |
| 581 |
{ \@@_encode_suffix_tabular:N #1 } |
| 582 |
{ \@@_encode_suffix_proportional:N #1 } |
| 583 |
} |
| 584 |
% \end{macrocode} |
| 585 |
% \end{macro} |
| 586 |
% |
| 587 |
% \begin{macro}{\@@_encode_suffix_alt:N} |
| 588 |
% Determines the alternate one-letter suffix for the current |
| 589 |
% figure style and places the result in the given \meta{string variable} |
| 590 |
% |#1|. Note that the suffix only depends on the current figure style |
| 591 |
% and not on the current figure alignment. |
| 592 |
% \begin{macrocode} |
| 593 |
\cs_new_protected:Nn \@@_encode_suffix_alt:N |
| 594 |
{ |
| 595 |
\str_if_eq:NNTF \l_@@_fontfigurestyle_str \c_@@_text_str |
| 596 |
{ \str_set:Nn #1 {j} } |
| 597 |
{ \str_set:Nn #1 {x} } |
| 598 |
} |
| 599 |
% \end{macrocode} |
| 600 |
% \end{macro} |
| 601 |
% |
| 602 |
% \begin{macro}{\@@_set_fontfamily:} |
| 603 |
% Sets the font family accoding to the current figure style, figure alignment |
| 604 |
% and base family. |
| 605 |
% \begin{macrocode} |
| 606 |
\cs_new_protected:Nn \@@_set_fontfamily: |
| 607 |
{ |
| 608 |
\bool_set_false:N \l_tmpa_bool |
| 609 |
\@@_encode_suffix:N \l_tmpa_seq |
| 610 |
\seq_map_inline:Nn \l_tmpa_seq |
| 611 |
{ |
| 612 |
\@@_if_family_exists:nTF { \l_@@_fontbasefamily_str-##1 } |
| 613 |
{ |
| 614 |
\fontfamily { \l_@@_fontbasefamily_str-##1 } |
| 615 |
\seq_map_break:n { \bool_set_true:N \l_tmpa_bool } |
| 616 |
} |
| 617 |
} |
| 618 |
% \end{macrocode} |
| 619 |
% If no suffix could be applied, try the alternate scheme. |
| 620 |
% \begin{macrocode} |
| 621 |
\bool_if:NF \l_tmpa_bool |
| 622 |
{ |
| 623 |
\@@_encode_suffix_alt:N \l_tmpa_str |
| 624 |
\@@_if_family_exists:nTF { \l_@@_fontbasefamily_str\l_tmpa_str } |
| 625 |
{ \fontfamily { \l_@@_fontbasefamily_str\l_tmpa_str } } |
| 626 |
{ \fontfamily \l_@@_fontbasefamily_str } |
| 627 |
} |
| 628 |
} |
| 629 |
% \end{macrocode} |
| 630 |
% \end{macro} |
| 631 |
% |
| 632 |
% \begin{macro}{\@@_set_mathversion:} |
| 633 |
% Sets the math version according to the current math weight and figure |
| 634 |
% alignment. |
| 635 |
% \begin{macrocode} |
| 636 |
\cs_new_protected:Nn \@@_set_mathversion: |
| 637 |
{ |
| 638 |
\str_clear:N \l_tmpa_str |
| 639 |
\str_if_eq:NNT \l_@@_mathweight_str \c_@@_bold_str |
| 640 |
{ \str_put_right:Nn \l_tmpa_str { bold } } |
| 641 |
\str_if_eq:NNT \l_@@_mathalign_str \c_@@_tabular_str |
| 642 |
{ \str_put_right:Nn \l_tmpa_str { tabular } } |
| 643 |
\str_if_empty:NTF \l_tmpa_str |
| 644 |
{ \mathversion { normal } } |
| 645 |
{ \mathversion { \l_tmpa_str } } |
| 646 |
} |
| 647 |
% \end{macrocode} |
| 648 |
% \end{macro} |
| 649 |
% |
| 650 |
% \subsection{Decoding} |
| 651 |
% |
| 652 |
% \begin{macro}{\@@_decode_suffix:n,\@@_decode_suffix:V} |
| 653 |
% Takes a font family suffix like |TOsF| and sets the current font |
| 654 |
% figure style and figure alignment accordingly. Iterates through all |
| 655 |
% suffixes corresponding to the proportional version of a figure style |
| 656 |
% before it iterates through all suffixes corresponding to the tabular |
| 657 |
% versions until the given suffix is found. Does not alter the current |
| 658 |
% figure alignment the suffix is ambiguous. |
| 659 |
% \begin{macrocode} |
| 660 |
\cs_new_protected:Nn \@@_decode_suffix:n |
| 661 |
{ |
| 662 |
\str_set:Nn \l_tmpa_str {#1} |
| 663 |
\bool_set_false:N \l_tmpa_bool |
| 664 |
\prop_map_inline:Nn \g_@@_figurestyles_proportional_prop |
| 665 |
{ |
| 666 |
\clist_if_in:nVT {##2} \l_tmpa_str |
| 667 |
{ |
| 668 |
\str_set:Nn \l_@@_fontfigurestyle_str {##1} |
| 669 |
\prop_get:NnNTF \g_@@_figurestyles_tabular_prop {##1} \l_tmpa_clist |
| 670 |
{ |
| 671 |
\clist_if_in:NVF \l_tmpa_clist \l_tmpa_str |
| 672 |
{ |
| 673 |
\str_set_eq:NN \l_@@_fontfigurealignment_str |
| 674 |
\c_@@_proportional_str |
| 675 |
} |
| 676 |
} |
| 677 |
{ |
| 678 |
\str_set_eq:NN \l_@@_fontfigurealignment_str |
| 679 |
\c_@@_proportional_str |
| 680 |
} |
| 681 |
\prop_map_break:n { \bool_set_true:N \l_tmpa_bool } |
| 682 |
} |
| 683 |
} |
| 684 |
\bool_if:NF \l_tmpa_bool |
| 685 |
{ |
| 686 |
\prop_map_inline:Nn \g_@@_figurestyles_tabular_prop |
| 687 |
{ |
| 688 |
\clist_if_in:nVT {##2} \l_tmpa_str |
| 689 |
{ |
| 690 |
\str_set:Nn \l_@@_fontfigurestyle_str {##1} |
| 691 |
\str_set_eq:NN \l_@@_fontfigurealignment_str |
| 692 |
\c_@@_tabular_str |
| 693 |
\prop_map_break: |
| 694 |
} |
| 695 |
} |
| 696 |
} |
| 697 |
} |
| 698 |
\cs_generate_variant:Nn \@@_decode_suffix:n { V } |
| 699 |
% \end{macrocode} |
| 700 |
% \end{macro} |
| 701 |
% |
| 702 |
% \begin{macro}{\@@_decode_fontfamily_alt:n, |
| 703 |
% \@@_decode_fontfamily_alt:V, |
| 704 |
% \@@_decode_fontfamily_alt_aux:w} |
| 705 |
% Tries to decode the given font family name using the \emph{alternate} |
| 706 |
% four-letter scheme where the last letter is either |x| for lining or |
| 707 |
% |j| for text and sets the font base family and figure style accordingly. |
| 708 |
% Note that the current figure alignment is not altered by this command. |
| 709 |
% \begin{macrocode} |
| 710 |
\cs_new_protected:Nn \@@_decode_fontfamily_alt:n |
| 711 |
{ |
| 712 |
\str_set:Nn \l_@@_fontbasefamily_str {#1} |
| 713 |
\@@_decode_fontfamily_alt_aux:w #1 \q_stop |
| 714 |
} |
| 715 |
\cs_generate_variant:Nn \@@_decode_fontfamily_alt:n { V } |
| 716 |
% \end{macrocode} |
| 717 |
% \begin{macrocode} |
| 718 |
\cs_new_protected:Npn \@@_decode_fontfamily_alt_aux:w #1#2#3#4 \q_stop |
| 719 |
{ |
| 720 |
\str_if_eq:nnT {#4} {x} |
| 721 |
{ |
| 722 |
\str_set:Nn \l_@@_fontbasefamily_str { #1#2#3 } |
| 723 |
\str_set_eq:NN \l_@@_fontfigurestyle_str \c_@@_lining_str |
| 724 |
} |
| 725 |
\str_if_eq:nnT {#4} {j} |
| 726 |
{ |
| 727 |
\str_set:Nn \l_@@_fontbasefamily_str { #1#2#3 } |
| 728 |
\str_set_eq:NN \l_@@_fontfigurestyle_str \c_@@_text_str |
| 729 |
} |
| 730 |
} |
| 731 |
% \end{macrocode} |
| 732 |
% \end{macro} |
| 733 |
% |
| 734 |
% \begin{macro}{\@@_get_fontfamily:} |
| 735 |
% Evaluates the current font family and infers the current figure |
| 736 |
% style, figure alignment and base family. |
| 737 |
% \begin{macrocode} |
| 738 |
\cs_new_protected:Nn \@@_get_fontfamily: |
| 739 |
{ |
| 740 |
\@@_split_family:VNNTF \f@family \l_@@_fontbasefamily_str \l_tmpa_str |
| 741 |
{ \@@_decode_suffix:V \l_tmpa_str } |
| 742 |
{ \@@_decode_fontfamily_alt:V \f@family } |
| 743 |
} |
| 744 |
% \end{macrocode} |
| 745 |
% \end{macro} |
| 746 |
% |
| 747 |
% \begin{macro}{\@@_get_mathversion:} |
| 748 |
% Evaluates the current math version and infers the current math weight |
| 749 |
% and figure alignment. |
| 750 |
% \begin{macrocode} |
| 751 |
\cs_new_protected:Nn \@@_get_mathversion: |
| 752 |
{ |
| 753 |
\str_if_in:NnTF \math@version { bold } |
| 754 |
{ \str_set_eq:NN \l_@@_mathweight_str \c_@@_bold_str } |
| 755 |
{ \str_set_eq:NN \l_@@_mathweight_str \c_@@_normal_str } |
| 756 |
\str_if_in:NnTF \math@version { tabular } |
| 757 |
{ \str_set_eq:NN \l_@@_mathalign_str \c_@@_tabular_str } |
| 758 |
{ \str_set_eq:NN \l_@@_mathalign_str \c_@@_proportional_str } |
| 759 |
} |
| 760 |
% \end{macrocode} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% \subsection{User functions} |
| 764 |
% |
| 765 |
% \begin{macro}{\fontfigurestyle,\@@_fontfigurestyle:n,\@@_fontfigurestyle:e} |
| 766 |
% Sets the font figure style. |
| 767 |
% \begin{macrocode} |
| 768 |
\ProvideDocumentCommand \fontfigurestyle {m} |
| 769 |
{ \@@_fontfigurestyle:e {#1} } |
| 770 |
% \end{macrocode} |
| 771 |
% \begin{macrocode} |
| 772 |
\cs_new_protected:Nn \@@_fontfigurestyle:n |
| 773 |
{ |
| 774 |
\bool_if:nTF |
| 775 |
{ |
| 776 |
\prop_if_in_p:Nn \g_@@_figurestyles_proportional_prop {#1} || |
| 777 |
\prop_if_in_p:Nn \g_@@_figurestyles_tabular_prop {#1} |
| 778 |
} |
| 779 |
{ |
| 780 |
\@@_get_fontfamily: |
| 781 |
\str_set:Nn \l_@@_fontfigurestyle_str {#1} |
| 782 |
\@@_set_fontfamily: |
| 783 |
} |
| 784 |
{ |
| 785 |
\@@_warning:nn { unknown-figurestyle } {#1} |
| 786 |
} |
| 787 |
} |
| 788 |
\cs_generate_variant:Nn \@@_fontfigurestyle:n { e } |
| 789 |
% \end{macrocode} |
| 790 |
% \end{macro} |
| 791 |
% |
| 792 |
% \begin{macro}{\fontfigurealignment, |
| 793 |
% \@@_fontfigurealignment:n, |
| 794 |
% \@@_fontfigurealignment:e} |
| 795 |
% Sets the font figure alignment. |
| 796 |
% \begin{macrocode} |
| 797 |
\ProvideDocumentCommand \fontfigurealignment {m} |
| 798 |
{ \@@_fontfigurealignment:e {#1} } |
| 799 |
% \end{macrocode} |
| 800 |
% \begin{macrocode} |
| 801 |
\cs_new_protected:Nn \@@_fontfigurealignment:n |
| 802 |
{ |
| 803 |
\bool_if:nTF |
| 804 |
{ |
| 805 |
\str_if_eq_p:Vn \c_@@_proportional_str {#1} || |
| 806 |
\str_if_eq_p:Vn \c_@@_tabular_str {#1} |
| 807 |
} |
| 808 |
{ |
| 809 |
\@@_get_fontfamily: |
| 810 |
\str_set:Nn \l_@@_fontfigurealignment_str {#1} |
| 811 |
\@@_set_fontfamily: |
| 812 |
} |
| 813 |
{ |
| 814 |
\@@_warning:nn { unknown-figurealignment } {#1} |
| 815 |
} |
| 816 |
} |
| 817 |
\cs_generate_variant:Nn \@@_fontfigurealignment:n { e } |
| 818 |
% \end{macrocode} |
| 819 |
% \end{macro} |
| 820 |
% |
| 821 |
% \begin{macro}{\fontbasefamily} |
| 822 |
% Sets the base font family. |
| 823 |
% \begin{macrocode} |
| 824 |
\ProvideDocumentCommand \fontbasefamily {m} |
| 825 |
{ |
| 826 |
\@@_get_fontfamily: |
| 827 |
\str_set:Ne \l_@@_fontbasefamily_str {#1} |
| 828 |
\@@_set_fontfamily: |
| 829 |
} |
| 830 |
% \end{macrocode} |
| 831 |
% \end{macro} |
| 832 |
% |
| 833 |
% \begin{macro}{\mathweight,\@@_mathweight:n,\@@_mathweight:e} |
| 834 |
% Sets the math weight. |
| 835 |
% \begin{macrocode} |
| 836 |
\ProvideDocumentCommand \mathweight {m} |
| 837 |
{ \@@_mathweight:e {#1} } |
| 838 |
% \end{macrocode} |
| 839 |
% \begin{macrocode} |
| 840 |
\cs_new_protected:Nn \@@_mathweight:n |
| 841 |
{ |
| 842 |
\bool_if:nTF |
| 843 |
{ |
| 844 |
\str_if_eq_p:Vn \c_@@_normal_str {#1} || |
| 845 |
\str_if_eq_p:Vn \c_@@_bold_str {#1} |
| 846 |
} |
| 847 |
{ |
| 848 |
\@@_get_mathversion: |
| 849 |
\str_set:Nn \l_@@_mathweight_str {#1} |
| 850 |
\@@_set_mathversion: |
| 851 |
} |
| 852 |
{ |
| 853 |
\@@_warning:nn { unknown-mathweight } {#1} |
| 854 |
} |
| 855 |
} |
| 856 |
\cs_generate_variant:Nn \@@_mathweight:n { e } |
| 857 |
% \end{macrocode} |
| 858 |
% \end{macro} |
| 859 |
% |
| 860 |
% \begin{macro}{\mathfigurealignment, |
| 861 |
% \@@_mathfigurealignment:n, |
| 862 |
% \@@_mathfigurealignment:e} |
| 863 |
% Sets the math figure alignment. |
| 864 |
% \begin{macrocode} |
| 865 |
\ProvideDocumentCommand \mathfigurealignment {m} |
| 866 |
{ \@@_mathfigurealignment:e {#1} } |
| 867 |
% \end{macrocode} |
| 868 |
% \begin{macrocode} |
| 869 |
\cs_new_protected:Nn \@@_mathfigurealignment:n |
| 870 |
{ |
| 871 |
\bool_if:nTF |
| 872 |
{ |
| 873 |
\str_if_eq_p:Vn \c_@@_proportional_str {#1} || |
| 874 |
\str_if_eq_p:Vn \c_@@_tabular_str {#1} |
| 875 |
} |
| 876 |
{ |
| 877 |
\@@_get_mathversion: |
| 878 |
\str_set:Nn \l_@@_mathalign_str {#1} |
| 879 |
\@@_set_mathversion: |
| 880 |
} |
| 881 |
{ |
| 882 |
\@@_warning:nn { unknown-mathfigurealignment } {#1} |
| 883 |
} |
| 884 |
} |
| 885 |
\cs_generate_variant:Nn \@@_mathfigurealignment:n { e } |
| 886 |
% \end{macrocode} |
| 887 |
% \end{macro} |
| 888 |
% |
| 889 |
% \begin{macro}{\txfigures,\lnfigures} |
| 890 |
% Higher-level commands for choosing the font figure style. |
| 891 |
% \begin{macrocode} |
| 892 |
\ProvideDocumentCommand \txfigures {} |
| 893 |
{ |
| 894 |
\@nomath \txfigures |
| 895 |
\bool_if:NTF \g_@@_fontspec_bool |
| 896 |
{ \addfontfeature{ Numbers = OldStyle } } |
| 897 |
{ |
| 898 |
\fontfigurestyle { \c_@@_text_str } |
| 899 |
\selectfont |
| 900 |
} |
| 901 |
} |
| 902 |
\ProvideDocumentCommand \lnfigures {} |
| 903 |
{ |
| 904 |
\@nomath \lnfigures |
| 905 |
\bool_if:NTF \g_@@_fontspec_bool |
| 906 |
{ \addfontfeature{ Numbers = Lining } } |
| 907 |
{ |
| 908 |
\fontfigurestyle { \c_@@_lining_str } |
| 909 |
\selectfont |
| 910 |
} |
| 911 |
} |
| 912 |
% \end{macrocode} |
| 913 |
% \end{macro} |
| 914 |
% \begin{macro}{\prfigures,\tbfigures} |
| 915 |
% Higher-level commands for choosing the font figure alignment. |
| 916 |
% \begin{macrocode} |
| 917 |
\ProvideDocumentCommand \prfigures {} |
| 918 |
{ |
| 919 |
\@nomath\prfigures |
| 920 |
\bool_if:NTF \g_@@_fontspec_bool |
| 921 |
{ \addfontfeature{ Numbers = Proportional } } |
| 922 |
{ |
| 923 |
\fontfigurealignment { \c_@@_proportional_str } |
| 924 |
\selectfont |
| 925 |
} |
| 926 |
} |
| 927 |
\ProvideDocumentCommand \tbfigures {} |
| 928 |
{ |
| 929 |
\@nomath\tbfigures |
| 930 |
\bool_if:NTF \g_@@_fontspec_bool |
| 931 |
{ \addfontfeature{ Numbers = Monospaced } } |
| 932 |
{ |
| 933 |
\fontfigurealignment { \c_@@_tabular_str } |
| 934 |
\selectfont |
| 935 |
} |
| 936 |
} |
| 937 |
% \end{macrocode} |
| 938 |
% \end{macro} |
| 939 |
% |
| 940 |
% \begin{macro}{\boldmath,\unboldmath} |
| 941 |
% Reimplementation of \cs{boldmath} and \cs{unboldmath} to only change the |
| 942 |
% math weight. |
| 943 |
% \begin{macrocode} |
| 944 |
\RenewDocumentCommand \boldmath {} |
| 945 |
{ |
| 946 |
\@nomath \boldmath |
| 947 |
\mathweight { \c_@@_bold_str } |
| 948 |
} |
| 949 |
\RenewDocumentCommand \unboldmath {} |
| 950 |
{ |
| 951 |
\@nomath \unboldmath |
| 952 |
\mathweight { \c_@@_normal_str } |
| 953 |
} |
| 954 |
% \end{macrocode} |
| 955 |
% \end{macro} |
| 956 |
% \begin{macro}{\tabularmath,\proportionalmath} |
| 957 |
% Higher-level commands to change the math figure alignment. |
| 958 |
% \begin{macrocode} |
| 959 |
\ProvideDocumentCommand \proportionalmath {} |
| 960 |
{ |
| 961 |
\@nomath \proportionalmath |
| 962 |
\mathfigurealignment { \c_@@_proportional_str } |
| 963 |
} |
| 964 |
\ProvideDocumentCommand \tabularmath {} |
| 965 |
{ |
| 966 |
\@nomath \tabularmath |
| 967 |
\mathfigurealignment { \c_@@_tabular_str } |
| 968 |
} |
| 969 |
% \end{macrocode} |
| 970 |
% \end{macro} |
| 971 |
% |
| 972 |
% \begin{macro}{\textfigures,\liningfigures, |
| 973 |
% \tabularfigures,\proportionalfigures} |
| 974 |
% Text font commands which apply a certain figure style or figure alignment |
| 975 |
% to their argument. |
| 976 |
% \begin{macrocode} |
| 977 |
\DeclareTextFontCommand {\textfigures} {\txfigures} |
| 978 |
\DeclareTextFontCommand {\liningfigures }{\lnfigures} |
| 979 |
\DeclareTextFontCommand {\tabularfigures} {\tbfigures\tabularmath} |
| 980 |
\DeclareTextFontCommand {\proportionalfigures} {\prfigures\proportionalmath} |
| 981 |
% \end{macrocode} |
| 982 |
% \end{macro} |
| 983 |
% |
| 984 |
% \begin{macro}{\figureversion} |
| 985 |
% Convenience macro for setting font figure style and alignment simultaneously. |
| 986 |
% \begin{macrocode} |
| 987 |
\ProvideDocumentCommand \figureversion {m} |
| 988 |
{ |
| 989 |
\clist_set:Ne \l_tmpa_clist {#1} |
| 990 |
\clist_map_inline:Nn \l_tmpa_clist |
| 991 |
{ |
| 992 |
\prop_get:NnNTF \g_@@_figureversions_prop {##1} \l_tmpa_tl |
| 993 |
{ \tl_use:N \l_tmpa_tl } |
| 994 |
{ \@@_warning:nn { unknown-figureversion } {##1} } |
| 995 |
} |
| 996 |
} |
| 997 |
% \end{macrocode} |
| 998 |
% \end{macro} |
| 999 |
% |
| 1000 |
% \subsection{Public code-level functions} |
| 1001 |
% |
| 1002 |
% \begin{macro}{\figureversions_new_figurestyle:nnn, |
| 1003 |
% \figureversions_new_figurestyle:Vnn, |
| 1004 |
% \@@_new_figurestyle_proportional:nn, |
| 1005 |
% \@@_new_figurestyle_tabular:nn} |
| 1006 |
% Defines the figure style |#1| with the corresponding font family suffixes |
| 1007 |
% listed in the \meta{comma lists} |#2| for proportional figures and |#3| for |
| 1008 |
% tabular figures. Does nothing if |#1| is already defined as a figure style. |
| 1009 |
% \begin{macrocode} |
| 1010 |
\cs_new_protected:Nn \@@_new_figurestyle_proportional:nn |
| 1011 |
{ |
| 1012 |
\clist_set:Ne \l_tmpa_clist { \tl_to_str:n {#2} } |
| 1013 |
\clist_if_empty:NF \l_tmpa_clist |
| 1014 |
{ |
| 1015 |
\prop_gput_if_not_in:NnV \g_@@_figurestyles_proportional_prop {#1} |
| 1016 |
\l_tmpa_clist |
| 1017 |
} |
| 1018 |
} |
| 1019 |
\cs_new_protected:Nn \@@_new_figurestyle_tabular:nn |
| 1020 |
{ |
| 1021 |
\clist_set:Ne \l_tmpa_clist { \tl_to_str:n {#2} } |
| 1022 |
\clist_if_empty:NF \l_tmpa_clist |
| 1023 |
{ |
| 1024 |
\prop_gput_if_not_in:NnV \g_@@_figurestyles_tabular_prop {#1} |
| 1025 |
\l_tmpa_clist |
| 1026 |
} |
| 1027 |
} |
| 1028 |
\cs_new_protected:Nn \figureversions_new_figurestyle:nnn |
| 1029 |
{ |
| 1030 |
\@@_new_figurestyle_proportional:nn {#1} {#2} |
| 1031 |
\@@_new_figurestyle_tabular:nn {#1} {#3} |
| 1032 |
} |
| 1033 |
\cs_generate_variant:Nn \figureversions_new_figurestyle:nnn { V } |
| 1034 |
% \end{macrocode} |
| 1035 |
% \end{macro} |
| 1036 |
% |
| 1037 |
% \begin{macro}{\figureversions_new_figureversion:nn} |
| 1038 |
% Defines the figure version |#1| and assigns the code |#2| to it. |
| 1039 |
% Does nothing if |#1| is already defined as a figure version. |
| 1040 |
% \begin{macrocode} |
| 1041 |
\cs_new_protected:Nn \figureversions_new_figureversion:nn |
| 1042 |
{ \prop_gput_if_not_in:Nnn \g_@@_figureversions_prop {#1} {#2} } |
| 1043 |
% \end{macrocode} |
| 1044 |
% \end{macro} |
| 1045 |
% |
| 1046 |
% \subsection{Initialization} |
| 1047 |
% |
| 1048 |
% Finally, we declare the pre-defined figure styles `text' and `lining' and the |
| 1049 |
% initial keys for the \cs{figureversion} command. |
| 1050 |
% \begin{macrocode} |
| 1051 |
\figureversions_new_figurestyle:Vnn \c_@@_text_str { OsF } { TOsF } |
| 1052 |
\figureversions_new_figurestyle:Vnn \c_@@_lining_str { LF } { TLF } |
| 1053 |
% \end{macrocode} |
| 1054 |
% \begin{macrocode} |
| 1055 |
\figureversions_new_figureversion:nn { text } { \txfigures } |
| 1056 |
\figureversions_new_figureversion:nn { osf } { \txfigures } |
| 1057 |
\figureversions_new_figureversion:nn { lining } { \lnfigures } |
| 1058 |
\figureversions_new_figureversion:nn { lf } { \lnfigures } |
| 1059 |
\figureversions_new_figureversion:nn { tabular } |
| 1060 |
{ \tbfigures \tabularmath } |
| 1061 |
\figureversions_new_figureversion:nn { tab } |
| 1062 |
{ \tbfigures \tabularmath } |
| 1063 |
\figureversions_new_figureversion:nn { proportional } |
| 1064 |
{ \prfigures \proportionalmath } |
| 1065 |
\figureversions_new_figureversion:nn { prop } |
| 1066 |
{ \prfigures \proportionalmath } |
| 1067 |
% \end{macrocode} |
| 1068 |
% |
| 1069 |
% \subsection{Hooks} |
| 1070 |
% |
| 1071 |
% At the start of the document, we check whether math versions `tabular' and |
| 1072 |
% `boldtabular' have been defined. If not, we provide a default by copying the |
| 1073 |
% state of `normal' respectively `bold'. |
| 1074 |
% \begin{macrocode} |
| 1075 |
\AtBeginDocument |
| 1076 |
{ |
| 1077 |
\@@_copy_mathversion_if_undefined:nn { tabular } { normal } |
| 1078 |
\@@_copy_mathversion_if_undefined:nn { boldtabular } { bold } |
| 1079 |
% \end{macrocode} |
| 1080 |
% Test for \pkg{fontspec}. |
| 1081 |
% \begin{macrocode} |
| 1082 |
\IfPackageLoadedT { fontspec } |
| 1083 |
{ \bool_gset_true:N \g_@@_fontspec_bool } |
| 1084 |
% \end{macrocode} |
| 1085 |
% Finally, we redefine some commands for use in PDF strings. |
| 1086 |
% \begin{macrocode} |
| 1087 |
\IfPackageLoadedT { hyperref } |
| 1088 |
{ |
| 1089 |
\pdfstringdefDisableCommands |
| 1090 |
{ |
| 1091 |
\cs_set_eq:NN \figureversion \use_none:n |
| 1092 |
\cs_set_eq:NN \fontfigurestyle \use_none:n |
| 1093 |
\cs_set_eq:NN \fontfigurealignment \use_none:n |
| 1094 |
\cs_set_eq:NN \fontbasefamily \use_none:n |
| 1095 |
\cs_set_eq:NN \mathweight \use_none:n |
| 1096 |
\cs_set_eq:NN \mathfigurealignment \use_none:n |
| 1097 |
\cs_set_eq:NN \txfigures \relax |
| 1098 |
\cs_set_eq:NN \lnfigures \relax |
| 1099 |
\cs_set_eq:NN \prfigures \relax |
| 1100 |
\cs_set_eq:NN \tbfigures \relax |
| 1101 |
\cs_set_eq:NN \proportionalmath \relax |
| 1102 |
\cs_set_eq:NN \tabularmath \relax |
| 1103 |
\cs_set_eq:NN \textfigures \use:n |
| 1104 |
\cs_set_eq:NN \liningfigures \use:n |
| 1105 |
\cs_set_eq:NN \tabularfigures \use:n |
| 1106 |
\cs_set_eq:NN \proportionalfigures \use:n |
| 1107 |
} |
| 1108 |
} |
| 1109 |
} |
| 1110 |
%</package> |
| 1111 |
% \end{macrocode} |
| 1112 |
% |
| 1113 |
% \RemoveFromHook{sffamily} |
| 1114 |
% \end{implementation} |
| 1115 |
% |
| 1116 |
% \begin{thebibliography}{9} |
| 1117 |
% |
| 1118 |
% \bibitem{nfss} |
| 1119 |
% \LaTeX\ Project Team: |
| 1120 |
% \LaTeXe\ font selection. |
| 1121 |
% \url{https://www.latex-project.org/help/documentation/fntguide.pdf} |
| 1122 |
% |
| 1123 |
% \bibitem{ltnews31} |
| 1124 |
% \LaTeX\ News. Issue 31, February 2020. |
| 1125 |
% \url{https://www.latex-project.org/news/latex2e-news/ltnews31.pdf} |
| 1126 |
% |
| 1127 |
% \end{thebibliography} |
| 1128 |
% |
| 1129 |
% \Finale |