1

enter image description here

How can I make a table like that? Is there a way that the rows adjust themselves automatically? I need it for a worksheet at school.

3
  • 1
    insert in one of the empty cells a rule of a height (downwards) equal to the remaining vertical space in the page, and width 0pt.
    – Bernard
    Jun 18, 2021 at 13:38
  • Are you concerned about the width or the height of the table -- or both? Please advise.
    – Mico
    Jun 18, 2021 at 13:40
  • What exactly does "the rows adjust themselves automatically" refer to? Do you know the required height of your table in advance?
    – leandriis
    Jun 18, 2021 at 14:56

1 Answer 1

5

I assumed that by full page you mean the text area of the page.

The command \blankrows{<nn>} adds nn blank rows. (From https://tex.stackexchange.com/a/62178/161015)

The exact number of blank rows to fill the page depends on the paper size and the layout of the page. In this case is 43.

The package nicematrix provides the command \Block that replaces \multicolumn and \multirow, and also allows the use of \\ inside.

\Block{}{Lernbereich \\ \scriptsize (Sprechen, Grammatik, \\ \scriptsize Lesen, \dots{})} defines a 1x1 cell with three lines, the last two with a smaller font.

The column type P{<number>} sets the width of the columns in fractions of \textwidth, with all five columns adding one \textwidth.

30 rows, showing the margins

p30x

43 rows, full page

fx

\documentclass{article}

\usepackage{tikz}% needed <<<<  
\usepackage{nicematrix}% needed <<<<

\usepackage{amssymb} % checkmark    

% From https://tex.stackexchange.com/a/62178/161015
\newcommand{\blankrows}[1]{%
    \def\temp{}%
    \foreach \i in {1,...,#1}
    {%
        \expandafter\gdef\expandafter\temp\expandafter{\temp  & & &  & \\}%
    }%
    \temp}

\usepackage{showframe} % to show margins

\newcolumntype{P}[1]{>{\sffamily\centering\arraybackslash}p{#1\textwidth-\arrayrulewidth}}
\setlength{\tabcolsep}{0pt}

\begin{document}
        
\noindent
\begin{NiceTabular}{|P{0.2}|P{0.3}|P{0.2}|P{0.2}|P{0.1}|}
    \hline
    Datum & \Block{}{Lernbereich \\ \scriptsize (Sprechen, Grammatik, \\ \scriptsize Lesen, \dots{})} & Thema & Material & \LARGE\color{green}\checkmark  \\
    \hline
    \blankrows{30}  % add rows
    \hline
\end{NiceTabular}

\end{document}

Alternative solution, following Bernard's comment: put an invisible rule with a height to reach the bottom of the text area. In this case 0.925\textheight. The code is simpler.

\documentclass{article}

\usepackage{nicematrix}% needed <<<<    
\usepackage{amssymb} % checkmark

\usepackage{showframe} % to show margins

\newcolumntype{P}[1]{>{\sffamily\centering\arraybackslash}p{#1\textwidth-\arrayrulewidth}}
\setlength{\tabcolsep}{0pt}

\begin{document}

\noindent
\begin{NiceTabular}{|P{0.2}|P{0.3}|P{0.2}|P{0.2}|P{0.1}|}
    \hline
    Datum & \Block{}{Lernbereich \\ \scriptsize (Sprechen, Grammatik, \\ \scriptsize Lesen, \dots{})} & Thema & Material & \LARGE\color{green}\checkmark  \\
    \hline
 \rule{0pt}{0.925\textheight}& & &  & \\ % add space until the end of the text area
    \hline
\end{NiceTabular}

\end{document}

But the first solution is more flexible. Allows you to insert horizontal lines, if you want.

Using the command \replicate{<nn>}{<command>} to replicate command nn times.

xx

\documentclass{article}

\usepackage{tikz}% needed <<<<  
\usepackage{nicematrix}% needed <<<<

\usepackage{amssymb} % checkmark    

% From https://tex.stackexchange.com/a/62178/161015
\newcommand{\replicate}[2]{%
\def\temp{}%
\foreach \i in {1,...,#1}{\expandafter\gdef\expandafter\temp\expandafter{\temp #2}}%
\temp}

%\usepackage{showframe} % to show margins

\newcolumntype{P}[1]{>{\sffamily\centering\arraybackslash}p{#1\textwidth-\arrayrulewidth}}
\setlength{\tabcolsep}{0pt}
\renewcommand{\arraystretch}{1.8}

\begin{document}
        
\noindent
\begin{NiceTabular}{|P{0.2}|P{0.3}|P{0.2}|P{0.2}|P{0.1}|}
    \hline
    Datum & \Block{}{Lernbereich \\ \scriptsize (Sprechen, Grammatik, \\ \scriptsize Lesen, \dots{})} & Thema & Material & \LARGE\color{green}\checkmark  \\
    \hline
    \replicate{21}{ & &  & &\\ \hline}  % add lines
    \hline
\end{NiceTabular}

\end{document}

And also number the lines.

nx

\documentclass{article} 

\usepackage{tikz}% needed <<<<  
\usepackage{nicematrix}% needed <<<<

\usepackage{amssymb} % checkmark

\newcounter{rowcount}
    \setcounter{rowcount}{1}

% From https://tex.stackexchange.com/a/62178/161015
\newcommand{\replicate}[2]{%
    \def\temp{}%
    \foreach \i in {1,...,#1}{\expandafter\gdef\expandafter\temp\expandafter{\temp #2}}%
    \temp}

%\usepackage{showframe} % to show margins

\newcolumntype{P}[1]{>{\sffamily\centering\arraybackslash}m{#1\textwidth-\arrayrulewidth}}
\setlength{\tabcolsep}{0pt}
\renewcommand{\arraystretch}{1.8}

\begin{document}        
            
\noindent
\begin{NiceTabular}{|P{0.1}|P{0.15}|P{0.25}|P{0.2}|P{0.2}|P{0.1}|}
    \hline
\#  & Datum & \Block{}{Lernbereich \\ \scriptsize (Sprechen, Grammatik, \\ \scriptsize Lesen, \dots{})} & Thema & Material & \LARGE\color{green}\checkmark  \\
    \hline
    \replicate{21}{\therowcount\stepcounter{rowcount} & & &  & &\\ \hline}  % add numbered rows & lines
    \hline
\end{NiceTabular}

\end{document}
2

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.