请考虑以下示例:
\documentclass[
12pt,
danish,
landscape
]{article}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage[
a3paper,
hmargin = 0cm,
vmargin = 4cm
]{geometry}
\usepackage{fancyhdr}
\usepackage{diagbox}
\usepackage{
ragged2e,
array
}
\usepackage[
table
]{xcolor}
\usepackage{etoolbox}
\usepackage{xfp}
\def\mlr{2.5}
\newcommand*\mc[2]{\multicolumn{3}{c|}{\raisebox{\fpeval{#1*\mlr}ex}{\textbf{#2}}}}
\newcommand*\saenk[1]{\raisebox{\fpeval{-5/9*\mlr}ex}{#1}}
\newcommand*\tid[1]{\saenk{#1}}
\definecolor{MB}{rgb}{0.96, 0.76, 0.76}
\definecolor{MAT}{rgb}{0.13, 0.67, 0.8}
\definecolor{F/K}{rgb}{0.74, 0.2, 0.64}
\definecolor{GEO}{rgb}{0.82, 0.41, 0.12}
\definecolor{BIO}{rgb}{0.0, 0.42, 0.24}
\definecolor{HIS}{rgb}{1.0, 0.96, 0.0}
\definecolor{SAM}{rgb}{1.0, 0.31, 0.0}
\definecolor{ENG}{rgb}{0.01, 0.28, 1.0}
\definecolor{TYS}{rgb}{0.6, 0.8, 0.2}
\definecolor{DAN}{rgb}{0.93, 0.11, 0.14}
\definecolor{IDR}{rgb}{0.33, 0.41, 0.47}
\definecolor{KRI}{rgb}{0.93, 0.79, 0.69}
\definecolor{Valgfag}{rgb}{0.52, 0.73, 0.4}
\definecolor{STU}{rgb}{1, 1, 1}
\newcommand*\laerer[2]{\cellcolor{#2}\saenk{\MakeUppercase{#1}}}
\newcommand*\lokale[2]{\cellcolor{#2}\saenk{\MakeLowercase{#1}}}
\newcommand*\fag[1]{\cellcolor{#1}\saenk{\textsf{\textbf{\MakeUppercase{#1}}}}}
\pagestyle{empty}
\begin{document}
\LARGE
\begin{center}
\begin{tabular}{
|>{\RaggedRight\arraybackslash}m{6.51cm}
*{5}{|>{\RaggedRight\arraybackslash}m{1.48cm}
>{\RaggedRight\arraybackslash}m{1.70cm}
>{\RaggedRight\arraybackslash}m{0.88cm}}|
}
\hline
{\bfseries\backslashbox{Tidsrum}{Ugedag}}
& \mc{0.3}{Mandag}
& \mc{0.3}{Tirsdag}
& \mc{0.3}{Onsdag}
& \mc{0.3}{Torsdag}
& \mc{0.3}{Fredag} \\
\hline
\verb||\hphantom{1}%
\tid{8:10\,--\,8:25}
& \laerer{AJ}{MB} & \fag{MB} & \lokale{25}{MB}
& \laerer{LL}{MB} & \fag{MB} & \lokale{25}{MB}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{MB} & \fag{MB} & \lokale{25}{MB}
& \laerer{AJ}{MB} & \fag{MB} & \lokale{25}{MB} \\[\mlr ex]
\hline
\verb||\hphantom{1}%
\tid{8:25\,--\,9:10}
& \laerer{AJ}{SAM} & \fag{SAM} & \lokale{25}{SAM}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{AJ}{HIS} & \fag{HIS} & \lokale{25}{HIS} \\[\mlr ex]
\hline
\verb||\hphantom{1}%
\tid{9:10\,--\,9:55}
& \laerer{AJ}{SAM} & \fag{SAM} & \lokale{25}{SAM}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS} \\[\mlr ex]
\hline
\tid{10:25\,--\,11:10}
& \laerer{HH}{IDR} & \fag{IDR} & \lokale{hal}{IDR}
& \laerer{LL}{STU} & \fag{STU} & \lokale{25}{STU}
& \mc{0}{\fag{Valgfag}}
& \laerer{MAS}{F/K} & \fag{F/K} & \lokale{fys}{F/K}
& \laerer{MAS}{GEO} & \fag{GEO} & \lokale{25}{GEO} \\[\mlr ex]
\hline
\tid{11:10\,--\,11:55}
& \laerer{HH}{IDR} & \fag{IDR} & \lokale{hal}{IDR}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS}
& \mc{0}{\fag{Valgfag}}
& \laerer{MAS}{F/K} & \fag{F/K} & \lokale{fys}{F/K}
& \laerer{MAS}{GEO} & \fag{GEO} & \lokale{25}{GEO} \\[\mlr ex]
\hline
\tid{12:40\,--\,13:25}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG}
& \laerer{HL}{STU} & \fag{STU} & \lokale{25}{STU}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT} \\[\mlr ex]
\hline
\tid{13:25\,--\,14:10}
& \laerer{MIT}{BIO} & \fag{BIO} & \lokale{bio}{BIO}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{AJ}{HIS} & \fag{HIS} & \lokale{25}{HIS}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG} \\[\mlr ex]
\hline
\tid{14:25\,--\,15:10}
& \laerer{MIT}{BIO} & \fag{BIO} & \lokale{bio}{BIO}
& \laerer{LL}{KRI} & \fag{KRI} & \lokale{25}{KRI}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN} \\[\mlr ex]
\hline
\end{tabular}
\end{center}
\end{document}
我们可以看出,细胞之间有微小的无色垂直条纹。
我该如何摆脱这些空间?
答案1
混合使用视觉隐喻通常不是一个好主意:如果表格不使用颜色,请随意使用水平和(如果确实必须)垂直规则。相反,如果您使用颜色来设置表格单元格,那么使用水平规则实际上没有任何好处。
\documentclass[12pt,danish,landscape]{article}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage[a3paper,hmargin = 0cm, vmargin = 4cm]{geometry}
\usepackage{fancyhdr}
%%\usepackage{diagbox} % no longer needed
\usepackage{ragged2e,array}
\usepackage[table]{xcolor}
%\usepackage{etoolbox}
\usepackage{xfp}
\usepackage{booktabs} % <-- new
\def\mlr{2.5}
\newcommand*\mc[2]{\multicolumn{3}{c}{%
\raisebox{\fpeval{#1*\mlr}ex}{\textbf{#2}}}}
\newcommand*\saenk[1]{%
\raisebox{\fpeval{-5/9*\mlr}ex}{#1}}
\newcommand*\tid[1]{\saenk{#1}}
\definecolor{MB}{rgb}{0.96, 0.76, 0.76}
\definecolor{MAT}{rgb}{0.13, 0.67, 0.8}
\definecolor{F/K}{rgb}{0.74, 0.2, 0.64}
\definecolor{GEO}{rgb}{0.82, 0.41, 0.12}
\definecolor{BIO}{rgb}{0.0, 0.42, 0.24}
\definecolor{HIS}{rgb}{1.0, 0.96, 0.0}
\definecolor{SAM}{rgb}{1.0, 0.31, 0.0}
\definecolor{ENG}{rgb}{0.01, 0.28, 1.0}
\definecolor{TYS}{rgb}{0.6, 0.8, 0.2}
\definecolor{DAN}{rgb}{0.93, 0.11, 0.14}
\definecolor{IDR}{rgb}{0.33, 0.41, 0.47}
\definecolor{KRI}{rgb}{0.93, 0.79, 0.69}
\definecolor{Valgfag}{rgb}{0.52, 0.73, 0.4}
\definecolor{STU}{rgb}{1, 1, 1}
\newcommand*\laerer[2]{\cellcolor{#2}\saenk{\MakeUppercase{#1}}}
\newcommand*\lokale[2]{\cellcolor{#2}\saenk{\MakeLowercase{#1}}}
\newcommand*\fag[1]{\cellcolor{#1}\saenk{\textsf{\textbf{\MakeUppercase{#1}}}}}
\pagestyle{empty}
\begin{document}
\LARGE
\begin{center}
\begin{tabular}{
l
*{5}{>{\RaggedRight\arraybackslash}m{1.48cm}
>{\RaggedRight\arraybackslash}m{1.70cm}
>{\RaggedRight\arraybackslash}m{0.88cm}}
}
\toprule
\addlinespace
\textbf{Tidsrum} &
\multicolumn{15}{c}{\textbf{Ugedag}}\\
\cmidrule{2-16}
\addlinespace
& \mc{0.3}{Mandag}
& \mc{0.3}{Tirsdag}
& \mc{0.3}{Onsdag}
& \mc{0.3}{Torsdag}
& \mc{0.3}{Fredag} \\
\hphantom{1}\tid{8:10\,--\,\hphantom{1}8:25}
& \laerer{AJ}{MB} & \fag{MB} & \lokale{25}{MB}
& \laerer{LL}{MB} & \fag{MB} & \lokale{25}{MB}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{MB} & \fag{MB} & \lokale{25}{MB}
& \laerer{AJ}{MB} & \fag{MB} & \lokale{25}{MB} \\[\mlr ex]
\hphantom{1}\tid{8:25\,--\,\hphantom{1}9:10}
& \laerer{AJ}{SAM} & \fag{SAM} & \lokale{25}{SAM}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{AJ}{HIS} & \fag{HIS} & \lokale{25}{HIS} \\[\mlr ex]
\hphantom{1}\tid{9:10\,--\,\hphantom{1}9:55}
& \laerer{AJ}{SAM} & \fag{SAM} & \lokale{25}{SAM}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG}
& \mc{0}{\fag{Valgfag}}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS} \\[\mlr ex]
\tid{10:25\,--\,11:10}
& \laerer{HH}{IDR} & \fag{IDR} & \lokale{hal}{IDR}
& \laerer{LL}{STU} & \fag{STU} & \lokale{25}{STU}
& \mc{0}{\fag{Valgfag}}
& \laerer{MAS}{F/K} & \fag{F/K} & \lokale{fys}{F/K}
& \laerer{MAS}{GEO} & \fag{GEO} & \lokale{25}{GEO} \\[\mlr ex]
\tid{11:10\,--\,11:55}
& \laerer{HH}{IDR} & \fag{IDR} & \lokale{hal}{IDR}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS}
& \mc{0}{\fag{Valgfag}}
& \laerer{MAS}{F/K} & \fag{F/K} & \lokale{fys}{F/K}
& \laerer{MAS}{GEO} & \fag{GEO} & \lokale{25}{GEO} \\[\mlr ex]
\tid{12:40\,--\,13:25}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG}
& \laerer{HL}{STU} & \fag{STU} & \lokale{25}{STU}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT} \\[\mlr ex]
\tid{13:25\,--\,14:10}
& \laerer{MIT}{BIO} & \fag{BIO} & \lokale{bio}{BIO}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{AJ}{HIS} & \fag{HIS} & \lokale{25}{HIS}
& \laerer{LL}{MAT} & \fag{MAT} & \lokale{25}{MAT}
& \laerer{LL}{ENG} & \fag{ENG} & \lokale{25}{ENG} \\[\mlr ex]
\tid{14:25\,--\,15:10}
& \laerer{MIT}{BIO} & \fag{BIO} & \lokale{bio}{BIO}
& \laerer{LL}{KRI} & \fag{KRI} & \lokale{25}{KRI}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN}
& \laerer{CJ}{TYS} & \fag{TYS} & \lokale{25}{TYS}
& \laerer{HL}{DAN} & \fag{DAN} & \lokale{25}{DAN} \\[\mlr ex]
\end{tabular}
\end{center}
\end{document}