我正在格式化表格,但不知道如何处理几个单独的问题:
- 我不知道如何在单元格内换行但保持单元格内的边距和文本高度不变。
- 我希望在单元格中留出更多空间,以便清楚地显示最终类别属于单独的、更聚合的类别。在下面的代码中,这将在“私营部门”和“雇主”之间留出更多空间。
- 我想在一个单元格内逐项列出,或者至少让它看起来更好一些,例如“没有受薪工人的雇主”应该有相同的缩进。
- 我希望在下一个边框开始之前先切割一些表格边框,如附图所示
以下是开头带有序言的代码,表格位于最后:
\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}
如果您能提供帮助或者需要任何说明,请告诉我。
诚挚问候 Ruben
答案1
使用该nicematrix
包,您可以获得\Block
既可以用作多列又可以用作多行的命令,还允许在内部使用\\
。代码更简单,更易于维护。
例如,\Block{2-1}{Active\\ Population}
创建一个单元格,宽度为一列,高度为两行,内部有两行,垂直居中。
实线是利用该包在单元格中创建的节点之间插入tikz
命令(带有)的功能绘制的。\CodeAfter
\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}