I am trying to implement a workaround for the error I get when inputting a table as external file in a file using \input. The code snippet below works for this purpose:
\IfFileExists{filename}
\ExplSyntaxOn \cs_new:Npn \expandableinput #1
{ \use:c { @@input } { \file_full_name:n {#1} } }
\AddToHook{env/tabular/begin}
{ \cs_set_eq:NN \input \expandableinput }
\AddToHook{env/tabular*/begin}
{ \cs_set_eq:NN \input \expandableinput }
\ExplSyntaxOff
I now want to only apply it on some computers, not others, so wanted to put it inside \IfFileExists. I don't know whether it is the best solution, but it certainly does not work:
\documentclass[12pt,fleqn]{article}
\IfFileExists{filename}
{ \ExplSyntaxOn \cs_new:Npn \expandableinput #1
{ \use:c { @@input } { \file_full_name:n {#1} } }
\AddToHook{env/tabular/begin}
{ \cs_set_eq:NN \input \expandableinput }
\AddToHook{env/tabular*/begin}
{ \cs_set_eq:NN \input \expandableinput }
\ExplSyntaxOff}
{}
\begin{document}
\end{document}
I would like to make it work if possible. Alternative solutions would also be welcome. E.g., would it work to use \IfFileExists to define some other variable, and use it as argument to a conditional?
expl3explicitly (I added it in my answer). Writing\ExplSyntaxOninside the argument there is wrong (so much that it doesn't work for TL 2021), and it only works for TL 2019 because the False branch is taken – Phelype Oleinik Apr 07 '22 at 23:25