[Tex/LaTex] Table doesn’t fit to page width properly

formattingtables

The table produced by this code always goes out off the width of my page. I want the table to fit within the width of the page. I tried giving extra \\ in between but it made it worse only.

\begin{tabular}{|l|l|}
\hline 
 LocationProvider & Description \\ 
 \hline 
 network & Uses the mobile network or WI-Fi to determine the best location.Might have a higher precision in closed rooms than GPS. \\
\hline 
gps & Use the GPS receiver in the Android device to determine the best location via satellites. Usually better precision than network. \\
\hline 
passive & Allows to participate in location of updates of other components to save energy \\ 
\hline 
\end{tabular}

The result:
enter image description here

Best Answer

"l" means left aligned so everything in the cell comes out in a single row and if you have a lot of material you end up exceeding the available width on your page.

Alternatives:

  • use p{<width>} on one or more columns to have the text inside wrap the the specified <width>
  • or use the package tabularx which allows you to get the column width for wrapping columns be determined automatically (see package documentation how to do this)
  • in some cases using a slightly smaller font for the table might be a choice, but in general I would not recommend this.