表格垂直边距未对齐

表格垂直边距未对齐

希望我没有发布重复的内容。我有下表: 在此处输入图片描述

我有两个问题,非常感谢大家的帮助。如图所示,垂直文本溢出了水平文本(例如“标准化”和“成熟度”)。此外,元素之间的间距不同(“受监管”和“标准化”之间的间距与“数据”和“可互换”之间的间距不同)。代码在这里:https://pastebin.com/xrGnW3Aa

我怎样才能使该表格看起来如下所示,包括垂直边距和垂直单词之间的间距?

在此处输入图片描述

非常感谢

编辑:来源-

\documentclass{article}
\usepackage[
singlelinecheck=false
]{caption}
\usepackage{adjustbox}
\usepackage[table,xcdraw]{xcolor}

\begin{table}[h]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|l|c|l|l|l}
\hline
\multicolumn{5}{|c|}{\textbf{Asset}} &
  \multicolumn{13}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Trust \\ Establishment\end{tabular}}} &
  \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}CC-Tx \\ Realization\end{tabular}}} \\ \hline
\multicolumn{3}{|c|}{\textbf{Type}} &
  \multicolumn{2}{c|}{\textbf{Maturation}} &
  \multicolumn{3}{c|}{\textbf{Correctness}} &
  \multicolumn{6}{c|}{\textbf{Decentralization}} &
  \multicolumn{4}{c|}{\textbf{Channel}} &
   &
   &
  \multicolumn{1}{l|}{} \\ \cline{1-18}
 &
   &
   &
   &
   &
   &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
   &
   &
  \multicolumn{1}{l|}{} \\
 &
   &
   &
   &
   &
   &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
  \multicolumn{2}{l|}{} &
   &
   &
  \multicolumn{1}{l|}{} \\
\multirow{-3}{*}{\rotV{Data}} &
  \multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Fungible}}} &
  \multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Non-fungible}}} &
  \multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{\centering Standardized}}} &
  \multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Regulated}}} &
  \multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Behavioral}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Formal}}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{User}}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Consortium}}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Trusted Party}}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{On-chain}}}} &
  \multicolumn{2}{l|}{\multirow{-3}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Off-chain}}}} &
  \multirow{-4}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Cross-claim}}} &
  \multirow{-4}{*}{\rotatebox[origin=c]{90}{\parbox[c]{1cm}{Escrowed cross-claim}}} &
  \multicolumn{1}{l|}{\multirow{-4}{*}{\rotV{Mediate}}} \\ \hline
\multicolumn{1}{|c|}{\cellcolor[HTML]{D8E3BB}+} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{BF504D}-} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{F79545}$\pm$} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{D8E3BB}+} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{D8E3BB}+} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{D8E3BB}+} &
  \multicolumn{2}{c|}{\cellcolor[HTML]{D8E3BB}+} &
  \multicolumn{2}{c|}{\cellcolor[HTML]{BF504D}-} &
  \multicolumn{2}{c|}{\cellcolor[HTML]{BF504D}-} &
  \multicolumn{2}{c|}{\cellcolor[HTML]{BF504D}-} &
  \multicolumn{2}{c|}{\cellcolor[HTML]{BF504D}-} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{F79545}$\pm$} &
  \cellcolor[HTML]{F79545}$\pm$ &
  \multicolumn{1}{c|}{\cellcolor[HTML]{F79545}$\pm$} &
  \multicolumn{1}{c|}{\cellcolor[HTML]{F79545}$\pm$} &
  \multicolumn{1}{c}{\cellcolor[HTML]{F79545}$\pm$} \\ \hline
\end{tabular}%
}
\caption{}
\label{tab:my-table}
\end{table}
\end{document}

答案1

tabularx

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage[singlelinecheck=false
            ]{caption}
\usepackage{adjustbox}
\newcommand\RotText[1]{\rotatebox{90}{\parbox{2.5 cm}{\raggedright#1}}}
\usepackage[table,xcdraw]{xcolor}
\usepackage{makecell, tabularx}
\renewcommand\theadfont{\small\bfseries}
\renewcommand\theadgape{}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c|}{#2}}
\NewExpandableDocumentCommand\mcd{O{1}m}
    {\multicolumn{#1}{|c|}{#2}}

\begin{document}
    \begin{table}[ht]
    \renewcommand\arraystretch{1.2}
    \setlength\tabcolsep{3pt}
\caption{This is a table}
\label{tab:my-table}
\begin{tabularx}{\textwidth}{|*{15}{C|} }
    \hline
\mcd[5]{\thead{Asset}}  & \mcc[7]{\thead{Trusted Establishment}}   
    &\mcc[3]{\thead{CC-Tx\\ realization}}           \\ \hline
\mcd[3]{\thead{Type}}   & \mcc[2]{\thead{Maturation}} 
    & \mcc[2]{\thead{Correctness}} 
                        & \mcc[3]{\thead{Decentralization}} 
    & \mcc[2]{\thead{channel}}  &   &   &           \\ \cline{1-12}
\RotText{Data} 
    & \RotText{Fungible} 
        & \RotText{Non-fungible} 
            & \RotText{Standardized}    
                & \RotText{Regulated}   
                    & \RotText{Behavioural} 
                        & \RotText{Formal}  
                            & \RotText{User} 
    & \RotText{Consortium}
        & \RotText{Trusted Party}
            & \RotText{On-chain}
                & \RotText{Off-chain}
                    & \RotText{cross-claim}
                        & \RotText{Esscrowded cross-claim}
                            & \RotText{Mediaate}    \\ \hline
\cellcolor{green}{+} 
    & \cellcolor{red}{-} 
        & \cellcolor{orange}{$\pm$} 
            & \cellcolor{green}{+} 
                & \cellcolor{green}{+}
                    & \cellcolor{green}{+}
                        & \cellcolor{green}{+}
                            & \cellcolor{red}{-}
    & \cellcolor{red}{-}
        & \cellcolor{red}{-}
            & \cellcolor{red}{-}
                & \cellcolor{orange}{$\pm$}
                    &  \cellcolor{orange}{$\pm$}
                        & \cellcolor{orange}{$\pm$}
                            & \cellcolor{orange}{$\pm$}
    \\ \hline
    \end{tabularx}
    \end{table}
\end{document}

注意:表格非常宽,因此 MWE 使用geometry包来定义更宽的文本区域。

在此处输入图片描述

答案2

也许这对你来说是一个解决方案:

\documentclass{article}
\usepackage[
singlelinecheck=false
]{caption}
\usepackage{adjustbox}
\usepackage[table,xcdraw]{xcolor}

\newcommand\RotText[1]{\rotatebox{90}{\parbox{2.5 cm}{\raggedright#1}}}


\begin{document}
    
\renewcommand{\arraystretch}{1.25}
\begin{table}[]
    \centering
    \caption{This is a table:}
    \label{tab:my-table}
    \begin{adjustbox}{max width=\textwidth}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
        \hline
        \multicolumn{5}{|c|}{\textbf{Asset}} &
        \multicolumn{8}{c|}{\begin{tabular}{@{}c@{}}\textbf{Trusted} \\ \textbf{Establishment}\end{tabular}} &
        \multicolumn{3}{c|}{\begin{tabular}{@{}c@{}}\textbf{CC-Tx} \\ \textbf{realization}\end{tabular}} \\ \hline
        \multicolumn{3}{|c|}{\textbf{Type}} &
        \multicolumn{2}{c|}{\textbf{Maturation}} &
        \multicolumn{2}{c|}{\textbf{Correctness}} &
        \multicolumn{3}{c|}{\textbf{Decentralization}} &
        \multicolumn{3}{c|}{\textbf{Channel}} &
        &
        &
        \\ \cline{1-13}
        \RotText{Data} &
        \RotText{Fungible} &
        \RotText{Non-fungible} &
        \RotText{Standardized} &
        \RotText{Regulated} &
        \RotText{Behavioural} &
        \RotText{Formal} &
        \RotText{User} &
        \RotText{Consortium} &
        \RotText{Trusted Party} &
        \RotText{On-chain} &
        \multicolumn{2}{c|}{\RotText{Off-chain}} &
        \RotText{cross-claim} &
        \RotText{Esscrowded cross-claim} &
        \RotText{Mediaate} \\ \hline
        \cellcolor[HTML]{34FF34}+ &
        \cellcolor[HTML]{FE0000}- &
        \cellcolor[HTML]{F56B00} $\pm$ &
        \cellcolor[HTML]{34FF34} + &
        \cellcolor[HTML]{34FF34} + &
        \cellcolor[HTML]{34FF34} + &
        \cellcolor[HTML]{34FF34} + &
        \cellcolor[HTML]{FE0000} - &
        \cellcolor[HTML]{FE0000} - &
        \cellcolor[HTML]{FE0000} - &
        \cellcolor[HTML]{FE0000} - &
        \cellcolor[HTML]{F56B00} $\pm$ &
        \cellcolor[HTML]{F56B00} $\pm$ &
        \cellcolor[HTML]{F56B00} $\pm$&
        \cellcolor[HTML]{F56B00} $\pm$ &
        \cellcolor[HTML]{F56B00} $\pm$ \\ \hline
    \end{tabular}
\end{adjustbox}
\end{table}

\end{document}

在此处输入图片描述

编辑:

\documentclass{article}
\usepackage[
singlelinecheck=false
]{caption}
\usepackage{adjustbox}
\usepackage[table,xcdraw]{xcolor}

\newcommand\RotText[1]{\rotatebox{90}{\parbox{2.5 cm}{\raggedright#1}}}

\usepackage{array}
\newcolumntype{A}{>{\centering}m{0.1\textwidth}}


\begin{document}
    

\renewcommand{\arraystretch}{1.25}
\begin{table}[h]
\centering
\caption{This is a table:}
\label{tab:my-table}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{|A|A|A|A|A|A|A|A|A|A|A|A|AAA|}
    \hline
    \multicolumn{5}{|c|}{\textbf{Asset}} & 
    \multicolumn{7}{c|}{\begin{tabular}{@{}c@{}}\textbf{Trusted} \\ \textbf{Establishment}\end{tabular}} & \multicolumn{3}{c|}{\textbf{CC-Tx realization}} \\ \cline{1-12}
    \multicolumn{3}{|c|}{\textbf{Type}} &
    \multicolumn{2}{c|}{\textbf{Maturation}} &
    \multicolumn{2}{c|}{\textbf{Correctness}} &
    \multicolumn{3}{c|}{\textbf{Decentralization}} &
    \multicolumn{2}{c|}{\textbf{Channel}} &
    &
    &
    \\ \hline
\RotText{Data} &
\RotText{Fungible} &
\RotText{Non-fungible} &
\RotText{Standardized} &
\RotText{Regulated} &
\RotText{Behavioural} &
\RotText{Formal} &
\RotText{User} &
\RotText{Consortium} &
\RotText{Trusted Party} &
\RotText{On-chain} &
\RotText{Off-chain} &
\multicolumn{1}{A|}{\RotText{cross-claim}} &
\multicolumn{1}{A|}{\RotText{Escrowded cross-claim}} &
\RotText{Mediate}  \tabularnewline  \hline
\cellcolor[HTML]{34FF34}+   & 
\cellcolor[HTML]{FE0000}-   & 
\cellcolor[HTML]{F56B00} $\pm$  & 
\cellcolor[HTML]{34FF34}+   & 
\cellcolor[HTML]{34FF34}+    & 
\cellcolor[HTML]{34FF34}+    & 
\cellcolor[HTML]{34FF34}+     & 
\cellcolor[HTML]{FE0000}-   & 
\cellcolor[HTML]{FE0000}-   & 
\cellcolor[HTML]{FE0000}-   & 
\cellcolor[HTML]{FE0000}-   & 
\cellcolor[HTML]{F56B00} $\pm$   & 
\multicolumn{1}{c|}{\cellcolor[HTML]{F56B00} $\pm$}       & 
\multicolumn{1}{c|}{\cellcolor[HTML]{F56B00} $\pm$}     & 
\cellcolor[HTML]{F56B00} $\pm$     \tabularnewline \hline
\end{tabular}
\end{adjustbox}
\end{table}

\end{document}

在此处输入图片描述

相关内容