I have some LaTeX3 code that generates matrices and uses the hhline package internally. In LaTeX3 the ~
character is a special character, used for inserting spaces in strings, and using \c_tilde_str
results in hhline ignoring the character and giving the warning:
Package hhline Warning: macro:->~ ignored in \hhline argument
I have tried various tricks such as defining
\cs_new_protected:Npn \__active_tilde { \~ }
\group_begin:
\char_set_active_eq:nN {`~} \__active_tilde
\group_end:
and then using \__active_tilde
but this does not work either.
Here is a minimal working example that exhibits my problem:
\documentclass{article}
\usepackage{hhline}
\usepackage{expl3}
\ExplSyntaxOn
\newcommand\mat{
\typeout{----------------------------------------}
\begin{array}{cc} \hhline{~-} 1&2 \end{array}
\typeout{----------------------------------------}
\begin{array}{cc} \hhline{\c_tilde_str-} 1&2 \end{array}
\typeout{----------------------------------------}
}
\ExplSyntaxOff
\begin{document}
$\mat$
\end{document}
This produces the output
with the overline over the 1
's instead of the 2
's. The log file contains the lines:
Package hhline Warning: macro:->~ ignored in \hhline argument
(hhline) on input line 24.
This shows that the first ~
is being ignored, as it should be since ~
is a space in expl
code, and that the \c_tilde_str
is not being recognised as a ~
by hhline
.
[I know that the tabularray
package gives other ways of doing this but it does not work in my real use-case because it does not support expansion in its key-value syntax -- and for the number of tables that I need to produce there may be other performance issues...]