平均能量损失

平均能量损失

我正在尝试近似下表。

在此处输入图片描述

经过大量工作,我能够使用该tabu包生成下表

在此处输入图片描述

在 MWE 中我加入了这个showframe选项,只是为了看看图形溢出到边缘的位置。虽然很接近,但还是有几个问题我还没能弄清楚

  • B为什么和列之间有间隙C。是因为多列标题吗?

  • 我使用了\tabu包和X列分隔符,尽管如此,表格仍然超出右侧边距。为什么?

  • 我测试了几个不同的 PDF 查看器,发现水平和垂直规则似乎存在很多不一致之处。这可以修复吗?

  • 虽然结果很接近,但代码却完全是垃圾。我们能用更简单的代码得到类似的表格吗?

平均能量损失

\documentclass[tikz, border=1mm]{article}
\usepackage[utf8]{inputenc}

\usepackage[showframe]{geometry}

\usepackage{tabu}
\usepackage{multicol, multirow}
\usepackage[table]{xcolor}

\definecolor{maincolorLight}{HTML}{838fbc}
\definecolor{darkGray}{HTML}{e6e6e6}
\definecolor{lightGray}{HTML}{f2f2f2}

\usepackage{siunitx}

\newcolumntype{Y}{>{\columncolor{lightGray}}X}
\newcolumntype{g}{>{\columncolor{darkGray!80!black}}X[r]}

\newcommand{\tC}[1]{\multicolumn{1}{|c|}{\gK\textbf{#1}}}
\newcommand{\tR}[1]{\multicolumn{1}{|r|}{\gK\textbf{#1}}}
\newcommand{\tL}[1]{\multicolumn{1}{|l|}{\gK\textbf{#1}}}

\newcommand{\tD}[1]{\multicolumn{2}{|l}{\gK\textbf{#1}}}

\newcommand{\tM}[1]{\multicolumn{1}{|c|}{\gK$\num{#1}$}}
\newcommand{\tP}[1]{\multicolumn{1}{|c|}{\gK$\SI{#1}{\percent}$}}

\newcommand{\gK}{\cellcolor{darkGray}}
\newcommand{\cK}{\cellcolor{maincolorLight!50!}}

\newcommand{\tCc}[1]{\multicolumn{1}{|c|}{\cK #1}}
\newcommand{\tCw}[1]{\multicolumn{1}{|c|}{\cellcolor{white} #1}}

\newcommand{\Cline}[1]{\cline{1-1}\cline{#1}}

\newcommand{\tableTitle}{\multicolumn{5}{l}{\cellcolor{lightGray} \multirow{-2}{*}{\large \textbf{Skateberegning for personer med personinntekt over} $\num{565 400}$}}}

\begin{document}

\begin{table}[]
    \centering
    \begin{tabu} to \textwidth{g | Y *{5}{Y[5]}} \rowcolor{darkGray!80!black}
            &A& B              & C              & D              & E                & F                   \\ \hline 
            & &                &                  &                &                &                     \\ 
          1 & & \tableTitle                                                                               \\ \cline{1-1}
          2 & &                &                  &                &                &                     \\ \Cline{3-5}
          3 & & \tD{Personinntekt}                & \tCw{}         &                &                     \\ \Cline{3-5}
          4 & & \tD{Samlet fradrag:}              & \tCw{}         &                &                     \\ \Cline{3-5}
          5 & & \tD{Alminnelig Inntekt:}          & \tCc{}         &                &                     \\ \Cline{3-5}
          6 & &                &                  &                &                &                     \\ \Cline{1-1}
          7 & &                &                  &                &                &                     \\ \Cline{3-6}
          8 & &  \tD{}                            &\tC{Prosentsats}& \tC{Beløp}     &                     \\ \Cline{3-6}
          9 & &  \tD{Skatt av alminnelig inntekt:}& \tP{25}        & \tCc{}         &                     \\ \Cline{3-6}
         10 & &  \tD{Trygdeavgift:}               & \tP{8.5}       & \tCc{}         &                     \\ \Cline{3-6}
         11 & &                &                  &                &                &                     \\ \cline{1-1}
         12 & & \textbf{Trinnskatt} &             &                &                &                     \\ \Cline{3-7}
         13 & &  \tR{}         & \tC{Prosentsats} & \tC{Fra}       & \tC{Til}       & \tC{Skatt på trinn} \\ \Cline{3-7}
         14 & &  \tL{Trinn 1:} & \tP{0.44}        & \tM{159800.00} & \tM{224900.00} & \tCc{286.44}        \\ \Cline{3-7}
         15 & &  \tL{Trinn 2:} & \tP{1.7}         &\tM{224900.00}  & \tM{565400.00 }& \tCc{5788.50}       \\ \Cline{3-7}
         16 & &  \tL{Trinn 3:} & \tP{10.7}        & \tM{565400.00} & \tM{909500.00} & \tCc{}              \\ \Cline{3-7}
         17 & &  \tL{Trinn 4:} & \tP{13.7}        & \tM{909500.00} & \tL{}          & \tCc{}              \\ \Cline{3-7}
         18 & &  \tL{Totalt:}  & \tL{}            & \tL{}          & \tL{}          & \tCc{}              \\ \Cline{3-7}
         19 & &                &                  &                &                &                     \\ \Cline{3-4}
         20 & & \tR{Samlet skatt:} & \tCc{}       &                &                &                     \\ \Cline{3-4}
         21 & &                &                  &                &                &                     \\ 
    \end{tabu}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\end{document}

答案1

注意! 请勿使用tabu。这是一个过时且贬值的软件包。

使用卡路里

这是一个可能的解决方案卡路里。在这个第二个版本中,我使用更浅的规则(0.4pt)更新了代码。颜色根据您的 MWE 设置。我删除了背景页面颜色并将表格颜色改为浅灰色:

\documentclass[11pt, a4paper, twoside]{report} % If you use standard margins, you need 
                                               % footnotesize for table and enlarge the page with two
                                               % baselineskips to have room for the table
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}
\usepackage{xcolor, cals}

\renewcommand{\sfdefault}{uop}                % Optima as sans serif font
\renewcommand{\rmdefault}{\sfdefault}         % Whole document in sans serif

\usepackage{pdflscape}                        % It is necessary to set the table in landscape
                                              % An alternative is to rotate the table

\let\nc=\nullcell                             % Shortcuts
\let\sc=\spancontent

\definecolor{maincolorLight}{HTML}{838fbc}
\definecolor{darkGray}{HTML}{e6e6e6}
\definecolor{lightGray}{HTML}{f2f2f2}


\begin{document}

%\pagecolor{gray!10}                        % Set page background light gray
\begin{landscape}
\footnotesize                               % If not, the tabular is to wide for the standard margins

\enlargethispage{3\baselineskip}            % If not, the tabular is to high for the standard margins

\noindent\begin{calstable}

% Defining 9 column relative to each other and relative to the margins
\colwidths{{\dimexpr(\columnwidth/90 *3)\relax}
            {\dimexpr(\columnwidth/90 *3)\relax}
            {\dimexpr(\columnwidth/90 *13)\relax}
            {\dimexpr(\columnwidth/90 *13)\relax}
            {\dimexpr(\columnwidth/90 *13)\relax}
            {\dimexpr(\columnwidth/90 *13)\relax}
            {\dimexpr(\columnwidth/90 *12)\relax}
            {\dimexpr(\columnwidth/90 *10)\relax}
            {\dimexpr(\columnwidth/90 *10)\relax}
            }
% The 9 columns have to sum up to 90 to fill the text area

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.4pt}   % Outside frame rules, decrease if you find the rule too heavy
\def\cals@framecs@width{0.4pt}
\def\cals@cs@width{0.4pt}        % Inside rules, decrease if you find the rule too heavy
\def\cals@rs@width{0.4pt}
\def\cals@bodyrs@width{0.4pt}    % The rule between title and body
\cals@setpadding{Ag}             % Default value
\cals@setcellprevdepth{Al}       % Default value
\def\cals@bgcolor{}              % Initiate cals@bgcolor to empty

\def\dgray{\ifx\cals@bgcolor\empty         % Colour switch (on-off)
    \def\cals@bgcolor{darkGray!80!black}
\else \def\cals@bgcolor{} \fi}

\def\gray{\ifx\cals@bgcolor\empty          % Colour switch (on-off)
    \def\cals@bgcolor{darkGray}
\else \def\cals@bgcolor{} \fi}

\def\lgray{\ifx\cals@bgcolor\empty         % Colour switch (on-off)
    \def\cals@bgcolor{lightGray}
\else \def\cals@bgcolor{} \fi}

\def\white{\ifx\cals@bgcolor\empty         % Colour switch (on-off)
    \def\cals@bgcolor{white}
\else \def\cals@bgcolor{} \fi}

\def\blue{\ifx\cals@bgcolor\empty          % Colour switch (on-off)
    \def\cals@bgcolor{maincolorLight!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}

\def\lb{\ifx\cals@borderL\relax            % Left border switch (off-on)
    \def\cals@borderL{0pt}
\else \let\cals@borderL\relax\fi}

\def\rb{\ifx\cals@borderR\relax            % Right border switch (off-on)
    \def\cals@borderR{0pt}
\else \let\cals@borderR\relax\fi}

\def\rp{\ifdim\cals@paddingR=0.0pt\relax   % Left padding switch (off-on)
    \cals@setpadding{Ag}
\else \setlength{\cals@paddingR}{0pt}\fi}



% R1 Heading
\thead{
\brow
    \dgray\alignC\cell{}    % Switched on dark gray. Works until it is turned off. 
    \cell{A}
    \cell{B}
    \cell{C}
    \cell{D}
    \cell{E}
    \cell{F}
    \cell{G}
    \cell{H}\dgray        % Switch off dark gray at the end of the row.
\erow
}
% R2 Body
\brow
    \dgray\cell{\vfill1}\dgray
    \lgray\bb\nc{ltb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{tb}
    \nc{rtb}\sc{\rule{2pt}{0pt}\vfil\Large\bfseries Skatteberegning for personer med personinntekt over kr 565\,400}\bb\rb\lgray
\erow

% R3 Body
\brow
    \rb\dgray\cell{2}\dgray\rb
    \lgray\bb\cell{}
    \bb\cell{}
    \cell{}\bb
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R4 Body
\brow
    \bb\dgray\cell{3}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Personinntekt}\gray
    \white\cell{}\white\rb\bb
    \lgray\cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R5 Body
\brow
    \bb\dgray\alignC\cell{4}\dgray\bb
    \lgray\cell{}\rb\lgray
    \gray\bb\rb\alignL\cell{\bfseries Samlet fradrag:}\gray
    \white\cell{}\white\rb\bb
    \lgray\cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R6 Body
\brow
    \bb\dgray\alignC\cell{5}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Alminnelig inntekt:}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R7 Body
\brow
    \bb\dgray\alignC\cell{6}\dgray\rb\bb
    \lgray\cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R8 Body
\brow
    \bb\dgray\cell{7}\dgray\bb
    \lgray\rb\cell{}
    \bb\cell{}
    \cell{}
    \cell{}
    \cell{}\bb
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R9 Body
\brow
    \bb\dgray\cell{8}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\nc{ltb}
    \nc{rtb}\alignL\sc{}
    \alignC\cell{\bfseries Prosentsats}
    \cell{\bfseries Beløp}\rb\bb\gray
    \lgray\cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R10 Body
\brow
    \bb\dgray\alignC\cell{9}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\nc{ltb}
    \nc{rtb}\alignL\sc{\bfseries Skatt av alminnelig inntekt:}
    \alignC\cell{\bfseries 25 \%}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R11 Body
\brow
    \bb\dgray\cell{10}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\nc{ltb}
    \nc{rtb}\alignL\sc{\bfseries Trygdeavgift:}
    \alignC\cell{\bfseries 8,2 \%}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R12 Body
\brow
    \bb\dgray\cell{11}\dgray\bb
    \lgray\rb\cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R13 Body
\brow
    \bb\dgray\cell{12}\dgray\bb
    \lgray\rb\cell{}
    \bb\alignL\cell{\bfseries Trinnskatt}
    \cell{}
    \cell{}
    \cell{}
    \cell{}\bb
    \cell{}
    \rb\cell{}\lgray
\erow
% R5 Body
\brow
    \bb\dgray\alignC\cell{13}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\cell{}
    \alignC\cell{\bfseries Prosentsats}
    \cell{\bfseries Fra}
    \cell{\bfseries Til}
    \cell{\bfseries Skatt på trinn}\bb\rb\gray
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R5 Body
\brow
    \bb\dgray\alignC\cell{14}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Trinn 1:}
    \alignC\cell{0,44 \%}
    \alignL\cell{kr \hfill 159\,800,00}
    \alignL\cell{kr \hfill 224\,900,00}\gray
    \blue\cell{kr \hfill 286,44}\blue\bb\rb
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R16 Body
\brow
    \bb\dgray\alignC\cell{15}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Trinn 2:}
    \alignC\cell{1,4 \%}
    \alignL\cell{kr \hfill 224\,900,00}
    \alignL\cell{kr \hfill 565\,400,00}\gray
    \blue\cell{kr \hfill 5\,758,50}\blue\bb\rb
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R17 Body
\brow
    \bb\dgray\alignC\cell{16}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Trinn 3:}
    \alignC\cell{10,7 \%}
    \alignL\cell{kr \hfill 565\,400,00}
    \alignL\cell{kr \hfill 909\,500,00}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R18 Body
\brow
    \bb\dgray\alignC\cell{17}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Trinn 4:}
    \alignC\cell{13,7 \%}
    \alignL\cell{kr \hfill 909\,500,00}
    \alignL\cell{}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R19 Body
\brow
    \bb\dgray\alignC\cell{17}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Totalt:}
    \alignC\cell{}
    \alignL\cell{}
    \alignL\cell{}\gray
    \blue\cell{}\blue\bb\rb
    \lgray\cell{}
    \rb\cell{}\lgray
\erow
% R20 Body
\brow
    \bb\dgray\cell{19}\dgray\bb
    \lgray\rb\cell{}
    \bb\cell{}
    \cell{}\bb
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R21 Body
\brow
    \bb\dgray\cell{20}\dgray\bb
    \lgray\cell{}\lgray
    \gray\bb\alignL\cell{\bfseries Samlet skatt:}\gray
    \blue\cell{}\bb\blue\rb
    \lgray\cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
% R22 Body
\brow
    \bb\dgray\cell{21}\dgray
    \lgray\rb\cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \cell{}
    \rb\cell{}\lgray
\erow
\makeatletter
\end{calstable}\par % \par needed to align the tabular
\end{landscape}
\end{document}

在此处输入图片描述

使用tabular和朋友

经过多次尝试,我成功使用标准构建了表格tabular彩色表格线。构建表格很容易,但当你开始着色时,问题就开始了。当在表格中使用颜色时,clines 和其他规则会被颜色覆盖。这在彩色表格-manual。您必须使用hhline的语法逐行构建规则。当您删除规则的一部分(以模仿cline)时,线留下细的白色条纹(例如浅灰色背景)。这个答案通过改变背景颜色给出了解决方案arraycolor。语法很繁琐,特别是在复杂的表格中,你必须arraycolour多次打开和关闭。

我定义了一些简写来减少混乱,但如果你发现卡路里' 语法冗长,与此相比,这算不了什么。在我看来,卡路里更适合这种类型的表格;非常值得学习。

以下是新的 MWE 和结果表格:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1cm]{geometry}
\usepackage{multicol, array, hhline}
\usepackage[table]{xcolor}

\definecolor{maincolorLight}{HTML}{838fbc}
\definecolor{darkGray}{HTML}{e6e6e6}
\definecolor{lightGray}{HTML}{f2f2f2}

\renewcommand{\arraystretch}{1.3}
\setlength{\extrarowheight}{1pt}

\newcommand{\tableTitle}{\multicolumn{5}{l|}{\cellcolor{lightGray}\large\bfseries Skatteberegning for personer med personinntekt over kr~565\,400\rule{0pt}{4ex}}}
\newcommand{\blvi}[1]{\multicolumn{6}{l|}{\cellcolor{lightGray}#1}}
\newcommand{\blv}[1]{\multicolumn{5}{l|}{\cellcolor{lightGray}#1}}
\newcommand{\bliii}{\multicolumn{3}{l|}{\cellcolor{lightGray}}}
\newcommand{\blii}{\multicolumn{2}{l|}{\cellcolor{lightGray}}}
\newcommand{\mig}[1]{\multicolumn{1}{l}{\cellcolor{lightGray}\textbf{#1}}}
\newcommand{\mcdg}[1]{\multicolumn{1}{c|}{\cellcolor{darkGray}#1}}
\newcommand{\midg}[1]{\multicolumn{1}{|c|}{\cellcolor{darkGray}#1}}
\newcommand{\dgr}{\cellcolor{darkGray}}
\newcommand{\lgr}{\cellcolor{lightGray}}

\begin{document}

\begin{table}[tbh]
\centering\small
\begin{tabular}{|l|l|l|l|r|r|r|}

\hhline{*{7}{-}}
    \dgr{}
    &\mcdg{A}
    & \mcdg{B}  
    &\mcdg{C}
    &\mcdg{D}
    &\mcdg{E}
    &\mcdg{F}
\\
\hhline{*{7}{-}}
    \midg{1}
    &\mig{}
    &\tableTitle
\\
\hhline{|-|*{6}{>{\arrayrulecolor{lightGray}}-}|}\arrayrulecolor{black}
    \midg{2}
    &\blvi{}
\\
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{3}
    &\lgr
    &\dgr\textbf{Personinntekt:}
    &% white cell
    &\bliii
\\
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{4}
    &\lgr
    &\dgr\textbf{Samlet fradrag:}
    &% white cell
    &\bliii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{5}
    &\lgr
    &\dgr\textbf{Alminnelig inntekt:}
    &\cellcolor{maincolorLight}
    &\bliii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{6}
    &\blvi{}
\\ 
\hhline{|-|*{6}{>{\arrayrulecolor{lightGray}}-}|}
\arrayrulecolor{black}
    \midg{7}
    &\blvi{}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}---|>{\arrayrulecolor{lightGray}}--|}
\arrayrulecolor{black}
    \midg{8}
    &\lgr
    &\dgr
    &\dgr\textbf{Prosentsats}
    &\dgr\textbf{Beløp}
    &\blii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}---|>{\arrayrulecolor{lightGray}}--|}
\arrayrulecolor{black}
    \midg{9}
    &\lgr
    &\dgr\textbf{Skatt av alminnelig inntekt:}
    &\mcdg{25\,\%}
    &\cellcolor{maincolorLight}
    &\blii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}---|>{\arrayrulecolor{lightGray}}--|}
\arrayrulecolor{black}
    \midg{10}
    &\lgr
    &\dgr\textbf{Trygdeavgift:}
    &\mcdg{8,5\,\%}
    &\cellcolor{maincolorLight}
    &\blii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}---|>{\arrayrulecolor{lightGray}}--|}
\arrayrulecolor{black}
    \midg{11}
    &\blvi{}
\\ 
\hhline{|-|*{6}{>{\arrayrulecolor{lightGray}}-}|}
\arrayrulecolor{black}
    \midg{12}
    &\mig{}
    &\blv{\textbf{Trinnskatt}}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{13}
    &\lgr
    &\dgr
    &\dgr{\textbf{Prosentsats}}
    &\mcdg{\textbf{Fra}}
    &\mcdg{\textbf{Til}}
    &\dgr{\textbf{Skatt på trinn}}
\\
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{14}
    &\lgr
    &\dgr\textbf{Trinn 1:}
    &\mcdg{0,44\,\%}
    &\dgr{159\,800,00}  
    &\dgr{224\,900,00}
    &\cellcolor{maincolorLight}\textbf{286,44}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{15}
    &\lgr
    &\dgr\textbf{Trinn 2:}
    &\mcdg{1,7\,\%}
    &\dgr{224\,900,00}
    &\dgr{565\,400,00}
    &\cellcolor{maincolorLight}\textbf{5788,50}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{16}
    &\lgr
    &\dgr\textbf{Trinn 3:}
    &\mcdg{10,7\,\%}
    &\dgr{565\,400,00}
    &\dgr{909\,500,00}
    &\cellcolor{maincolorLight}
\\
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{17}
    &\lgr
    &\dgr\textbf{Trinn 4:}
    &\mcdg{13,7\,\%}
    &\dgr{909\,500,00}
    &\dgr
    &\cellcolor{maincolorLight}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{18}
    &\lgr
    &\dgr\textbf{Totalt:}
    &\dgr
    &\dgr
    &\dgr
    &\cellcolor{maincolorLight}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}-----|}
    \midg{19}
    &\blvi{}
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{20}
    &\lgr
    &\dgr\textbf{Samlet skatt:}
    &\cellcolor{maincolorLight}
    &\bliii
\\ 
\hhline{|-|>{\arrayrulecolor{lightGray}}->{\arrayrulecolor{black}}--|>{\arrayrulecolor{lightGray}}---|}
\arrayrulecolor{black}
    \midg{21}
    &\blvi{}
\\ 
\lasthline
    \end{tabular}
    \caption{Caption}
    \label{tab:my_label}
\end{table}
\end{document}

在此处输入图片描述

答案2

值得一提的是,该软件包pas-tableur是专门为创建电子表格布局而制作的,尽管可能不是问题中所示的具有丰富单元格格式(不同的网格厚度/背景等)(或者可能非常适合这个目的,我真的从来没有用过它)。

姆韦

\documentclass{article}
\usepackage{pas-tableur}
\begin{document}

\begin{tikzpicture}
\tableur[8]{A,B,C,D,E}
\celtxt[color=red]{D}{1}{=B3}
\celtxt*[r]{A}{3}{$\pi =$}
\celtxt*{B}{3}{3.14}
\selecCell{C}{5}
\celtxt[l]{C}{5}{28/12/2017}
\multiSelec{A-1}{C-2}
\celtxt[c]{B}{7}{Very long text that take more than one cell}
\end{tikzpicture}

\end{document}

答案3

以下是您可以使用 做的{NiceTabular}事情nicematrix

\documentclass{article}
\usepackage{xcolor,nicematrix,tikz}

\begin{document}

\definecolor{verylightgray}{gray}{0.95}
\NewDocumentCommand{\Price}{m}{\Block[l]{}{kr}\Block[r]{}{#1}}

\setlength{\tabcolsep}{2pt}
\sffamily
\begin{NiceTabular}{cc>{\bfseries}lw{c}{25mm}w{c}{25mm}w{c}{25mm}ccc}[colortbl-like]
\CodeBefore
  \tikz \fill [verylightgray] (1-|1) rectangle (last-|last) ; 
\Body
  \Block[hvlines,fill=[gray]{0.9}]{*-1}{}
     & \Block[hvlines,fill=[gray]{0.9}]{1-*}{}
       A & \Block[c]{}{\normalfont\sffamily B} & C & D & E & \Block[c]{}{F} & G & H \\
  1  & & \RowStyle[cell-space-top-limit=5pt]{}
         \Block[l]{1-*}{\large \bfseries Skatteberegning for personer med personinntekt over 565 400 kroner} \\
  2  \\
  3  & & \Block[hvlines]{3-2}{}
         Personinntekt & \cellcolor{white} \\
  4  & & Samlet fradrag & \cellcolor{white} \\
  5  & & Alminnelig inntekt & \cellcolor{red!15} \\
  6  \\
  7  \\
  8  & & \RowStyle{\bfseries}
         \Block[hvlines]{3-4}{}\Block{1-2}{}         && Prosensats & Beløp \\
  9  & & \Block[l]{1-2}{Skatt av alminnelig inntekt} && 25 \%  & \cellcolor{red!15} \\
  10 & & \Block[l]{1-2}{Trygdeavgift}                && 8.2 \% & \cellcolor{red!15} \\
  11 \\
  12 & & \bfseries Trinnskatt \\
  13 & & \RowStyle{\bfseries}
         \Block[hvlines]{6-5}{} & Prosentats & Fra        & Til & Skatt på trinn\\
  14 & & Trinn 1:               & 0.44 \%    & \Price{159 800.00} & \Price{224 900.00} & \cellcolor{red!15} \Price{286.44} \\
  15 & & Trinn 2:               & 1.7 \%     & \Price{224 900.00} & \Price{565 400.00} & \cellcolor{red!15} \Price{5788.50} \\
  16 & & Trinn 3:               & 10.7 \%    & \Price{565 400.00} & \Price{909 500.00} & \cellcolor{red!15} \\
  17 & & Trinn 4:               & 13.7 \%    & \Price{909 500.00} &                    & \cellcolor{red!15} \\
  18 & & Totalt:                &            &                    &                    & \cellcolor{red!15} \\
  19 \\
  20 & & \Block[hvlines]{1-2}{} Samlet skatt: & \cellcolor{red!15} \\
  21 \\
\end{NiceTabular}

\end{document}

您需要多次编译(因为nicematrix在后台使用 PGF/Tikz 节点)。

上述代码的输出

相关内容