1

I am formatting a table and I don't know how to deal with several separate issues:

  1. I don't know how to break the line within a cell but keep the margins and the height of the text within the cell.
  2. I would like to leave more space with cells so that it is clear that final categories belong to separate more aggregate categories. In the code below, that would be leaving more space between 'Private sector' and 'Employers'.
  3. I would like to itemise within a cell, or at least make it look better, e.g. 'Employers with no salaried workers' should have the same indentation.
  4. I would like some borders of the table to be cut before the next border starts as in the picture attached

Here is the code with the preamble at the beginning, the table is at the very end:

\documentclass[usenames,dvipsnames,handout,aspectratio=169]{beamer} % --> loads xcolor and hyperref
% \documentclass[usenames,dvipsnames, handout]{beamer} % --> loads xcolor and hyperref

%\usetheme{CambridgeUS}

\definecolor{Red}{RGB}{176,23,31}

%% Useful packages
    \usepackage{lipsum}
    \usepackage{caption,subcaption}
    \usepackage{fourier}

%This sequence of packages controls the mathematical tools of latex
    \usepackage{mathtools}  % Loads and enhances the features of amsmath: symbols, numerations,...
    % \usepackage{mathrsfs}
    \usepackage{amssymb}    % Loads the package 'amsfont' and adds  more symbols in the maths environment
    \usepackage[makeroom]{cancel} % to cross a term in an equation

% A more advanced package for images and figures
    \usepackage{graphicx}

% These packages controls the graphs
    \usepackage{pgfplots} %--> it loads tikz
        \usetikzlibrary{fit, calc, matrix, positioning, arrows.meta, intersections, through, backgrounds, patterns, shapes, decorations.pathreplacing, arrows.meta}
        \usepgfplotslibrary{fillbetween}
        \pgfplotsset{compat = newest}
        \pgfplotsset{overwrite option/.style args={#1 with #2}{#1=#2,#1/.code=}}
        \pgfplotsset{
            vasymptote/.style={before end axis/.append code={\draw[dashed,<->,-{Latex}] ({rel axis cs:0,0} -| {axis cs:#1,0}) -- ({rel axis cs:0,1} -| {axis cs:#1,0}); }},
            myaxis/.style={axis line style={<->, {Latex}-{Latex}}}
            }   % This fancy shit sets the arrows to both parts of the axis in the axis environment of pgfplot
        
% to import certain files
    \usepackage{import}


% These packages are for a better align
    \usepackage{ragged2e}   % This package provides new commands and environments for setting ragged tex
        \apptocmd{\frame}{}{\justifying}{}
        \renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm} % For justifying the whole document
    \usepackage[none]{hyphenat} % <--- to remove hyphens
        \sloppy %to justify when there is no hyphenation

% For dealing with slides with two columns
    \usepackage{multicol}
        \setlength{\columnsep}{5pt}
        

% to control the colors of the pyperref package
    \hypersetup{
        colorlinks=true,
        linkcolor=DarkOrchid,
        filecolor=magenta,      
        urlcolor=blue,
    }
    
    \usepackage{float}
    \usepackage{marvosym} % symbols to draw the lighting
        \let\marvosymLightning\Lightning

% STRUCTURE OF THE BEAMER
\usefonttheme{professionalfonts}
\usefonttheme{serif}

\setbeamercolor{title}{fg=Red}
\setbeamercolor{frametitle}{fg=Red}
\setbeamercolor{structure}{fg=Red}

\setbeamercolor*{enumerate item}{fg=black}
\setbeamercolor*{enumerate subitem}{fg=black}
\setbeamercolor*{enumerate subsubitem}{fg=black}

\setbeamertemplate{frametitle}[default][center]
    \addtobeamertemplate{frametitle}{\vskip 5pt}{} % to control the height
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{section in toc}[sections numbered] % to number sections in the table of contents
% \useoutertheme{miniframes}

\setlength{\leftmargini}{20.00pt}
 
 
 
\title{1. Labour Supply}
\author{Rub\'{e}n P\'{e}rez Sanz}
\institute{University of Bristol, School of Economics}
\date{\footnotesize{\today}}


\makeatother
\setbeamertemplate{footline}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
    \insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
  \end{beamercolorbox}}%
  \vskip0pt%
}
\makeatletter

\newcommand\Smallfont{\fontsize{7.5}{12}\selectfont}
\newcommand\Normalfont{\fontsize{9}{12}\selectfont}


% To enumerate the table of contents
\AtBeginSection[]
{
  \begin{frame}
    \frametitle{Table of Contents}
    \tableofcontents[currentsection]
  \end{frame}
}


\begin{document}
%------------------------------------------------------------------------------
% Table of definitions
%------------------------------------------------------------------------------

\begin{frame}{INTRODUCTION}
\framesubtitle{DEFINITION}
    \fontsize{7pt}{8pt}\selectfont  
    
    \begin{table}[]
    \begin{tabular}{lllll}
\textbf{Under 16-years-old}                                                                   &                                                                                                 &                                                                                                                                                   &                                                                                              &                                                                                                                                     \\ \cline{1-4}
\multicolumn{1}{l|}{\textbf{\begin{tabular}[c]{@{}l@{}}16-years-old\\ or above\end{tabular}}} & \multicolumn{1}{l|}{\textbf{\begin{tabular}[c]{@{}l@{}}Active\\ Population\end{tabular}}}       & \multicolumn{1}{l|}{\textbf{Employed}}                                                                                                            & \multicolumn{1}{l|}{\textbf{Salaried}}                                                       & \begin{tabular}[c]{@{}l@{}}- Public sector\\ - Private sector\end{tabular}                                                          \\ \cline{4-4}
\multicolumn{1}{l|}{}                                                                         & \multicolumn{1}{l|}{}                                                                           & \multicolumn{1}{l|}{}                                                                                                                             & \multicolumn{1}{l|}{\textbf{Self-employed}}                                                  & \begin{tabular}[c]{@{}l@{}}- Employers\\ - Employers with \\    no salaried workers\\ - Cooperativists\\ - Family help\end{tabular} \\ \cline{4-4}
\multicolumn{1}{l|}{}                                                                         & \multicolumn{1}{l|}{}                                                                           & \multicolumn{1}{l|}{}                                                                                                                             & \multicolumn{1}{l|}{\textbf{Others}}                                                         &                                                                                                                                     \\ \cline{3-3}
\multicolumn{1}{l|}{}                                                                         & \multicolumn{1}{l|}{}                                                                           & \multicolumn{1}{l|}{\textbf{Unemployed}}                                                                                                          & \begin{tabular}[c]{@{}l@{}}- Search for first \\   employment\\ - Worked before\end{tabular} &                                                                                                                                     \\ \cline{2-2}
\multicolumn{1}{l|}{}                                                                         & \multicolumn{1}{l|}{\textbf{\begin{tabular}[c]{@{}l@{}}Out of \\ Labour \\ Force\end{tabular}}} & \begin{tabular}[c]{@{}l@{}}- Students\\ - Pensioners\\ - Housewife/husband\\ - Unfit to work\\ - Others (renters,etc.)\\ - Not known\end{tabular} &                                                                                              &                                                                                                                                     \\ \cline{2-2}
\multicolumn{1}{l|}{}                                                                         & \multicolumn{1}{l|}{\textbf{\begin{tabular}[c]{@{}l@{}}Counted \\ aside\end{tabular}}}          & - Military                                                                                                                                        &                                                                                              &                                                                                                                                    
    \end{tabular}
    \end{table}
         
\end{frame}
\end{document}

And here is the picture with the intended final result: enter image description here

Please, let me know if you can help here or if you need any clarification.

Kind regards Ruben

3
  • 1
    Please minimise your code by removing irrelevant packages. pgfplots doesn't seem required, for example. Similarly for many of your other packages. Note you don't need multicol. Beamer already provides support for columns in slides. You don't use lipsum in the example, as far as I can tell, so why are you loading it? It isn't something you'd use in a real document.
    – cfr
    Oct 17, 2023 at 15:56
  • Thanks for this. They are there because the document is much larger, but I will take your suggestions into consideration, you are right in that I probably don't need them. In any case, any idea about the points I made in the original question? Oct 17, 2023 at 18:53
  • The point is you don't need them for the question. I realise your real document will use many of those packages. But minimise your example here. (However, lipsum you can't possibly be using unless, possibly, you're writing documentation about typesetting.)
    – cfr
    Oct 17, 2023 at 19:19

1 Answer 1

2

With the nicematrix package you get the \Block command that serves as both multi-column and multi-row, also allowing the use of \\ inside. The code is simpler and easier to maintain.

For instance \Block{2-1}{Active\\ Population} creates a cell one column wide by two rows high, with two lines inside, vertically centered.

The solid lines were drawn using the package's ability to insert tikz commands (with \CodeAfter) between the nodes it creates in the cells.

c

\documentclass[usenames,dvipsnames,handout,aspectratio=169]{beamer} 

\definecolor{Red}{RGB}{176,23,31}

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

% STRUCTURE OF THE BEAMER
\usefonttheme{professionalfonts}
\usefonttheme{serif}

\setbeamercolor{title}{fg=Red}
\setbeamercolor{frametitle}{fg=Red}
\setbeamercolor{structure}{fg=Red}

\setbeamercolor*{enumerate item}{fg=black}
\setbeamercolor*{enumerate subitem}{fg=black}
\setbeamercolor*{enumerate subsubitem}{fg=black}

\setbeamertemplate{frametitle}[default][center]
\addtobeamertemplate{frametitle}{\vskip 5pt}{} % to control the height
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{section in toc}[sections numbered] % to number sections in the table of contents
 \useoutertheme{miniframes}

\setlength{\leftmargini}{20.00pt}

\title{1. Labour Supply}
\author{Rub\'{e}n P\'{e}rez Sanz}
\institute{University of Bristol, School of Economics}
\date{\footnotesize{\today}}


\makeatother
\setbeamertemplate{footline}
{
    \leavevmode%
    \hbox{%
        \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
            \usebeamerfont{author in head/foot}\insertshortauthor
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.4\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
            \usebeamerfont{title in head/foot}\insertshorttitle
        \end{beamercolorbox}%
        \begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{date in head/foot}%
            \insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
    \end{beamercolorbox}}%
    \vskip0pt%
}
\makeatletter

\begin{document}

\begin{frame}{INTRODUCTION}
\setstretch{0.65} % <<<<<<<<<<<<<
\renewcommand{\arraystretch}{0.75} % <<<<<<<<<<<<<

\framesubtitle{DEFINITION}

\begin{NiceTabular}{lllll}
    \RowStyle[nb-rows=*]{\bfseries\fontsize{8pt}{9pt}\selectfont }% set the font to be used <<
    \Block[l]{1-2}{Under 16-years-old} &&&&\\[1ex]
    \Block{2-1}{16-years-old\\ or above}&\Block{2-1}{Active\\ Population}&Employed&Salaried&\Block{2-1}<\normalfont>{- Public sector\\ - Private}\\
    &&&&\\
    &&&&\\  
    &&&Self-employed&\Block{5-1}<\normalfont>{- Employers\\ - Employers with \\ \hspace{1ex}   no salaried workers\\ - Cooperativists\\ - Family help}\\
    &&&&\\
    &&&&\\
    &&&&\\
    &&&&\\
    &&&Others&\\
    &&&&\\
    &&Unemployed&\Block{3-1}<\normalfont>{- Search for first \\ \hspace{1ex}  employment\\ - Worked before}&\\
    &&&&\\  
    &&&&\\
    &&&&\\
    &\Block{3-1}{Out of \\ Labour \\ Force}&\Block{6-1}<\normalfont>{- Students\\ - Pensioners\\ - Housewife/husband\\ - Unfit to work\\ - Others (renters,etc.)\\ - Not known}&&\\
    &&&&\\
    &&&&\\
    &&&&\\
    &&&&\\
    &&&&\\
    &&&&\\
    \Block{2-1}{Counted \\ aside}   &\normalfont- Military&&&\\ 
    &&&&\\  
    \CodeAfter 
        \tikz \draw [thick](2-|4) ++(1ex,0.5ex) -| (2-|5) -|(4-|5) ;
        \tikz \draw [thick](5-|4) ++(1ex,0.5ex) -| (5-|5) -|(10-|5) ;
        \tikz \draw [thick](2-|3) ++(1ex,0.5ex) -| (2-|4) -|(11-|4);
        \tikz \draw [thick](12-|3) ++(1ex,0.5ex) -| (12-|4) -|(15-|4);
        \tikz \draw [thick](2-|2) ++(1ex,0.5ex) -| (2-|3) -|(15-|3);    
        \tikz \draw [thick](16-|2) ++(1ex,0.5ex) -| (16-|3) -|(22-|3);
        \tikz \draw [thick](23-|2) ++(1ex,0.5ex) -| (23-|3) -|(25-|3);      
        \tikz \draw [thick](2-|1) ++(1ex,0.5ex) -| (2-|2) -|(25-|2);            
\end{NiceTabular}

\end{frame}
    
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .