我正在尝试制作一个好看的禁忌,作为我正在处理的一份作业的一部分。如果我简单地使用l
、c
或r
作为列的参数,它看起来不错。
然而,当我尝试定义列的宽度时(p{3.75cm}
在本例中),问题出现了。用于将 tabu 下部分成三部分的垂直线消失了。
这就是我希望禁忌的样子,只有列的宽度是预定义的,就像这样:
但是如您所见,本例中的分隔线消失了。我该如何恢复它们?
\documentclass[danish]{report}
\usepackage[a4paper, headheight=14pt]{geometry}
\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}
\usepackage{babel}
% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}
\begin{document}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
\multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
D & E & F & \\
G & H & I &
\end{tabu}
\caption{My caption}
\label{my-label}
\end{table}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{l|l|ll}
\multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
C & D & E & \\
F & G & H &
\end{tabu}
\caption{My caption2}
\label{my-label2}
\end{table}
\end{document}
答案1
\documentclass[danish]{report}
\usepackage[a4paper, headheight=14pt]{geometry}
\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}
\usepackage{babel}
% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}
\begin{document}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
\multicolumn{1}{c|}{\textbf{Scenarie}} & \multicolumn{1}{c|}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
D & E & F & \\
G & H & I &
\end{tabu}
\caption{My caption}
\label{my-label}
\end{table}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{l|l|ll}
\multicolumn{1}{c|}{\textbf{Scenarie}} & \multicolumn{1}{c|}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
C & D & E & \\
F & G & H &
\end{tabu}
\caption{My caption2}
\label{my-label2}
\end{table}
\end{document}
新修改的代码
\documentclass[danish]{report}
\usepackage[a4paper, headheight=14pt]{geometry}
\usepackage[table]{xcolor}
\usepackage{float}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{tabu}
\usepackage{babel}
% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}
\begin{document}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{p{3.75cm}|p{3.75cm}|p{3.75cm}l}
\multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
D & E & F & \\
G & H & I &
\end{tabu}
\caption{My caption}
\label{my-label}
\end{table}
\begin{table}[H]
\centering
\taburowcolors 2 {white .. UMLetGray}
\begin{tabu}{l|l|ll}
\multicolumn{1}{c}{\textbf{Scenarie}} & \multicolumn{1}{c}{\textbf{Resultat}} & \multicolumn{1}{c}{\textbf{Godkendt}} & \\
\hline
A & B & C & \\
C & D & E & \\
F & G & H &
\end{tabu}
\caption{My caption2}
\label{my-label2}
\end{table}
\end{document}
答案2
使用。{NiceTabular}
无论nicematrix
使用哪种 PDF 查看器,垂直规则都不会消失。
\documentclass[danish]{report}
\usepackage[a4paper, headheight=14pt]{geometry}
\usepackage{xcolor}
\usepackage{float}
\usepackage{nicematrix}
\usepackage{babel}
% Define colors
\definecolor{UMLetBlue}{RGB}{130,130,255}
\definecolor{UMLetGray}{RGB}{189,189,189}
\definecolor{UMLetGreen}{RGB}{130,255,130}
\definecolor{UMLetRed}{RGB}{255,130,130}
\definecolor{UMLetYellow}{RGB}{255,255,130}
\begin{document}
\begin{table}[H]
\centering
\begin{NiceTabular}{p{3.75cm}|p{3.75cm}|p{3.75cm}}
\CodeBefore
\rowcolors{2}{white}{UMLetGray}
\Body
\RowStyle{\bfseries\centering}\Block{1-*}{}
Scenarie & Resultat & Godkendt \\
\hline
A & B & C \\
C & D & E \\
F & G & H
\end{NiceTabular}
\caption{My caption2}
\label{my-label2}
\end{table}
\begin{table}[H]
\centering
\begin{NiceTabular}{l|l|l}
\CodeBefore
\rowcolors{2}{white}{UMLetGray}
\Body
\RowStyle{\bfseries}\Block{1-*}{}
Scenarie & Resultat & Godkendt \\
\hline
A & B & C \\
C & D & E \\
F & G & H
\end{NiceTabular}
\caption{My caption2}
\label{my-label2}
\end{table}
\end{document}
您需要多次编译(因为nicematrix
在后台使用 PGF/Tikz 节点)。