1

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)?

10
  • 1
    Works fine for me. Show a complete example. Commented Feb 16, 2020 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? Commented Feb 16, 2020 at 23:30
  • 2
    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.
    – egreg
    Commented Feb 16, 2020 at 23:32
  • 2
    @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. Commented Feb 16, 2020 at 23:46
  • @PhelypeOleinik Ok, thank you! But shouldn't I delete the question since the catcode change does work outside a beamer frame? Commented Feb 16, 2020 at 23:54

1 Answer 1

3

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.

2
  • 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 \\). Commented Feb 16, 2020 at 23:50
  • @EuklidAlexandria I see the reason, so I modified the code.
    – egreg
    Commented Feb 17, 2020 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .