1

I am trying to make a table in LaTeX. However, I get several extra alignment tab errors and I do not know why.

I have searched here for similar problems but I only found extra alignment tab error and that is a different problem cause by the %, which I do not use. So, I am quite lost, at the moment.

Here is some minimal code that reproduces the error:

\documentclass[a4paper,10pt]{article}

\usepackage[table]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{array}

%define some nice colors
\definecolor{middleware_green}{RGB}{82, 119, 17}
\definecolor{middleware_white}{RGB}{255, 255, 255}
\definecolor{middleware_light_gray}{RGB}{239, 239, 239}
\definecolor{middleware_dark_gray}{RGB}{153, 153, 153}

%renewing commands for tabularx
\renewcommand{\tabularxcolumn}[1]{>{\small}m{#1}}

%new column type for test tables 
\newcolumntype{L}{>{\leavevmode\ignorespaces\raggedleft\arraybackslash\sffamily}X}%
\newcolumntype{C}{>{\leavevmode\ignorespaces\centering\arraybackslash\sffamily}X}%

\newcolumntype{R}{|>{\leavevmode\ignorespaces\color{magenta!70!black}\raggedright\sffamily\bfseries\footnotesize}p{2.5cm}}%
\newcolumntype{H}{|>{\leavevmode\ignorespaces\color{orange!30!black}\centering\arraybackslash\sffamily\footnotesize}X}%
\newcolumntype{J}{|>{\leavevmode\ignorespaces\color{green!30!black}\centering\sffamily\footnotesize}X}%
\newcolumntype{W}{|>{\leavevmode\ignorespaces\color{blue!30!black}\centering\arraybackslash\sffamily\footnotesize}X|}%


\begin{document}

\begin{table}[ph!]
\footnotesize\centering
\rowcolors{2}{middleware_white}{middleware_light_gray}

\begin{tabularx}{0.46\textwidth}{|L|L|L|L|L|}
\hline\rowcolor{middleware_green}
\multicolumn{ 5}{|c|}{\small\textcolor{white}{\textbf{Cloud Types}}} \\ \hline
\rowcolor{middleware_dark_gray}
\multicolumn{1}{|C}{\scriptsize\textcolor{white}{\textbf{Pu\-blic cloud}}} & 
\multicolumn{1}{|C}{\scriptsize\centering\textcolor{white}{\textbf{Pri\-va\-te cloud}}} & 
\multicolumn{1}{|C}{\scriptsize\centering\textcolor{white}{\textbf{Hy\-brid cloud}}} & 
\multicolumn{1}{|C|}{\scriptsize\textcolor{white}{\textbf{Vir\-tu\-al pri\-va\-te cloud}}} &
\multicolumn{1}{|C|}{\scriptsize\textcolor{white}{\textbf{Com\-mu\-ni\-ty cloud}}} & \\ \hline
Definition  &   Public cloud definition &   Private cloud definition    &   Hybrid cloud defitnion  &   Virtual Private Cloud definition    &   Community Cloud definition  \\ \hline
Advantages  &   Public cloud advantages &   Private cloud advantages    &   Hybrid cloud advantages &   Virtual Private Cloud advantages    &   Community Cloud advantages  \\ \hline
Disadvantages   &   Public cloud disadvantages  &   Private cloud disadvantages &   Hybrid cloud disadvantages  &   Virtual Private Cloud disadvantages &   Community Cloud disadvantages   \\ \hline
\end{tabularx}
\caption{Cloud Types\label{tab:cloud_types}}
\end{table}



\end{document}

What am I missing?

  • 2
    Column types L and C are not defined and there is also a missing & after the second last \multicolumn{1}{|C|}{...}. – Heiko Oberdiek May 15 '14 at 12:45
  • Ok, I updated the document, but I still cant get rid of the problem ! – Flame_Phoenix May 15 '14 at 14:32
  • 2
    Now you have defined five columns for your table, but as @dcmst said, the row starting with Definition & has six columns, as do the next two rows. Edit: Remember that & separates columns, so if there are five & in a row, that means there are six columns. – Torbjørn T. May 15 '14 at 15:11
2

The tabular content is divided into six columns, but only five are declared with the macro.

Something like:

\begin{tabular}{|L|L|L|L|L|}         %five columns
                 1&2&3&4&5&6         %six columns
\end{tabular}

Which will not work.

To solve the compilation error the number of columns should be equal or less than that declared with the macro.

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.