[Tex/LaTex] table too wide for twocolumn-mode document

horizontal alignmenttables

I have a table which comes outside the text column width into the margin of the paper. How do I make the text in the table align to left ?

 \documentclass[a4paper,10pt]{article}
 \usepackage[utf8]{inputenc}

 \title{}
\author{}

\begin{document}

\maketitle

 \begin{abstract}
 abc
\end{abstract}

\section{table}
\begin{table}[h!]
\caption{Top 5 movies recommended by content-based CF algorithm} %title of the table
\centering
% centering table
\begin{tabular}{c r}
% creating eight columns
\hline\hline
%inserting double-line
Movies&\multicolumn{1}{c}{Genre} \\ [0.5ex]
\hline
% inserts single-line
The Flintstones(1994)
& Children's,Comedy\\
% Entering row contents
Son in Law(1974) & Comedy, Horror\\
The Princess Bride(1987) & Action, Adventure, Comedy, Romance\\
Star Wars(1977) & Action, Adventure, Romance, Sci-Fi, War\\
Toy Story(1995)
& Animated, Animated Children's, Comedy\\[1ex] % [1ex] adds vertical space
\hline
% inserts single-line
\end{tabular}
\label{tab:hresult}
\end{table}
 \end{document}


 This is how it looks : 

enter image description here

Best Answer

Since you use two-column mode, you should use a table* rather than a table environment. The table* environment spans both columns. A restriction is that these floats can only appear at the top of a page.

enter image description here

By the way, I suggest you use the commands \toprule, \midrule, and \bottomrule of the booktabs package in the tabular environment, rather than \hline and various ad-hoc vertical spacing commands. The following modified form of your MWE shows how these commands may be used.

\documentclass[a4paper,10pt,twocolumn]{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,lipsum}
\begin{document}
\lipsum[1-5] % filler text
\begin{table*}
\caption{Top 5 movies recommended by content-based CF algorithm} \label{tab:hresult}
\centering
\begin{tabular}{@{}ll@{}}
\toprule
Movies & Genre \\ 
\midrule
The Flintstones (1994) & Children's, Comedy\\
Son in Law (1974) & Comedy, Horror\\
The Princess Bride (1987) & Action, Adventure, Comedy, Romance\\
Star Wars (1977) & Action, Adventure, Romance, Sci-Fi, War\\
Toy Story (1995) & Animated, Animated Children's, Comedy\\
\bottomrule
\end{tabular}
\end{table*}
\lipsum[6-14] % more filler text
\end{document}