1

I have following code written

\documentclass{article}
\usepackage{tabularx}
\setlength{\tabcolsep}{15pt}
\usepackage{array}
\usepackage{multirow}
\usepackage[table]{xcolor}
\begin{document}
    \begin{table}[h]
        \begin{tabular}{ l@{\hspace{1in}}| l | l | r | }
            \hline\noalign{\smallskip}
            \multicolumn{2}{c}{Item} 
             & Other things
             \\
             \hline
            Animal & Description & Price (\$) \\
            \noalign{\smallskip}\hline\noalign{\smallskip}
            Gnat  & per gram & 13.65 \\
            & each     &  0.01 \\
            Gnu   & stuffed  & 92.50 \\
            Emu   & stuffed  & 33.33 \\
            Armadillo & frozen & 8.99 \\
            \noalign{\smallskip}\hline
        \end{tabular}
    \end{table}


    \begin{table}[h]
        \rowcolors{1}{red}
        \begin{tabular}{| l | l | c | c |}
            \hline
        1 & 2 & \multicolumn{2}{c|}{Content 3 and 4}  \\[20pt] \hline 
        5 & 6 & 7 & 8 \\ \cline{2-4}
        9 & 10 & \multirow{2}{*}{Rows 3 and 4} & 12  \\ 
        \cline{1-2} \cline{4-4}
        13 & 14 &  & 16 \\ \hline
    \end{tabular}
    \end{table}

\begin{table}
    \begin{tabular}{p c}
        \hline
        \begin{verbatim}
        code
        \end{verbatim}
        & description
        \\ \hline
    \end{tabular}

\end{table}

\end{document}

I get error

  line 31: Misplaced \noalign. \hline
line 32: Misplaced alignment tab character &. 1 &
line 32: Misplaced alignment tab character &. 1 & 2 &
line 32: Misplaced \omit. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \span. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \omit. ...& 2 & \multicolumn{2}{c|}{Content 3 and 4}
line 32: Misplaced \noalign. ...n{2}{c|}{Content 3 and 4} \\[20pt] \hline
line 33: Misplaced alignment tab character &. 5 &
line 33: Misplaced alignment tab character &. 5 & 6 &
line 33: Misplaced alignment tab character &. 5 & 6 & 7 &
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced alignment tab character &. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \span. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \span. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \omit. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \cr. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 33: Misplaced \noalign. 5 & 6 & 7 & 8 \\ \cline{2-4}
line 34: Misplaced alignment tab character &. 9 &
line 34: Misplaced alignment tab character &. 9 & 10 &
line 34: Misplaced alignment tab character &. 9 & 10 & \multirow{2}{*}{Rows 3 and 4} &
line 35: Misplaced \omit. \cline{1-2}
line 35: Misplaced \span. \cline{1-2}
line 35: Misplaced \omit. \cline{1-2}
line 35: Misplaced \cr. \cline{1-2}
line 35: Misplaced \noalign. \cline{1-2}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced \span. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced \span. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Misplaced alignment tab character &. \cline{1-2} \cline{4-4}
line 35: Misplaced \omit. \cline{1-2} \cline{4-4}
line 35: Leaders not followed by proper glue. \cline{1-2} \cline{4-4}
line 35: Misplaced \cr. \cline{1-2} \cline{4-4}
line 35: Misplaced \noalign. \cline{1-2} \cline{4-4}
line 36: Misplaced alignment tab character &. 13 &
line 36: Misplaced alignment tab character &. 13 & 14 &
line 36: Misplaced alignment tab character &. 13 & 14 & &
line 36: Misplaced \noalign. 13 & 14 & & 16 \\ \hline
line 37: Misplaced \crcr. \end{tabular}
line 37: Extra }, or forgotten \endgroup. \end{tabular}
line 37: Extra }, or forgotten $. \end{tabular}
line 37: \begin{table} on input line 28 ended by \end{tabular}. \end{tabular}
line 37: Missing $ inserted. \end{tabular}
line 38: Too many }'s. \end{table}
line 38: \begin{document} ended by \end{table}. \end{table}
line 38: Extra \endgroup. \end{table}
line 42: Undefined control sequence. \hline
line 43: Missing number, treated as zero. \begin
line 43: Illegal unit of measure (pt inserted). \begin
line 46: Extra alignment tab has been changed to \cr. &
line 46: Missing number, treated as zero. & d
line 46: Illegal unit of measure (pt inserted). & d
line 47: Undefined control sequence. \\ \hline
line 32: Underfull \hbox (badness 10000) in paragraph
line 33: Underfull \hbox (badness 10000) in paragraph
line 34: Overfull \vbox (12.0pt too high) detected
line 34: Underfull \hbox (badness 10000) in paragraph
line 36: Underfull \hbox (badness 10000) in paragraph
line 43: Overfull \hbox (4.44444pt too wide) in paragraph
line 45: Overfull \hbox (20.99982pt too wide) in paragraph
line 46: Overfull \hbox (52.30565pt too wide) in paragraph

so what is the error in above table? my code editor Tex Studio does not shows line numbers. I see the line numbers only in error messages.

8
  • 1
    \rowcolors has three arguments as it is for alternating colors. E.g. \rowcolors{1}{red}{green}. Commented May 8, 2020 at 13:38
  • yes I changed that while you commented but I still have lot of errors.like Package xcolor Error: Undefined color red0.25'. 1 &`
    – koeradoera
    Commented May 8, 2020 at 13:39
  • show the real code you are now using. Commented May 8, 2020 at 13:40
  • ok I edited the original code and errors updated with new ones, you can now see the new code and new errors
    – koeradoera
    Commented May 8, 2020 at 13:42
  • The error in the new example is completely unrelated. You can not have verbatim in a c column as c entries are single line, use p{5cm} or whatever width you need. Commented May 8, 2020 at 13:44

1 Answer 1

2

You are missing an argument to \rowcolors

       \rowcolors{1}{red}{blue}
6
  • Well good to see you after long time, I have been trying to learn latex I am trying to understand working of xltabular so I am trying codes from here en.wikibooks.org/wiki/LaTeX/Tables please tell me what does this means \begin{xltabular}{\textwidth}{@{} l X @{} X @{} X}
    – koeradoera
    Commented May 8, 2020 at 13:46
  • @koeradoera X is tabularx syntax for a p{...} column of automatically determined width, the rest is standard latex syntax for tabular* environment/ Commented May 8, 2020 at 13:47
  • how are the colors of rows decided \rowcolors{1}{red}{green} I am getting an output in which 1st row and second row is red and 2nd,3rd row is coming green.I am not certain which row would get which color.
    – koeradoera
    Commented May 8, 2020 at 14:06
  • @koeradoera supposed to alternate red/green Commented May 8, 2020 at 14:10
  • I get an output which is like this and I don't think this is alternatig, imgur.com/HYYHSnu could it be because I have multirow used.
    – koeradoera
    Commented May 8, 2020 at 14:12

You must log in to answer this question.

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