带有双粗细线的Latex表格

带有双粗细线的Latex表格

我想创建下表。但我被卡住了,总有一些东西让我不知所措。我无法实现这个表。包相互干扰或线路被切断。 在此处输入图片描述

谢谢你的帮助

答案1

以下内容可以作为起点:

在此处输入图片描述

\documentclass{article}
\usepackage{boldline}

\begin{document}
\begin{tabular}{|c|c|c|cV{2.7}c|}
\hline
D & C & B & A & S\\
\hline\hline
0 & 0 & 0 & 0 & - \\
0 & 0 & 0 & 0 & - \\
0 & 0 & 0 & 0 & - \\
0 & 0 & 0 & 0 & - \\
\hlineB{2.7}
0 & 0 & 0 & 0 & - \\
\end{tabular}
\end{document}

答案2

我已经使用标准为您的表格提供了代码和示例tabular我已经为您的表格提供了使用标准环境和使用包的卡路里。难点在于避免第 1 行和第 2 行之间的水平双线覆盖垂直线。请注意使用tabular线在不同的 PDF 查看器中可能看起来不同。

CALS 表

这是一个使用的解决方案卡路里-packages。由于您可以打开和关闭每个单元格的规则(包括厚度)calstable,因此可以排版没有断线的表格。

  1. 我使用以下命令设置非常窄的行 (2pt),模拟了第 1 行和第 2 行之间的双线:

    \ht\cals@current@row=2pt
    

    由于calstable不支持双重规则。我已移除该行中所有单元格的顶部填充,但在移除底部填充时遇到了一些问题。因此,您将收到一些有关 的警告Overfull hboxes。只需忽略它们即可。

  2. 粗水平线使用on/off命令 ( \bbb- 粗体底部边框) 排版,将底部边框设置为1.5pt。此命令将一直有效,直到在行末关闭为止。
  3. 垂直粗线(边框)的排版使用类似的命令(\brb- 粗右边框),在受影响单元格的开头和结尾处打开和关闭粗线。设置垂直线有点繁琐,因为卡路里没有影响一行中所有单元格的命令。

在此处输入图片描述

\documentclass{article}
\usepackage{cals}

\begin{document}

\begin{calstable}[c]
% Defining 12 equal columns
\colwidths{{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}{24pt}
            }

% Set up the tabular
\makeatletter
\def\cals@framers@width{0.3pt}   % Outside frame rules, reduce if the rule is too heavy
\def\cals@framecs@width{0.3pt}
\def\cals@bodyrs@width{0.3pt}
\cals@setpadding{Ag}
\cals@setcellprevdepth{Al}
\def\cals@cs@width{0.3pt}             % Inside rules, reduce if the rule is too heavy
\def\cals@rs@width{0.3pt}
\def\cals@bgcolor{}

\def\bbb{\ifx\cals@borderB\relax     % Bold Bottom Border switch (off-on)
    \def\cals@borderB{1.5pt}
\else \let\cals@borderB\relax\fi}

\def\brb{\ifx\cals@borderR\relax     % Bold Right Border switch (off-on)
\def\cals@borderR{1.5pt}
\else \let\cals@borderR\relax\fi}

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

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

% R1H1
\thead{\itshape\large%
\brow
    \alignC\cell{D}
    \cell{C}
    \cell{B}
    \brb\cell{A}\brb  % Switch on and off heavy vertical rule for this cell
    \cell{S}
    \brb\cell{T}\brb
    \cell{U}
    \brb\cell{V}\brb
    \cell{W}
    \brb\cell{X}\brb
    \cell{Y}
    \brb\cell{Z}\brb
\erow
\upshape%
}
\tfoot{\lastrule\strut}
%R2B1 % This sexond row is just to ‘fake’ double horizontal lines
\brow
    \tp\cell{}
    \cell{}
    \cell{}
    \brb\cell{}\brb
    \cell{}
    \brb\cell{}\brb
    \cell{}
    \brb\cell{}\brb
    \cell{}
    \brb\cell{}\brb
    \cell{}
    \brb\cell{}\brb\tp
    \ht\cals@current@row=2pt
\erow
%R3B2
\brow
    \alignC\cell{0}
    \cell{0}
    \cell{0}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
\erow
%R4B3
\brow
    \cell{0}
    \cell{0}
    \cell{0}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
\erow
%R5B4
\brow
    \cell{0}
    \cell{0}
    \cell{1}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
\erow
%R5B4
\brow
    \bbb\cell{0}
    \cell{0}
    \cell{1}
    \brb\cell{1}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{0}\bbb\brb
\erow
%R6B5
\brow
    \cell{0}
    \cell{1}
    \cell{0}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{1}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{1}
    \brb\cell{--}\brb
\erow
%R7B6
\brow
    \cell{0}
    \cell{1}
    \cell{0}
    \brb\cell{1}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{1}\brb
\erow
%R8B7
\brow
    \cell{0}
    \cell{1}
    \cell{1}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{1}\brb
    \cell{1}
    \brb\cell{--}\brb
\erow
%R9B8
\brow
    \bbb\cell{0}
    \cell{1}
    \cell{1}
    \brb\cell{1}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{1}\bbb\brb
\erow
%R10B9
\brow
    \cell{1}
    \cell{0}
    \cell{0}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{1}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{1}
    \brb\cell{--}\brb
\erow
%R11B10
\brow
    \cell{1}
    \cell{0}
    \cell{0}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{0}\brb
\erow
%R12B11
\brow
    \cell{1}
    \cell{0}
    \cell{1}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{1}\brb
\erow
%R13B12
\brow
    \bbb\cell{1}
    \cell{0}
    \cell{1}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{1}\bbb\brb
\erow
%R14B13
\brow
    \cell{1}
    \cell{1}
    \cell{0}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{1}\brb
    \cell{1}
    \brb\cell{--}\brb
    \cell{1}
    \brb\cell{--}\brb
\erow
%R15B14
\brow
    \cell{1}
    \cell{1}
    \cell{0}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{0}\brb
    \cell{0}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{1}\brb
\erow
%R16B15
\brow
    \cell{1}
    \cell{1}
    \cell{1}
    \brb\cell{0}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
\erow
%R17B16
\brow
    \bbb\cell{1}
    \cell{1}
    \cell{1}
    \brb\cell{1}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb
    \cell{--}
    \brb\cell{--}\brb\bbb
\erow
\makeatletter
\end{calstable}\par
\end{document}

Tabular、colortbl 和 hhline

这是使用表格tabular。我避免使用覆盖规则彩色表(通过彩色使用表格选项)和线。如您所见,hhline语法很复杂。您可以通过语法*{<no>}{<col>}和主体将复杂的规则定义为命令来简化序言中的代码。如果您发现繁重的规则太重,您可以减少\arrayrulewidth\doublerulesep

在此处输入图片描述

\documentclass{article}
\usepackage{array, hhline}
\usepackage[table]{xcolor}

\setlength{\extrarowheight}{1.5pt}
\renewcommand*{\arraystretch}{1.2}

\begin{document}
\setlength\doublerulesep{1pt}{\doublerulesepcolor{black}
\begin{tabular}{|c|c|c|c||c|c||c|c||c|c||c|c||}
\hline
\itshape D & \itshape C & \itshape B & \itshape A & \itshape S & \itshape T &\itshape U&\itshape V&\itshape W&\itshape X&\itshape Y&\itshape Z\\
\hhline{>{\doublerulesepcolor{white}}|=|=|=|=%
>{\doublerulesepcolor{black}}||>{\doublerulesepcolor{white}}=|=%
>{\doublerulesepcolor{black}}||>{\doublerulesepcolor{white}}=|=%
>{\doublerulesepcolor{black}}||>{\doublerulesepcolor{white}}=|=%
>{\doublerulesepcolor{black}}||>{\doublerulesepcolor{white}}=|=%
>{\doublerulesepcolor{black}}||>{\doublerulesepcolor{white}}%
}
0 & 0 & 0 & 0 & -- & -- &-- &-- &-- &-- &-- &-- \\
\hline
0 & 0 & 0 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\hline
0 & 0 & 1 & 0 & -- & -- &-- &-- &-- &-- &-- &-- \\
\hline
0 & 0 & 1 & 1 & 1 & -- & 1 &-- &-- & 1 &-- & 0 \\
\hhline{>{\doublerulesepcolor{black}}|=|=|=|=||=|=||=|=||=|=||=|=||}
0 & 1 & 0 & 0 & 0 & -- & -- & 1 & 1 & -- & 1 &-- \\
\hline
0 & 1 & 0 & 1 & 0 & -- & -- & 0 & 0 & -- & -- & 1 \\
\hline
0 & 0 & 0 & 0 & 0 & -- & -- & 0 &-- & 1 & 1 & -- \\
\hline
0 & 1 & 1 & 1 & 0 & -- & -- & 0 & -- & 0 & -- & 1 \\
\hhline{>{\doublerulesepcolor{black}}|=|=|=|=||=|=||=|=||=|=||=|=||}
1 & 0 & 0 & 0 & -- & 1 & 1 &-- & 1 &-- & 1 & -- \\
\hline
1 & 0 & 0 & 1 & -- & 0 & 0 &-- & 0 & -- & -- & 1 \\
\hline
1 & 0 & 1 & 0 & -- & 0 & 0 &-- & -- & 1 & 1 & -- \\
\hline
1 & 0 & 1 & 1 & -- & 0 & 0 &-- & -- & 0 & -- & 1 \\
\hhline{>{\doublerulesepcolor{black}}|=|=|=|=||=|=||=|=||=|=||=|=||}
1 & 1 & 0 & 0 & -- & 0 & -- & 1 & 1 & -- & 1 & -- \\
\hline
1 & 1 & 0 & 1 & -- & 0 & -- & 0 & 0 & -- & -- & 1 \\
\hline
1 & 1 & 1 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\hline
1 & 1 & 1 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\hhline{>{\doublerulesepcolor{black}}|=|=|=|=||=|=||=|=||=|=||=|=||}
\end{tabular}
\end{document}

答案3

{NiceTabular}这是使用 的解决方案nicematrix。该包nicematrix提供了定义命令和字母(用于数组前导)的工具,以便根据 Tikz 的规范绘制规则。为了完美地结合规则,我调整了\boldlineTikz 参数shorten >和的行为shorten <

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

\setlength{\extrarowheight}{1.5pt}
\renewcommand*{\arraystretch}{1.2}

\begin{document}

\NiceMatrixOptions
  {
    custom-line = 
     {
       letter = I ,
       command = normalline ,
       tikz = { line width = 0.4 pt } ,
       total-width = 0.4 pt
     } ,
    custom-line = 
     {
       letter = J ,
       tikz = { line width = 1.2 pt } ,
       total-width = 0.8 pt
     } ,
    custom-line = 
     {
       command = boldline ,
       tikz = { line width = 1 pt , shorten > = -0.2pt , shorten < = -0.4pt } ,
       total-width = 1 pt
     } ,
  }

\begin{NiceTabular}{IcIcIcIcJcIcJcIcJcIcJcIcJ}
\normalline
\RowStyle{\itshape}
D & C & B & A & S & T & U & V & W & X & Y & Z \\
\hline\hline
0 & 0 & 0 & 0 & -- & -- &-- &-- &-- &-- &-- &-- \\
\normalline
0 & 0 & 0 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\normalline
0 & 0 & 1 & 0 & -- & -- &-- &-- &-- &-- &-- &-- \\
\normalline
0 & 0 & 1 & 1 & 1 & -- & 1 &-- &-- & 1 &-- & 0 \\
\boldline
0 & 1 & 0 & 0 & 0 & -- & -- & 1 & 1 & -- & 1 &-- \\
\normalline
0 & 1 & 0 & 1 & 0 & -- & -- & 0 & 0 & -- & -- & 1 \\
\normalline
0 & 0 & 0 & 0 & 0 & -- & -- & 0 &-- & 1 & 1 & -- \\
\normalline
0 & 1 & 1 & 1 & 0 & -- & -- & 0 & -- & 0 & -- & 1 \\
\boldline
1 & 0 & 0 & 0 & -- & 1 & 1 &-- & 1 &-- & 1 & -- \\
\normalline
1 & 0 & 0 & 1 & -- & 0 & 0 &-- & 0 & -- & -- & 1 \\
\normalline
1 & 0 & 1 & 0 & -- & 0 & 0 &-- & -- & 1 & 1 & -- \\
\normalline
1 & 0 & 1 & 1 & -- & 0 & 0 &-- & -- & 0 & -- & 1 \\
\boldline
1 & 1 & 0 & 0 & -- & 0 & -- & 1 & 1 & -- & 1 & -- \\
\normalline
1 & 1 & 0 & 1 & -- & 0 & -- & 0 & 0 & -- & -- & 1 \\
\normalline
1 & 1 & 1 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\normalline
1 & 1 & 1 & 1 & -- & -- &-- &-- &-- &-- &-- &-- \\
\boldline
\end{NiceTabular}
\end{document}

您需要多次编译(因为 PGF/Tikz 节点)。

上述代码的输出

相关内容