Tabular content spilling over right column margin

Tabular content spilling over right column margin. What's going on here? How can I fix it?

\documentclass[a4paper,12pt]{article}

\author{Peter Cao}
\date{}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption} %apparently needs to come first or options clash with other packages will occur

\usepackage[x11names,dvipsnames]{xcolor} %for use in color links

\usepackage[hyphens]{url}
\usepackage[hyphenbreaks]{breakurl}
\usepackage{a4wide}
\usepackage{graphicx}

\usepackage[version=3]{mhchem}

\usepackage[T1]{fontenc} %for > and < in text mode
\usepackage{tikz}
\mhchemoptions{arrows=pgf-filled}

\usepackage{booktabs} %for top, middle and bottomline

\usepackage{multirow} %multi column and row spanning

\usepackage{amsmath}

\usepackage{cite}

\usepackage{multirow}
\usepackage{tabularx}

\usepackage{siunitx}

\usepackage{fancyhdr}
%\usepackage{fancyheadings} seems to be obsoleted by fancyhdr

\usepackage{comment}
\usepackage{multicol}

\usepackage{lastpage}

\newcommand{\ignore}[1]{} %a null macro which gobbles up comments, and thus acts as a tool for in-line commenting.

\usepackage{blindtext}

\begin{document}

\begin{multicols}{2}

\subsection*{Results}

{\small
\begin{tabularx}{\columnwidth}{l | c | c}
\toprule
Characteristic & \multicolumn{2}{c}{Result}\\
\cmidrule(l){2-3}
& Seaweed isolate & Coral isolate \\
\cmidrule(r){1-1} \cmidrule(l){2-3}
Cell shape & Rod & Rod\\
Gram stain & $-$ & $-$\\
Oxidase & $+$ & $-$\\
Catalase & $+$ & $-$\\
MSA & Growth & No growth\\
Anaerobic & Growth (weak) & No growth\\
Motility & & \\
Indole production & & \\
Hugh \& Leifsons & & \\
\bottomrule
\end{tabularx}
}

\blindtext

\end{multicols}

\end{document}


Updated version demonstrating shrinkage issues:

\documentclass[a4paper,12pt]{article}

\usepackage{booktabs} %for top, middle and bottomline
\usepackage{multirow} %multi column and row spanning
\usepackage{multicol}
\usepackage{graphicx}

\begin{document}

\begin{multicols}{2}

\subsection*{Results}

{\noindent
\resizebox{\columnwidth}{!}{%
\begin{tabular}{@{} l c c @{}}
\toprule
Characteristic & \multicolumn{2}{c}{Result}\\
\cmidrule{2-3}
& Seaweed isolate & Coral isolate \\
\midrule
Cell shape & Rod & Rod\\
Gram stain & $-$ & $-$\\
Oxidase & $+$ & $-$\\
Catalase & $+$ & $-$\\
Anaerobic & Growth (weak) & No growth\\
Motility & & \\
Indole production & & \\
Hugh \& Leifsons & & \\
MSA & Growth & No growth\\
Growth in absence of salt & & \\
Colony pigmentation & White & White \\
\bottomrule
\end{tabular}
}
}

\end{multicols}

\end{document}


-

I already showed you in the other examples what to do ...

\documentclass[a4paper,12pt]{article}
\date{}
\usepackage[font=small,labelfont=bf,tableposition=top]{caption} %apparently needs to come first or options clash with other packages will occur

\usepackage[x11names,dvipsnames]{xcolor} %for use in color links
\usepackage[hyphens]{url}
\usepackage[hyphenbreaks]{breakurl}
\usepackage{a4wide}
\usepackage{graphicx}

\usepackage[version=3]{mhchem}

\usepackage[T1]{fontenc} %for > and < in text mode
\usepackage{tikz}
\mhchemoptions{arrows=pgf-filled}

\usepackage{booktabs} %for top, middle and bottomline

\usepackage{multirow} %multi column and row spanning

\usepackage{amsmath}
\usepackage{cite}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{siunitx}
\usepackage{fancyhdr}
%\usepackage{fancyheadings} seems to be obsoleted by fancyhdr
\usepackage{comment}
\usepackage{multicol}
\usepackage{lastpage}

\newcommand{\ignore}[1]{} %a null macro which gobbles up comments, and thus acts as a tool for in-line commenting.
\usepackage{blindtext}
\begin{document}

\begin{multicols}{2}

\subsection*{Results}

\noindent
\resizebox{\columnwidth}{!}{%
\begin{tabular}{@{} l | c | c @{}}
\toprule
Characteristic & \multicolumn{2}{c}{Result}\\
\cmidrule(l){2-3}
& Seaweed isolate & Coral isolate \\
\cmidrule(r){1-1} \cmidrule(l){2-3}
Cell shape & Rod & Rod\\
Gram stain & $-$ & $-$\\
Oxidase & $+$ & $-$\\
Catalase & $+$ & $-$\\
MSA & Growth & No growth\\
Anaerobic & Growth (weak) & No growth\\
Motility & & \\
Indole production & & \\
Hugh \& Leifsons & & \\
\bottomrule
\end{tabular}%
}

\bigskip
\blindtext

\end{multicols}

\end{document}


it is also possible to fiddle with a surrounding tabularx or a parshape to get "unbalanced" columns:

-
Would resizing the table to the column width not be the last resort, due to the resulting odd font size? (Ok, I often do this by myself, but thought it is a bad habit) – Martin Scharrer May 12 '11 at 16:10
My table text became tiny as I added new rows to it. Resizebox was great until it became so small I could barely make out the content...is there another way to achieve the same effect without resizebox shrinking my font? A little bit of shrinking is ok, but anything less than size 8pt becomes non-legible... – ptrcao May 13 '11 at 11:07
@ptrcao: It maybe a good idea if you could provide a complete example of your table, then we do not need to show you solutions which cannot work ... – Herbert May 13 '11 at 11:52
Of course - see OP under the heading "Updated version demonstrating shrinkage issues". This is where I'm at now, and as you can see, resizebox is great until a certain point when things become a bit difficult to read due to smallness of the font... – ptrcao May 13 '11 at 13:29
@ptrcao: if you can split the text into paragraphs then you can use two multiols or a tabularx for the table and text, see image in the edited answer – Herbert May 13 '11 at 13:58

The tabularx environment can only adjust the widths of table columns with the X specifier. To allow it to adjust a centred column you need to replace the column specifier c with

>{\centering\arraybackslash}X


For a left aligned column, use

>{\raggedright\arraybackslash}X


So, a simple example would look like this.

\documentclass{article}
\usepackage{tabularx}
\begin{document}
%
\begin{tabularx}{0.8\textwidth}
{ | l | >{\raggedright\arraybackslash} X | >{\centering\arraybackslash} X | }
Leave this column alone. & Left justify and adjust this column. &
Centre and adjust this column. \\
\end{tabularx}
%
\end{document}


Have a look at section 4.2 of the tabularx package documentation for more details.

-
In your case you can get there by adjusting the first column only to an "X" column, and specifying hyphenation for "Characteristic". But it looks pretty terrible, because there end up being odd word breaks. You can only squeeze so much into narrow columns, so it's crucial prune the text itself as far as possible! – Paul Stanley May 12 '11 at 13:51