[Tex/LaTex] How to fix this Package array Error: Only one column-spec allowed

columnstables

I have the following table:

enter image description here

From the code:

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage[brazil]{babel}
\usepackage[a4paper, margin=2cm]{geometry}

\usepackage{newtxtext,newtxmath}
\usepackage{array,ragged2e,tabularx,multirow}

\begin{document}
\section{Custos}

    \begin{tabular}
    {|
        *1{@{\hspace{3.0pt}}>{ \RaggedRight\arraybackslash\hsize=1.1\hsize }p{3.9cm}|} % Item
        *1{@{\hspace{3.0pt}}>{ \RaggedRight\arraybackslash\hsize=1.1\hsize }p{1.9cm}|} % Quantidade
        *1{@{\hspace{3.0pt}}>{ \RaggedRight\arraybackslash\hsize=1.1\hsize }p{3.0cm}|} % Valor, Valor
        *1{@{\hspace{3.0pt}}>{ \RaggedRight\arraybackslash\hsize=1.1\hsize }p{2.6cm}|} % Valor, Valor
    }
        \hline Item             &   Quantidade  &   Valor Unitário (R\$)    &   Valor Total (R\$) \\ \hline
        CD                      &   1           &   5,00                    &   5,00,00           \\ \hline
        Impressão               &   800         &   0,15                    &   120,00            \\ \hline
        Reserva Gerencial       &   1           &   20,00                   &   20,00             \\ \hline
        Reserva de Contingência &   1           &   20,00                   &   20,00             \\ \hline
        Total                   & \multicolumn{2}{c c|}{}                   &   165,00            \\ \hline

    \end{tabular}

\end{document}

But is throwing the error:

 test.tex:29: Package array Error: Only one column-spec. allowed.. [...                  & \multicolumn{2}{c c}{}]

The table is rendering almost as I like to, except for the shifted | before 165,00.

How to remove the error from appearing and align correctly the shifted | pipe?


Update

Nice list for references:

  1. Multi-column and multi-row cells in LaTeX tables
  2. https://en.wikibooks.org/wiki/LaTeX/Tables
  3. What is the difference between tabular, tabular* and tabularx environments?
  4. Using multicolumn in latex
  5. Latex Table multiple row and multiple column

Best Answer

\multicolumn can have only one column specifier. You have two! However, why do you have such complicated head definition. This does the same:

\begin{tabular}
    {|
        >{\RaggedRight}p{3.9cm}| 
        % Item
        >{\RaggedRight}p{1.9cm}|
        % Quantidade
        >{\RaggedRight}p{3.0cm}| 
        % Valor, Valor
        >{\RaggedRight}p{2.6cm}| }\hline 
    Item             &   Quantidade  &   Valor Unitário (R\$)    &   Valor 
    Total (R\$) \\ \hline
    CD                      &   1           &   5,00                    &   
    5,00,00           \\ \hline
    Impressão               &   800         &   0,15                    &   
    120,00            \\ \hline
    Reserva Gerencial       &   1           &   20,00                   &   
    20,00             \\ \hline
    Reserva de Contingência &   1           &   20,00                   &   
    20,00             \\ \hline
    Total                   & \multicolumn{2}{c|}{}                   &   
    165,00            \\ \hline 
\end{tabular}
Related Question