Table exceeds page

You can either fix the column width by specifying a paragraph style p{<len>}, or you can use a different tabular environment that stretches according to the contents up to the maximum width of the text block. The latter is provided by the tabularx package which defines the environment tabularx with an additional width-of-table argument, as well as the stretchable X column specifier.

An example of the first suggestion:

enter image description here

\documentclass[12pt]{report}
\usepackage[a4paper,left=15mm,right=15mm, top=1cm, bottom=2cm]{geometry}% http://ctan.org/pkg/geometry
\begin{document}
\noindent\begin{tabular}{|l|c|p{0.7\linewidth}|}
  \hline
  a & b & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\\
  \hline
\end{tabular}
\end{document}​

An example of the second suggestion:

enter image description here

\documentclass[12pt]{report}
\usepackage[a4paper,left=15mm,right=15mm, top=1cm, bottom=2cm]{geometry}% http://ctan.org/pkg/geometry
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\noindent\begin{tabularx}{\linewidth}{|l|c|X|}
  \hline
  a & b & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\\
  \hline
\end{tabularx}
\end{document}​

The tabularx approach is an easy way out since you don't have to worry about specifying a column width that exactly matches the remaining column space on the page. However, it is possible to calculate the appropriate value of <len> when using the p{<len>} column specifier.


LaTeX's algorithms for formatting tables have a few shortcomings. One is that it will not automatically wrap text in cells, even if it overruns the width of the page. For columns that you know will contain a certain amount of text, then it is recommended that you use the p attribute and specify the desired width of the column (although it may take some trial-and-error to get the result you want). Use the m attribute to have the lines aligned toward the middle of the box and the b attribute to align along the bottom of the box.

LaTeX/Tables - Wikibooks, open books for an open world

Use p{width} to set the column's width. Here is an example, based on yours:

\begin{tabular}[ht]{|l|c|p{5cm}|}
\hline
    a & b & Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\\
\hline
\end{tabular}

If you're new to LaTeX you should use the Wikibooks LaTeX book (upper link), it has a lot of basic tips and tricks.


Wrapping around done for p{LENGTH} columns. Just change your |l| to |p{2cm}| (or whatever length you need)

Tags:

Width

Tables