1

How to fix the error

Package array Error: Illegal pream-token (\ecolumn): `c' used. \end{tabularx}

when using the column specifier O for the following?

\documentclass{exam}

\usepackage{makecell,ragged2e}
\usepackage[column=O]{cellspace}
\addparagraphcolumntypes{X}

\usepackage{tabularx,hyperref}
\newcolumntype{Y}[1]{>{\hsize=#1\hsize\Centering}X}

\begin{document}

    \begingroup
    \null
    \thispagestyle{empty}%
    \addtocounter{page}{-1}%
    \hypersetup{pageanchor=false}%

    \setlength\cellspacetoplimit{10mm}
    \setlength\cellspacebottomlimit{10mm}

    \begin{tabularx}{0.5\linewidth}{%
            OY{1} Y{1} Y{1} Y{1}}
        \hline
        Question & Marks   & Score & \makecell[c]{Instructor\\ Signature}  \\
        \hline
        1\textsuperscript{st} & 30 & & \\
        \hline
        2\textsuperscript{nd} & 30 & & \\
        \hline
        3\textsuperscript{rd} & 30 & & \\
        \hline
        Total & 90 & &\\
        \hline
    \end{tabularx}

    \clearpage
    \endgroup

\end{document}
  • 3
    Did you try with O{Y{1}} ? – leandriis Jan 14 at 22:48
  • @leandriis No, I haven't before your comment :). You post it as an answer for the future readers. – Diaa Jan 14 at 22:50
1

The cellspace documentation states

To improve the spacing of your tables, you must change the table preamble and prepend S to the column types l, c, r. Thesame holds for the paragraph columns p, m, and b, except that they must be surrounded by an extra pair of braces.

Since your ney column type Y is an altered version of tabularx's X type columns, which in turn is derived from the p column type, You will also have so surround your Y column with an extra set of braces as follows:

\begin{tabularx}{0.5\linewidth}{%
            O{Y{1}} Y{1} Y{1} Y{1}}
|improve this answer|||||

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.