Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my table, i want the "2" to go right under the "1" in the same cell, how do I do that?

here is my code

\begin{center}
\begin{tabular}{ | p{1cm} | p{1,5cm} | p{1,5cm} | p{1,5 cm} | p{8,3cm} |}
\hline
\textbf{Uge} & \textbf{Speciel dato} & \textbf{ugedag} & \textbf{Antal blokke} & \textbf{Aktivitet} \\ \hline \hline
12 & 17/3 & Tirsdag Torsdag & 1 2 & Text \\ \hline
13 & 9C & 19C & Text & Text \\ \hline
14 & 10C & 21C & Text & Text \\
\hline
\end{tabular}

\end{center}

share|improve this question
    
In a new cell with an empty rest of the row? Or just like a fraction? Or perhaps something else. –  Werner May 9 at 15:52
    
If you don't need paragraph style wrapping between lines of your stacked text, the stackengine package offers many options to address this, with various justification options. –  Steven B. Segletes May 9 at 16:01

3 Answers 3

up vote 1 down vote accepted

With the array, makecell and cellspace packages:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{array}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\cellalign{cc}

\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{center}
\begin{tabular}{ | S{p{1cm}} | *{3}{ >{\centering}S{p{1,5cm}} |} S{m{8,3cm}} |}
\hline
\thead{Uge} & \thead{Speciel \\ dato} & \thead{ugedag} & \thead{Antal\\ blokke} & \thead{Aktivitet} \\
\hline \hline
12 & 17/3 & \makecell{Tirsdag\\ Torsdag} & \makecell{1\\ 2}  & Text text text text text text text text text text text text text text text text text text text text text \\
\hline
13 & 9C & 19C & Text & Text \\
\hline
14 & 10C & 21C & Text & Text \\
\hline
\end{tabular}
\end{center}

\end{document} 

you have this:

enter image description here

share|improve this answer

There are many ways to achieve the desired output. One way involves placing Torsdag and 2 in their own separate row. Doing so may be a good idea not only because it'll create the desired output, but also because the result will be robust to a widening of the third column, which might result in "Tirsdag" and "Torsdag" (Tuesday and Thursday??) suddenly appearing on the same line.

enter image description here

\documentclass[a4paper,11pt]{article}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\textwidth}{ | p{1cm} | p{1,5cm} | p{1,5cm} | p{1,5 cm} | X |}
\hline
\textbf{Uge} & \textbf{Speciel dato} & \textbf{ugedag} & \textbf{Antal blokke} & \textbf{Aktivitet} \\ 
\hline \hline
12 & 17/3 & Tirsdag  & 1 & Text \\ 
& & Torsdag & 2 & \\
\hline
13 & 9C & 19C & Text & Text \\ 
\hline
14 & 10C & 21C & Text & Text \\
\hline
\end{tabularx}
\end{document}
share|improve this answer
    
Thank you! Exactly what I needed! :) –  RandomDude May 9 at 15:59

If 1 and 2 shouldn't be centered, \newline does the work:

\documentclass{article}

\begin{document}

\begin{center}
\begin{tabular}{ | p{1cm} | p{1,5cm} | p{1,5cm} | p{1,5 cm} | p{8,3cm} |}
\hline
\textbf{Uge} & \textbf{Speciel dato} & \textbf{ugedag} & \textbf{Antal blokke} & \textbf{Aktivitet} \\ \hline \hline
12 & 17/3 & Tirsdag Torsdag & 1\newline 2 & Text \\ \hline
13 & 9C & 19C & Text & Text \\ \hline
14 & 10C & 21C & Text & Text \\
\hline
\end{tabular}
\end{center}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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