11

Getting errors with alternating rows saying undefined control sequences. Any help please!

\documentclass{article}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{graphicx}
\begin{document}

\begin{table}
    \captionsetup{font={footnotesize}}
    \caption{List of localities} 
    \label{table2}
    \scriptsize
    \centering
    \rowcolors[]{1}{white}{cyan}
    \begin{threeparttable} 
         \begin{tabularx}{\textwidth}{@{\extracolsep{\fill}}l c |l c | l c}
         \specialrule{.2em}{.1em}{.1em} 
         %\textbf{Locality} & 
         %\multicolumn{3}{c}{\textbf{Countries}\tnote{\textasteriskcentered}} \\
         %\cmidrule(lr){1-3}
        \textbf{G} & \textbf{Population size} & \textbf{L} & \textbf{Population size} & \textbf{SL} & \textbf{Population size} \\

       \specialrule{.2em}{.1em}{.1em} 
       Upper Guinea     & $4,308,494$ & Northern  & $2,233,091$ & & $4,976,871$ \\
       Middle Guinea    & $2,670,567$ & Southern & $1,243,517$ &  & \\
       Lower Guinea     & $3,649,911$ &  &  &  &  \\
       \specialrule{.2em}{.1em}{.1em} 
       Total & $10,628,972$ &  & $3,476,608$ &  & $4,976,871$ \\
       \specialrule{.2em}{.1em}{.1em} 
\end{tabularx}

\begin{tablenotes}[para]
    \tiny
    \item[\textdagger] 
    \tiny Data.     
\end{tablenotes}

\end{threeparttable}

\end{table}
\end{document}
2
  • 2
    Use \usepackage[table]{xcolor} instead of \usepackage{xcolor}.
    – user11232
    Mar 1, 2015 at 4:33
  • 2
    I had used \usepackage[table]{xcolor} in the past and I was still getting errors
    – user28251
    Mar 1, 2015 at 4:34

1 Answer 1

12

You have to use \usepackage[table]{xcolor} instead of \usepackage{xcolor}. Second since you use tabularx, better use X column and get rid of \extracolsep.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{threeparttable}
\usepackage{tabularx}
\begin{document}

\begin{table}[htb]
\captionsetup{font=footnotesize}
\caption{List of localities}
\label{table2}
\scriptsize
\centering
\rowcolors[]{1}{white}{cyan}
\begin{threeparttable}
\begin{tabularx}{\textwidth}{X c |X c | X c}
\specialrule{.2em}{.1em}{.1em}

%\textbf{Locality} &

%\multicolumn{3}{c}{\textbf{Countries}\tnote{\textasteriskcentered}} \\

%\cmidrule(lr){1-3}

\textbf{G} & \textbf{Population size} & \textbf{L} & \textbf{Population size} & \textbf{S
L} & \textbf{Population size} \\

\specialrule{.2em}{.1em}{.1em}
 Upper Guinea   & $4,308,494$ & Northern  & $2,233,091$ & & $4,976,871$ \\

 Middle Guinea  & $2,670,567$ & Southern & $1,243,517$ &  & \\
 Lower Guinea   & $3,649,911$ &  &  &  &  \\

\specialrule{.2em}{.1em}{.1em}

Total & $10,628,972$ &  & $3,476,608$ &  & $4,976,871$ \\

\specialrule{.2em}{.1em}{.1em}
\end{tabularx}

\begin{tablenotes}[para]

            \tiny

      \item[\textdagger]
            \tiny Data.
\end{tablenotes}

\end{threeparttable}

\end{table}
\end{document}

enter image description here

1
  • 1
    It is better not to use vertical rules in a table.
    – user11232
    Mar 1, 2015 at 4:41

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.