我有一张彩色桌子,我希望它看起来比较统一,并且\caption
彩色空间内部也可以用作标题。我可以用插入桌号,\thetable
但之后我必须手动将其添加到\listoftables
每张桌子,所以我正在寻找更好的解决方案。感谢您的任何建议。
这是我的简化代码:
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage{longtable}
\usepackage[table]{xcolor}
\begin{document}
\newcolumntype{R}{>{\raggedright\arraybackslash}b}
\newcolumntype{C}{>{\centering\arraybackslash}b}
\rowcolors{1}{gray!10}{gray!5}
\begin{longtable}{|R{\dimexpr 0.08\linewidth-2\tabcolsep}|
R{\dimexpr 0.52\linewidth-2\tabcolsep}||
C{\dimexpr 0.2\linewidth-2\tabcolsep}|
C{\dimexpr 0.2\linewidth-2\tabcolsep}|}
\hline
\rowcolor{gray!10}
\multicolumn{4}{|c|}{\large\textbf{Table \thetable : Tabulka procesů }} \T \\
\hline
\rowcolor{gray!10}
A & B & C & D\\
\hline\hline
\endfirsthead
\hline
A & B & C & D\\ \\
\hline\hline
\endhead
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
\end{longtable}
\end{document}
答案1
longtable\caption
已经是\multicolumn{4}{c}
(在这种情况下)你只想重新定义它,{|c|}
这样
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[czech]{babel}
\usepackage{longtable}
\usepackage[table]{xcolor}
\begin{document}
\newcolumntype{R}{>{\raggedright\arraybackslash}b}
\newcolumntype{C}{>{\centering\arraybackslash}b}
\rowcolors{1}{gray!10}{gray!5}
\makeatletter
\def\LT@makecaption#1#2#3{%
\LT@mcol\LT@cols{|c|}{#1{#2: }#3}}
\makeatother
\begin{longtable}{|R{0.08\dimexpr(\linewidth-8\tabcolsep-5\arrayrulewidth-\doublerulesep-.4pt)}|
R{ .52\dimexpr(\linewidth-8\tabcolsep-5\arrayrulewidth-\doublerulesep-.4pt)}||
C{.2\dimexpr (\linewidth-8\tabcolsep-5\arrayrulewidth-\doublerulesep-.4pt)}|
C{.2\dimexpr (\linewidth-8\tabcolsep-5\arrayrulewidth-\doublerulesep-.4pt)}|}
\hline
\rowcolor{gray!10}
\caption{Tabulka procesů}\\
\hline
\rowcolor{gray!10}
A & B & C & D\\
\hline\hline
\endfirsthead
\hline
A & B & C & D\\ \\
\hline\hline
\endhead
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
1 & 2 & 3 & 4 \\ \hline
\end{longtable}
\end{document}