# Change catcode of @ in a tabular environment inside a beamer frame

In order to input data from a file into a tabular environment, the TeX macro \@@input has to be used (see this question), since \input is non-expandable. Why is it not possible to change the catcode in a tabular contained in a beamer frame, e.g.

\documentclass{beamer}

\begin{document}
\begin{frame}
\begin{tabular}{c}
\makeatletter \@@input file \makeatother
\end{tabular}
\end{frame}
\end{document}


Although this does not give any errors, it only outputs @input file.

Why do I have to use \csname @@input\endcsname file (see David Carlisle's answer to this question)?

• Works fine for me. Show a complete example. Feb 16 '20 at 23:19
• @UlrikeFischer Ok, the problem is, that it is inside a beamer frame and catcode changing is not possible. Shall I delete the question? Feb 16 '20 at 23:30
• It's much better to say, in the preamble, \makeatletter\newcommand{\expandableinput}[1]{\@@input #1\relax}\makeatother and use \expandableinput{file} in the document. This will work independently of the document class. Feb 16 '20 at 23:32
• @EuklidAlexandria Do as egreg says. Just for an explanation: beamer frames collect their contents, so it's like you used a catcode change (\makeatletter) in the argument of a command, which does not work. Feb 16 '20 at 23:46
• @PhelypeOleinik Ok, thank you! But shouldn't I delete the question since the catcode change does work outside a beamer frame? Feb 16 '20 at 23:54

I wouldn't recommend using @-commands in the document body anyway.

If you plan to use \@@input, add

\makeatletter
\newcommand{\tableinput}[1]{\@@input #1 }
\makeatother


to your document preamble and use

\tableinput{file}


in the document.

Beware that this will create spurious spaces in other contexts.

• Thank you very much! I have replaced \relax with a space in order to make it work \bottomrule (the last line of file already includes \\). Feb 16 '20 at 23:50
• @EuklidAlexandria I see the reason, so I modified the code. Feb 17 '20 at 9:11