我有一个使用 tcolorbox 制作的漂亮格式的表格,它在后台使用了 tabularx。但是,我不知道如何配置它,就像使用 tabularx 一样,使表格适合线宽 - 而不在表格内留下空白。
我期待的一个解决方案是,例如,自动拉伸其中一个单元格以使其占据整个空间(就像我的目标表对“Esteira Transportadora”单元格所做的那样)。
平均能量损失
\documentclass[12pt,a4paper, article]{abntex2}
%%%%%%%%%%%% ----------- PACOTES/PACKAGES ----------- %%%%%%%%%%%%%%
%%% Special Tables // Tabelas especiais
\usepackage[table, dvipsnames, svgnames]{xcolor} %% Definição de cores
\usepackage[most]{tcolorbox} %%Mudar ambientes de blocos
%multi-row
\begin{document}
\newcolumntype{Y}{>\arraybackslash\multirow{2}{*}{X}}% see tabularx
\tcbset{enhanced,fonttitle=\bfseries\large,fontupper=\normalsize\sffamily,
colback=yellow!10!white, colframe=red!50!black,colbacktitle=Salmon!30!white,
coltitle=black,center title,sharp corners, drop fuzzy shadow=black!30!white}
\begin{tcolorbox}[tabularx={l|c|c|c|c|c|c|}]
%%%%%%%%%%%%%% Primeira coluna
\hline
\cellcolor{orange!30} &
\cellcolor{Lavender!70} &
\cellcolor{white} &
\cellcolor{Lavender!70} &
Setor & Planta & Patrimônio \\
%%%%%%%%%%%%% Primeira coluna
\cline{5-7}
%%%%%%%%%%%%%%%% Segunda coluna
\multirow{-2}{*}{\cellcolor{orange!30}42.} &
\multirow{-2}{*}{\cellcolor{Lavender!70} \textbf{Máquina}}&
\multirow{-2}{*}{\cellcolor{white} \textbf{Esteira Transportadora}}&
\multirow{-2}{*}{\cellcolor{Lavender!70} \textbf{Localização}}&
53,8\% &
&
Não identificado
%%%%%%%%%%%%%%%% Segunda coluna
\end{tcolorbox}
\end{document}
答案1
我研究了 tcolorbox 上的配置并执行以下操作:
\newcolumntype{Y}{>{\raggedleft}X}% see tabularx
\tcbset{enhanced,fonttitle=\bfseries\large,fontupper=\normalsize\sffamily,
colback=yellow!10!white, colframe=red!50!black,colbacktitle=Salmon!30!white,
coltitle=black,center title,sharp corners, drop fuzzy shadow=black!30!white}
\begin{tcolorbox}[tabularx={l|c|X|c|c|c|c|}]
%%%%%%%%%%%%%% Primeira coluna
\hline
\cellcolor{orange!30} &
\cellcolor{Lavender!70} &
\cellcolor{white} &
\cellcolor{Lavender!70} &
Setor & Planta & Patrimônio \\
%%%%%%%%%%%%% Primeira coluna
\cline{5-7}
%%%%%%%%%%%%%%%% Segunda coluna
\multirow{-2}{*}{\cellcolor{orange!30}42.} &
\multirow{-2}{*}{\cellcolor{Lavender!70} \textbf{Máquina}}&
\multirow{-2}{*}{\cellcolor{white} \textbf{Esteira Transportadora}}&
\multirow{-2}{*}{\cellcolor{Lavender!70} \textbf{Localização}}&
53,8\% &
&
Não identificado
%%%%%%%%%%%%%%%% Segunda coluna
\end{tcolorbox}
它就是这样工作的,尽管我不明白为什么当时它不起作用。或者为什么现在它起作用了。但是,我接受它。