add tag
samcarter
*(This question is related to the feature request https://github.com/samcarter/panda/issues/1)*

Consider the following test document:

```
\documentclass[varwidth,border=1pt]{standalone}

\usepackage{expkv}

\ExplSyntaxOn
\makeatletter

\newif\ifBusyPanda@unknownerror
\BusyPanda@unknownerrortrue

\msg_new:nnn { panda } { unknown-font } {
  Font~#1~not~in~look-up~table^^J
  Please~see~section~3.3~of~the~documentation.
}
\cs_generate_variant:Nn \msg_expandable_error:nnn { nne }

\cs_new_nopar:Npn \__panda_unknown_font {
  \ifBusyPanda@unknownerror
    \ekverr{panda}{
      Font~not~in~look-up~table.^^J
      See~section~3.3~of~the~doc.^^J^^J
    }
    \msg_expandable_error:nne { panda } { unknown-font } { \f@family }
  \else
    \sys_if_engine_luatex:T {
      % from https://topanswers.xyz/tex?q=8144#a7753
      \directlua{
        texio.write_nl("
          \string\n 
          Package~panda~Warning:~ Font~\luaescapestring{\f@family}~not~in~look-up~table\string\n 
          (panda)\@spaces\@spaces\@spaces\@spaces Please~see~section~3.3~of~the~documentation.\string\n\string\n
        ")
      }
    }
  \fi
}


\NewExpandableDocumentCommand{ \busyPanda } { m } {
  \str_case_e:nnF { \f@family } {
    {cmdh}{0.785169}
    {cmss}{1.16462}
    {cmtt}{1.14753}
    {cmvtt}{1.28199}
    {cmbr}{1.03998}
  }{
    \__panda_unknown_font
    1
  }
}

\makeatother
\ExplSyntaxOff

\newcommand{\bamboo}{%
  \rule{\busyPanda{}\fontcharht\font`I}{\fontcharht\font`I}%
}

\begin{document}

cmr: \bamboo

\fontfamily{cmbr}\selectfont
cmbr: \bamboo

\end{document}
```

It generates two error messages, one with `\ekverr`, the other using the code by @निरंजन from https://topanswers.xyz/transcript?room=8190&id=178127#c178127

```
! panda Error: Font not in look-up table.
See section 3.3 of the doc.

! Paragraph ended before \<an-expandable-macro>
completed due to above exception.  If the error
summary is  not comprehensible  see the package
documentation.
I will try to recover now.  If you're in inter-
active mode hit <return>  at the ? prompt and I
continue hoping recovery was complete.
<to be read again> 
                   \par 
l.61 cmr: \bamboo
                 
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
```

```
! Use of \??? doesn't match its definition.
<argument> \???  
                 ! Package panda Error: Font cmr not in look-up table
Please...
l.61 cmr: \bamboo
                 
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
```



I like that the `\ekverr` message works nicely in abbreviated form, e.g. as shown in editors like TeXstudio:

![Screenshot 2025-10-08 at 17.22.46.png](/image?hash=a27c224f9707a79a30d38060db15d95d8c981a7e5eadb9713d2a8c116358f711)

Is there a way to include the name of the current font in the `\ekverr` message?
Top Answer
Skillmon
`\ekverr` doesn't expand anything on its own in the second argument, but you can expand everything before it reads its arguments via expansion control. Since you're already in an Expl-context you can use `\exp_args:Nne` to fully expand the message:

```
\documentclass[varwidth,border=1pt]{standalone}

\usepackage{expkv}

\ExplSyntaxOn
\makeatletter

\newif\ifBusyPanda@unknownerror
\BusyPanda@unknownerrortrue

\msg_new:nnn { panda } { unknown-font } {
  Font~#1~not~in~look-up~table^^J
  Please~see~section~3.3~of~the~documentation.
}
\cs_generate_variant:Nn \msg_expandable_error:nnn { nne }

\cs_new_nopar:Npn \__panda_unknown_font {
  \ifBusyPanda@unknownerror
    \exp_args:Nne \ekverr{panda}{
      Font~not~in~look-up~table:~\f@family^^J
      See~section~3.3~of~the~doc.^^J^^J
    }
    \msg_expandable_error:nne { panda } { unknown-font } { \f@family }
  \else
    \sys_if_engine_luatex:T {
      % from https://topanswers.xyz/tex?q=8144#a7753
      \directlua{
        texio.write_nl("
          \string\n
          Package~panda~Warning:~ Font~\luaescapestring{\f@family}~not~in~look-up~table\string\n
          (panda)\@spaces\@spaces\@spaces\@spaces Please~see~section~3.3~of~the~documentation.\string\n\string\n
        ")
      }
    }
  \fi
}


\NewExpandableDocumentCommand{ \busyPanda } { m } {
  \str_case_e:nnF { \f@family } {
    {cmdh}{0.785169}
    {cmss}{1.16462}
    {cmtt}{1.14753}
    {cmvtt}{1.28199}
    {cmbr}{1.03998}
  }{
    \__panda_unknown_font
    1
  }
}

\makeatother
\ExplSyntaxOff

\newcommand{\bamboo}{%
  \rule{\busyPanda{}\fontcharht\font`I}{\fontcharht\font`I}%
}

\begin{document}

cmr: \bamboo

\fontfamily{cmbr}\selectfont
cmbr: \bamboo

\end{document}
```

Note that this will be longer than the maximum length of 59 characters so TeX will shorten the message and display `\ETC` (`panda` are 5 letters and the hardcoded parts of the body are 57 letters (the `^^J` are counted as 1)). You should likely rephrase your error message to be as short as possible.

Note that inside of LuaTeX there is a possibility that `\ekverr` doesn't throw an error (at least with its current definition), and in LuaTeX you could use `tex.error()` to throw an expandable error message without this problem. (that's what's done in ConTeXt as there the `\par`-errors of short macros are ignored.)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.