5

I have reduced my code to the following lines:

\documentclass[9pt,letterpaper,oneside]{amsart}
\usepackage{graphicx}
\usepackage[table, dvipsnames]{xcolor}
\usepackage{longtable}
\usepackage[top=0.2in, bottom=0in, left=1in, right=1in]{geometry}
\usepackage[labelformat=empty]{caption}
\begin{document}

\renewcommand*\rmdefault{ppl}
\textrm{%
  \begin{table}[ht]
    \centering
    \caption{Blabla}
    {\tiny
      \begin{tabular}{llrrr}
        \hline
        \rowcolor[gray]{0.65} A & B & C & D & E \\ 
        \hline
        \emph{ }
      \end{tabular}
    }
  \end{table}}
\end{document}

This code does exactly what I want, but when I replace the line

\rowcolor[gray]{0.65} A & B & C & D & E \\ 

(which resembles a bigger table) with

\include{TableTest}

where TableTest.tex only contains

\rowcolor[gray]{0.65} A & B & C & D & E \\

I get an error message:

! Misplaced \noalign.
\rowcolor ->\noalign 
   {\ifnum 0=`}\fi \global \let \CT@do@color \CT@@do@color...
l.3 \rowcolor
   [gray]{0.65} A & B & C & D &

I use R/Sweave and xtable to make this table, and a similar problem (+ solution) is found here. Only this solution (i.e. replace \input with \expandableinput) does not work for me! That is

\documentclass[9pt,letterpaper,oneside]{amsart}
\usepackage{graphicx}
\usepackage[table, dvipsnames]{xcolor}
\usepackage{longtable}
\usepackage[top=0.2in, bottom=0in, left=1in, right=1in]{geometry}
\usepackage[labelformat=empty]{caption}
\usepackage{booktabs}
\begin{document}

\renewcommand*\rmdefault{ppl}
    \textrm{%
      \begin{table}[ht]
        \centering
        \caption{Blabla}
        {\tiny
          \begin{tabular}{llrrr}
            \hline
            \expandableinput TableTest.tex 
            \hline
            \emph{ }
          \end{tabular}
        }
      \end{table}}
    \end{document}

gives error message

! Undefined control sequence.
<recently read> \expandableinput 

l.25       \end{table}}

Question: how can I overcome the problem of importing the table from TableTest.tex into the LaTeX code?

1 Answers1

2

You can not have non expandable commands before \rowcolor. Instead of \include (which always forces a page break and is unsuitable for use anywhere in a table) use the expandable input command as defined in the referenced question.

  \makeatletter\let\expandableinput\@@input\makeatother 
David Carlisle
  • 757,742