当我使用 修剪表格的两侧时@{}
, 会\rowcolor
悬垂在两侧。我已<{\kern-\tabcolsep}
在第一列和最后一列上修复了这个问题(根据这个问题)。但是,如果\makecell
在第一列或最后一列中使用,则此方法无效。
梅威瑟:
\documentclass[11pt, a4paper]{scrartcl}
\usepackage[left=25mm,right=25mm,top=35mm,bottom=25mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage[flushleft]{threeparttable}
\newcommand{\ltnote}[1]{\textsuperscript{\TPTtagStyle{#1}}}
\usepackage{siunitx}
\colorlet{tableheadcol}{gray!25}
\colorlet{rowcol}{gray!10}
\newcommand{\topline}{\arrayrulecolor{black}\specialrule{\heavyrulewidth}{\abovetopsep}{0pt}%
\arrayrulecolor{tableheadcol}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}\rowcolor{tableheadcol}}
\newcommand{\midline}{\arrayrulecolor{tableheadcol}\specialrule{\aboverulesep}{0pt}{0pt}%
\arrayrulecolor{black}\specialrule{\lightrulewidth}{0pt}{0pt}%
\arrayrulecolor{white}\specialrule{\belowrulesep}{0pt}{0pt}%
\arrayrulecolor{black}}
\newcommand{\bottomline}{\arrayrulecolor{white}\specialrule{\aboverulesep}{0pt}{-2pt}%
\arrayrulecolor{black}\specialrule{\heavyrulewidth}{0pt}{\belowbottomsep}}
\begin{document}
\begin{table}
\centering\small
\rowcolors{3}{rowcol}{white}
\begin{threeparttable}
\begin{tabular}{>{\kern-\tabcolsep}lS[table-format=4.0]c<{\kern-\tabcolsep}}
\topline
Kraftwerk & {\makecell{Leistung \\ in \si{\MW}\ltnote{b}}} & \makecell{geplante \\ Inbetriebnahme} \\
\midline
Berlin-Klingenberg & 300 & 2020 \\
Berlin Lichtenberg & 260 & 2020 \\
Burghausen & 850 & 2023 \\
Dörpen & 170 & 2020 \\
Gersteinwerk & 1300 & 2023 \\
Herne 6 & 650 & 2022 \\
Rheinhafen RDK 6s & 465 & 2021 \\
Krefeld-Uerdingen & 900 & 2025 \\
Leverkusen-Wiesdorf & 570 & 2022 \\
Premnitz & 400 & 2023 \\
\bottomline
\end{tabular}
\begin{tablenotes}
\footnotesize
\item[a] Kraftwerksprojekte ab einer elektrischen Bruttoleistung von \SI{100}{\MW}
\item[b] elektrische Bruttoleistung
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
答案1
正如@leandriis 在评论中所建议的那样,添加Kraftwerk & {\makecell{Leistung \\ in \si{\MW}\ltnote{b}}} & \begin{tabular}{@{}c<{\kern-\tabcolsep}}geplante \\ Inbetriebnahme\end{tabular} \\
标题可以解决问题。
答案2
您可以使用 轻松制作此表nicematrix
。
\documentclass{article}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{siunitx}
\begin{document}
\begin{NiceTabular}{@{}lS[table-format=4.0]c@{}}
\CodeBefore
\rowcolor{gray!25}{1}
\rowcolors{2}{gray!10}{}
\Body
\toprule
Kraftwerk & {\Block{}{Leistung \\ in \unit{\MW}}} & \Block{}{geplante \\ Inbetriebnahme} \\
\midrule
Berlin-Klingenberg & 300 & 2020 \\
Berlin Lichtenberg & 260 & 2020 \\
Burghausen & 850 & 2023 \\
Dörpen & 170 & 2020 \\
Gersteinwerk & 1300 & 2023 \\
Herne 6 & 650 & 2022 \\
Rheinhafen RDK 6s & 465 & 2021 \\
Krefeld-Uerdingen & 900 & 2025 \\
Leverkusen-Wiesdorf & 570 & 2022 \\
Premnitz & 400 & 2023 \\
\bottomrule
\end{NiceTabular}
\end{document}
答案3
可以package cals
处理规则和颜色
平均能量损失
\documentclass{article}
\usepackage{cals}
\usepackage{xcolor}
\begin{document}
\begin{table*}[!htb]
\begin{calstable}[c]
% Defining columns
\colwidths{{1.5cm}
{2.25cm}
{1.75cm}
}
% Set up the tabular
\makeatletter
\def\cals@framers@width{0.8pt} % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0pt}
\def\cals@bodyrs@width{0.4pt} % "midrule" - line between heading and body
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0pt} % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.6pt}
\def\cals@bgcolor{}
\def\gray{\ifx\cals@bgcolor\empty % "Switch" to turn on and off colour
\def\cals@bgcolor{gray!50}
\else \def\cals@bgcolor{} \fi}
\def\bb{\ifx\cals@borderB\relax % Bottom border switch (off-on)
\def\cals@borderB{0pt}
\else \let\cals@borderB\relax\fi}
% R1B1
\thead{%
\brow
\gray\alignC\cell{1}\gray
\alignL\cell{2}
\gray\alignC\cell{3}\gray
\erow
}
%R2B2
\brow
\gray\alignC\cell{\vfil one}\gray
\alignL\cell{\vfil two}
\gray\alignC\cell{\vfil three}\gray
\erow
%R3B3
\brow
\gray\bb\alignC\cell{\vfil one}\bb\gray
\alignL\cell{\vfil two}
\gray\alignC\cell{\vfil three}\gray
\erow
%R4B4
\brow
\gray\alignC\cell{\vfil one}\gray
\alignL\cell{\vfil two}
\gray\alignC\cell{\vfil three}\gray
\erow
%R4B4
\brow
\gray\alignC\cell{\vfil un}\gray
\alignL\cell{\vfil deux}
\gray\alignC\cell{\vfil trois}\gray
\erow
\makeatletter
\end{calstable}\par
\caption{caption}
\end{table*}
\end{document}