Skip to content

Commit 83fc5e6

Browse files
committed
Controlled error for unknown font series
Fixes #856.
1 parent f4a1b83 commit 83fc5e6

5 files changed

Lines changed: 137 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
88

99
## [Unreleased]
1010

11+
### Fixed
12+
13+
- Issue controlled warning for unknown font series (see
14+
issue [\#856](https://github.com/josephwright/siunitx/issues/856))
15+
1116
## [v3.5.0] - 2026-03-14
1217

1318
### Added

siunitx-print.dtx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,11 @@
623623
}
624624
}
625625
\cs_new:Npn \@@_convert_series:n #1
626-
{ \tl_use:c { l_@@_version_ #1 _tl } }
626+
{
627+
\tl_if_exist:cTF { l_@@_version_ #1 _tl }
628+
{ \tl_use:c { l_@@_version_ #1 _tl } }
629+
{ \msg_expandable_error:nnn { siunitx } { unknown-series } {#1} }
630+
}
627631
\cs_generate_variant:Nn \@@_convert_series:n { v }
628632
\cs_new_protected:Npn \@@_math_auxi:n #1
629633
{
@@ -1113,6 +1117,13 @@
11131117
% \end{macro}
11141118
% \end{macro}
11151119
%
1120+
% \subsection{Messages}
1121+
%
1122+
% \begin{macrocode}
1123+
\msg_new:nnn { siunitx } { unknown-series }
1124+
{ Unknown~font~series~"#1"! }
1125+
% \end{macrocode}
1126+
%
11161127
% \subsection{Standard settings for module options}
11171128
%
11181129
% Some of these follow naturally from the point of definition

testfiles/siunitx-print.luatex.tlg

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,4 +3438,60 @@ l. ... }
34383438
<argument> \l_tmpa_box
34393439
l. ... }
34403440
============================================================
3441+
============================================================
3442+
TEST 26: Unknown series
3443+
============================================================
3444+
! Use of \??? doesn't match its definition.
3445+
<argument> \???
3446+
! Package siunitx Error: Unknown font series "foo"!
3447+
l. ... }
3448+
If you say, e.g., `\def\a1{...}', then you must always
3449+
put `1' after `\a', since control sequence names are
3450+
made up of letters only. The macro here has not been
3451+
followed by the required stuff, so I'm ignoring it.
3452+
> \box...=
3453+
\hbox(4.30554+0.0)x8.78014, direction TLT
3454+
.\mathon
3455+
.\OML/cmm/m/it/10 m
3456+
.\mathoff
3457+
! OK.
3458+
<argument> \l_tmpa_box
3459+
l. ... }
3460+
! Use of \??? doesn't match its definition.
3461+
<argument> \???
3462+
! Package siunitx Error: Unknown font series "foo"!
3463+
l. ... }
3464+
If you say, e.g., `\def\a1{...}', then you must always
3465+
put `1' after `\a', since control sequence names are
3466+
made up of letters only. The macro here has not been
3467+
followed by the required stuff, so I'm ignoring it.
3468+
> \box...=
3469+
\hbox(4.30554+0.0)x8.78014, direction TLT
3470+
.\mathon
3471+
.\OML/cmm/m/it/10 m
3472+
.\mathoff
3473+
! OK.
3474+
<argument> \l_tmpa_box
3475+
l. ... }
3476+
LaTeX Font Warning: Font shape `TU/lmr/foo/n' undefined
3477+
(Font) using `TU/lmr/m/n' instead on input line ....
3478+
> \box...=
3479+
\hbox(4.42+0.0)x8.33, direction TLT
3480+
.\hbox(4.42+0.0)x8.33, direction TLT
3481+
..\TU/lmr/m/n/10 m
3482+
! OK.
3483+
<argument> \l_tmpa_box
3484+
l. ... }
3485+
> \box...=
3486+
\hbox(4.42+0.0)x8.33, direction TLT
3487+
.\mathon
3488+
.\hbox(4.42+0.0)x8.33, direction TLT
3489+
..\hbox(4.42+0.0)x8.33, direction TLT
3490+
...\TU/lmr/foo/n/10 m
3491+
.\mathoff
3492+
! OK.
3493+
<argument> \l_tmpa_box
3494+
l. ... }
3495+
============================================================
34413496
(siunitx-print.aux)
3497+
LaTeX Font Warning: Some font shapes were not available, defaults substituted.

testfiles/siunitx-print.lvt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,12 @@
332332
\test:nn { unit } { \ensuremath { \times } }
333333
}
334334

335+
\TEST { Unknown~series }
336+
{
337+
\keys_set:nn { siunitx }
338+
{ reset-text-series = false, text-series-to-math = true }
339+
\cs_set_nopar:cpn { f@series } { foo }
340+
\test:nn { unit } { m }
341+
}
342+
335343
\end{document}

testfiles/siunitx-print.tlg

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,4 +3402,60 @@ l. ... }
34023402
<argument> \l_tmpa_box
34033403
l. ... }
34043404
============================================================
3405+
============================================================
3406+
TEST 26: Unknown series
3407+
============================================================
3408+
! Use of \??? doesn't match its definition.
3409+
<argument> \???
3410+
! Package siunitx Error: Unknown font series "foo"!
3411+
l. ... }
3412+
If you say, e.g., `\def\a1{...}', then you must always
3413+
put `1' after `\a', since control sequence names are
3414+
made up of letters only. The macro here has not been
3415+
followed by the required stuff, so I'm ignoring it.
3416+
> \box...=
3417+
\hbox(4.30554+0.0)x8.78014
3418+
.\mathon
3419+
.\OML/cmm/m/it/10 m
3420+
.\mathoff
3421+
! OK.
3422+
<argument> \l_tmpa_box
3423+
l. ... }
3424+
! Use of \??? doesn't match its definition.
3425+
<argument> \???
3426+
! Package siunitx Error: Unknown font series "foo"!
3427+
l. ... }
3428+
If you say, e.g., `\def\a1{...}', then you must always
3429+
put `1' after `\a', since control sequence names are
3430+
made up of letters only. The macro here has not been
3431+
followed by the required stuff, so I'm ignoring it.
3432+
> \box...=
3433+
\hbox(4.30554+0.0)x8.78014
3434+
.\mathon
3435+
.\OML/cmm/m/it/10 m
3436+
.\mathoff
3437+
! OK.
3438+
<argument> \l_tmpa_box
3439+
l. ... }
3440+
LaTeX Font Warning: Font shape `OT1/cmr/foo/n' undefined
3441+
(Font) using `OT1/cmr/m/n' instead on input line ....
3442+
> \box...=
3443+
\hbox(4.30554+0.0)x8.33336
3444+
.\hbox(4.30554+0.0)x8.33336
3445+
..\OT1/cmr/m/n/10 m
3446+
! OK.
3447+
<argument> \l_tmpa_box
3448+
l. ... }
3449+
> \box...=
3450+
\hbox(4.30554+0.0)x8.33336
3451+
.\mathon
3452+
.\hbox(4.30554+0.0)x8.33336
3453+
..\hbox(4.30554+0.0)x8.33336
3454+
...\OT1/cmr/foo/n/10 m
3455+
.\mathoff
3456+
! OK.
3457+
<argument> \l_tmpa_box
3458+
l. ... }
3459+
============================================================
34053460
(siunitx-print.aux)
3461+
LaTeX Font Warning: Some font shapes were not available, defaults substituted.

0 commit comments

Comments
 (0)