58

I'm making a tabular and I'd like to automatically do a like break rather than going beyond the page.

This is my tabular code:

\begin{table}[h]
\begin{tabular}{|l|l|l|}
Use Case Navn:          & \multicolumn{2}{l}{Opret Server} \\
Scenarie:               & \multicolumn{2}{l}{At oprette en server med bestemte regler som tillader folk at spille sammen. More Text more text More Text} \\
\end{tabular}
\end{table}

This is my preamble:

\documentclass[danish,a4paper,twoside,11pt]{report}
\usepackage{babel}
\usepackage[utf8x]{inputenc}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{titling}
\usepackage{color}
\usepackage{xcolor}
\usepackage{nag}
\usepackage{tabularx}

\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}

This is how it looks right now: image

33

One of the approaches is to use a p type column, p{dimension}:

\documentclass[a4paper]{article}
\pagestyle{empty}
\begin{document}
\begin{table}[h]
{\renewcommand\arraystretch{1.25}
\begin{tabular}{|l|l|l|} \hline
Use Case Navn:& \multicolumn{2}{l|}{Opret Server} \\ \hline\hline
Scenarie:& \multicolumn{2}{p{4cm}|}{\raggedright At oprette en server med bestemte regler som tillader folk at spille sammen. More Text more text More Text} \\ \hline
\end{tabular}}
\end{table}
\end{document}

enter image description here

76

Since you've tagged the question tabularx, this is a solution with tabularx (no need for those \multicolumns)

\documentclass[danish,a4paper,twoside,11pt]{report}

\usepackage{tabularx}

\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{|l|X|}
Use Case Navn:          & Opret Server \\
Scenarie:               & At oprette en server med bestemte regler som tillader folk at spille sammen. More Text more text More Text \\
\end{tabularx}
\end{table}
\end{document} 

enter image description here

The column type X takes all the space left from other columns till \textwidth or whatever you specify in the first argument.

  • The reasoning behind using multicolumn is that I need the tabular to be 2 cells in the upper part of the tabular and 3 cells in the lower one. Apologies for not showing you this in the original post, but this is how the tabular looks like in Word (just started studying LaTeX at school), so we need to "transform" a word document to LaTeX. Anyway, here's the tabular in word: prntscr.com/33xuog – Alexander Qvist-Hellum Mar 25 '14 at 9:37
  • What should I use instead of X if I am using double column? @karlkoeller – alper May 16 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.