2

What's the best way to create a table with a lot of data (text) ?

enter image description here

3
  • Take a look at the tabularx package. – leandriis Feb 17 '20 at 13:00
  • Perhaps also think about whether this is the best way to present this information? – daleif Feb 17 '20 at 13:02
  • 2
    None. For a lot of text is more convenient a nested list or plaint text well structured in sections. But you are looking for tabulary (similar to tabularx, but allow desigual widths and any type of alignment) – Fran Feb 17 '20 at 13:03
2

One solution with tabulary:

mwe

\documentclass{article}
\let\bf\bfseries
\usepackage{array,geometry,tabulary,booktabs,lipsum,microtype} 
\begin{document}
\renewcommand\arraystretch{2}
\begin{tabulary}{\linewidth}{>{\bf}l*3{>{\parskip1em}L}}\toprule
Klasse & 
\bf FooFooFoo & 
\bf FooFoo & 
\bf FooFooFoo \\\midrule
Niv\.a 1 & 
\lipsum[1][1-2]\par\lipsum[2][1-3]  & 
\lipsum[3][1-3]\par\lipsum[4][1-3] & 
\lipsum[5][1-3]\par\lipsum[5][4-5]\\\cmidrule{2-4}
Niv\.a 1 & 
\lipsum[6][1-2]\par\lipsum[7][1-8] & 
\lipsum[8][1-2]\par\lipsum[9][1-2] & 
\lipsum[10][1-3]\par\lipsum[11][1-3]\\\bottomrule
\end{tabulary}
\end{document}
9
  • \addlinespace instead of \cmidrule{2-3}? \bf is obsolete ... +1 – Zarko Feb 17 '20 at 13:44
  • @Zarko I am using really \bfseries, not \bf (see line 2). About \addlinespace, indeed, in general. But for this case I wanted to avoid confusion about the paragraph skips between and within cells. – Fran Feb 17 '20 at 14:04
  • I see now, however, I will not do this (redefine TeX command with LaTeX's one). – Zarko Feb 17 '20 at 14:13
  • 1
    @PetterÖstergren Change \linewidth by 0.8\linewidth (you can omit the zero). – Fran Feb 17 '20 at 20:52
  • 1
    @PetterÖstergren tabulary can use the l,c and r columns of the basic tabular environment , with cells of unbreakable single lines and L, C, R columns that can have breakable lines and even paragraphs. There are more column types: p, J, m, b ... Run texdoc lshort (see pages 34-37) and then texdoc array (see pages 1--3) and texdoc tabulary (see pages 1--4). – Fran Feb 18 '20 at 1:34
2

Welcome to tex.se! Obviously this a very open question. Some decisions about the design certainly don't have a blanket solution and have to be reassessed depending on the content of the table and the goal you are trying to achieve with it: Do you want centered text? Rules or spaces separating rows or columns? Should the cells be somehow otherwise distinguished from each other, for example with a background colour? Does the amount of text vary a lot from cell to cell? Is a table really the best way of displaying this text? Is it going to be displayed on a poster, in an article, etc.?

Like in other aspects of typography, there is hardly a single best way for all possible situations.

But here's one possible example nontheless:

\documentclass{article}

\usepackage{tabularx}
\usepackage{booktabs}

\begin{document}

\noindent \begin{tabularx}{\textwidth}{@{} l X X X @{}}
\toprule
\textbf{Klasse} & \textbf{Konfidesialitet} & \textbf{Integritet} & \textbf{Tilgjenglighet} \\
\midrule
\textbf{Niva 1}
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \\
\textbf{Niva 2}
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
& Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \\
\bottomrule
\end{tabularx}

\end{document}

enter image description here

There are of course many ways you could further improve or change this example (for example using tabulary instead of tabularx)... Maybe also have a look at Beautiful table samples or similar threads and see if you find something that suits you there.

1
  • Thanks for the warm welcome! It's a very open question indeed, this looks like a great starting point and thanks for the reference to "Beautiful table samples". Seams like a perfect place to find out more! – Petter Östergren Feb 17 '20 at 15:59

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.