Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global option math and latest fontspec package #501

Closed
3 of 4 tasks
lvjr opened this issue Feb 17, 2024 · 7 comments
Closed
3 of 4 tasks

Global option math and latest fontspec package #501

lvjr opened this issue Feb 17, 2024 · 7 comments

Comments

@lvjr
Copy link

lvjr commented Feb 17, 2024

Description

My class defines math option as choice key with \DeclareKeys command, but latest fontspec package doesn't like it and throws an error.

! LaTeX Error: Key 'fontspec/math' accepts boolean values only.

Check/indicate

  • Relevant for XeTeX
  • Relevant for LuaTeX
  • Issue tracker has been searched for similar issues?
  • Links to <tex.stackexchange.com> discussion if appropriate

Minimal example demonstrating the issue

\documentclass[math=many]{randexam}
\usepackage{fontspec}
\begin{document}
Test
\end{document}
@davidcarlisle
Copy link
Member

The issue is really with the latex format rather than fontspec. The new l3keys based option handler processes the global document class keys when handling a package, for consistency with traditional latex options.

It's possible that \ProcessKeyOptions could or should simply skip a key of the wrong type rather than throwing this error when processing the classoptions from within a package

Your class could remove the math=many from the global option list so it was not picked up by packages, which would get things working now, but I'm not sure if that's the best long term solution.

\ExplSyntaxOn
\prop_new:N\cEmptyProp
\ExplSyntaxOff
\documentclass[math=many]{randexam}
\makeatletter
\let\@raw@classoptionslist\@empty % or just remove math but simple case here
\makeatother
\usepackage{fontspec}
\begin{document}
Test
\end{document}```

@u-fischer
Copy link
Member

You could also set the unknown handler (and fontspec could do that too):

\documentclass{book}
\ExplSyntaxOn
\DeclareKeys
 {
   math  .choice:,
   math / many .code:n = {\def\blub{abc}},
   math / unknown .code:n={\typeout{class??????}}
 }

\SetKeys{math=many,math=xxxx}
\show\blub

\DeclareKeys
 {
   math    .bool_gset:N = \g__fontspec_math_bool,
   math / unknown .code:n={\typeout{fontspec??????}}
 }
 
\SetKeys{math=true,math=blub}  
\bool_if:NT \g__fontspec_math_bool {\show\yes}

\ExplSyntaxOff

\begin{document}
abc
\end{document}

@wspr
Copy link
Collaborator

wspr commented Feb 18, 2024 via email

@josephwright
Copy link
Member

@wspr We talked about that on the team list :)

@josephwright
Copy link
Member

Somewhere there was an issue about removing keyvals from the unused list: anyone remember where?

@wspr
Copy link
Collaborator

wspr commented Apr 20, 2024

I am thinking of adding code to fontspec to address this. Does a warning make sense?

Package fontspec Warning: The global option 'math=yuck' is not recognised. It w
ill be ignored.

I'm thinking this would cause more harm than help.

@wspr
Copy link
Collaborator

wspr commented Apr 20, 2024

(I thought we had word wrapping for expl3 messages...I guess I need to add it manually)

@wspr wspr closed this as completed in f0bf3fe Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants