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 :
Best Answer
Since you use two-column mode, you should use a
table*
rather than atable
environment. Thetable*
environment spans both columns. A restriction is that these floats can only appear at the top of a page.By the way, I suggest you use the commands
\toprule
,\midrule
, and\bottomrule
of thebooktabs
package in thetabular
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.