2

I have the following table that is compiling when I use TeXnicCentre (running on MiKTeX):

\begin{table}[H]
\begin{center}
\begin{tabular}{\textwidth}
\Large{\textcolor{Gray}{DATE:}}& \\
\Large{\textcolor{Gray}{COUNTRIES:}}& \\
\Large{\textcolor{Gray}{DEVICES:}}& \\
\Large{\textcolor{Gray}{CHANNELS:}}& \\
\end{tabular}
\end{center}
\end{table}

However, I am trying to create reporting tool that compiles the PDF using Shiny R and I end up with the following error:

Running 'texi2dvi' on 'pdf_shell.tex' failed.
LaTeX errors:
! Package array Error:  Illegal pream-token (\textwidth): `c' used.

See the array package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.136 \Large{\textcolor{Gray}{DATE:}}&
                                       \\
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.138 \Large{\textcolor{Gray}{COUNTRIES:}}&
                                            \\
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.140 \Large{\textcolor{Gray}{DEVICES:}}&
                                          \\
! Extra alignment tab has been changed to \cr.
<recently read> \endtemplate 

l.142 \Large{\textcolor{Gray}{CHANNELS:}}&
                                           \\

As far as I am concerned it might be related to the fact that I am using TeXnicCentre and shiny.io is running texlive-xetex and texlive-latex-recommended version 2009-15 for Ubuntu 12.04.

Does anyone have an idea how I could make my simple table work within the Shiny R, so it would be possible to create it on their TeX Live version?

Maybe I am wrong and something else is causing the problem.

  • 1
    The wrong code \begin{tabular}{\textwidth} will raise an error with every attempt at compilation. – egreg Jun 23 '16 at 10:49
  • Thank you, deleting tabular line actually solves my stupid mistake. Thank you very much! – An economist Jun 23 '16 at 10:57
3

The syntax for tabular is

\begin{tabular}[<pos>]{<col spec>}
  <tabular body>
\end{tabular}

where [<pos>] (optional) denotes a vertical alignment position or anchor. Options are [t]op, [c]entre (default) or [b]ottom. <col spec> (mandatory) defines a specification of the columns.

Your usage

\begin{tabular}{<width>}
  <tabular body>
\end{tabular}

uses <width> instead of <col spec> results in the error as LaTeX expects something like l, c, r or |.

It seems like you're using a two-column tabular, so you're probably after

\begin{tabular}{ l l }
  <tabular body>
\end{tabular}

The syntax for tabular* is similar, but includes a width specification:

\begin{tabular*}{<width>}[<pos>]{<col spec>}
  <tabular body>
\end{tabular*}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.