Hi,
Tassilo Horn <[email protected]> wrote:
> We could do that only if l3msg is loaded for the current document. I
> would like to try it but cannot find out which TeXLive package I need
> for l3msg. I have
>
> texlive-{bin,core,latexextra,bibtexextra,pictures,science,fontsextra}
>
> but apparently there is no l3msg... Any hints?
l3msg is just this:
https://github.com/latex3/latex3/blob/main/l3kernel/l3msg.dtx
It's a “chapter” of the LaTeX kernel in its literate programming form
('texdoc interface3' calls it a module). There is no \usepackage nor any
'import'-alike thingy needed to have it available. If you run current
LaTeX, l3msg is there, in the format (in earlier releases of the LaTeX
kernel, \usepackage{expl3} was needed).
Unrelated to your question but related to the thread: there is another,
less common way to print error messages, which works in expansion-only
contexts: \msg_expandable_error:nnn and friends. Since neither \message
nor \write work in expansion-only contexts, \msg_expandable_error:nnn
works by triggering a specially crafted “Undefined control sequence”
error, as it seems. The result is slightly ugly as compared to normal
error messages, but this is the only way I know to print error messages
in expansion-only contexts. The attached document shows an example,
which yields the following output on the terminal:
./document.tex:19: Undefined control sequence.
<argument> \::error
! foo: This is an error message: 'some stuff'.
l.19 \edef\zzz{\foomsg{some stuff}
}
Regards
--
Florent
\documentclass{article}
\ExplSyntaxOn
\msg_new:nnn { foo } { some-error } { This~is~an~error~message:~'#1'. }
\cs_new:Npn \foo_msg:n #1
{
\msg_expandable_error:nnn { foo } { some-error } {#1}
}
\NewExpandableDocumentCommand \foomsg { m }
{
\foo_msg:n {#1}
}
\ExplSyntaxOff
\begin{document}
\edef\zzz{\foomsg{some stuff}}
\end{document}