行颜色需要从顶行到底行更新,在禁忌包中,行颜色从底行到顶行更新,如何将颜色更改作为默认从顶行到底行的颜色作为替代。
注意:当我使用\taburowcolors[1]{rowcolor..white}
PDF 输出中更改的 rowcolor 颜色值百分比时。
请查看 MWE:
\documentclass{book}
\usepackage[table]{xcolor} %for use in color links
\usepackage{colortbl}
\usepackage{ragged2e}
\usepackage{tabu}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{>{\Centering\arraybackslash\hspace{0pt}}p{#1}}
\makeatletter
\def\tstrut{}
\def\bstrut{}
\definecolor{rowcolor}{cmyk}{0.11,0.08,0.07,0}
\long\def\tabuprocesstable#1#2#3{\bgroup%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%TEMP%%%%%%%%%%%%%%%%%%%%%%%%%%%
\arrayrulewidth=1pt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%TEMP%%%%%%%%%%%%%%%%%%%%%%%%%%%
\rowcolors{1}{rowcolor}{white}
\def\arraystretch{1.7}%
\parindent0pt
#1\par%
\noindent{#2}\par%
{#3}\par%
\egroup}%
\def\colhead#1{\sffamily\bfseries#1}
\makeatletter
\begin{document}
\begin{table}[!h]\tabuprocesstable{}
{\begin{tabu}{L{230pt}L{140pt}}
\colhead{\textbf{Subject}}
&
\colhead{\textbf{Paragraphs}}
\\
Selection and application of accounting policies
&
7–12
\\
Consistency of accounting policies
&
13
\\
Changes in accounting policies
&
14–27
\\
Disclosure of changes in accounting policies
&
28–31
\\
Changes in accounting estimates
&
32–40
\\
Errors
&
41–42
\\
XX&YY\\
\tabucline{-}
\end{tabu}}
{}
\end{table}
\begin{table}[!h]\tabuprocesstable{}
{\begin{tabu}{L{230pt}L{140pt}}
\colhead{\textbf{Subject}}
&
\colhead{\textbf{Paragraphs}}
\\
Selection and application of accounting policies
&
7–12
\\
Consistency of accounting policies
&
13
\\
Changes in accounting policies
&
14–27
\\
Disclosure of changes in accounting policies
&
28–31
\\
Changes in accounting estimates
&
32–40
\\
Errors
&
41–42
\\
\tabucline{-}
\end{tabu}}
{}
\end{table}
\end{document}
答案1
由于您似乎不使用类型tabu
的X
列,因此实际上根本不需要tabu
。您可以改用简单的tabular
。在下面的示例中,我还使用了\rowcolors
命令来实现交替行颜色。
由于您的表格对于标准页面的文本宽度来说太宽book
(见红线),您可能需要减小表格的整体宽度。这可以使用l
类型列而不是固定宽度L
类型列来实现。表格的内容足够短,表格可以适合文本宽度,而无需在单元格内容中使用换行符。或者,特别是如果您要在第一列中添加更宽的内容,您可能需要查看包tabularx
(参见第 3 个示例):
\documentclass{book}
\usepackage[table]{xcolor} %for use in color links
%\usepackage{colortbl} % Not needed as automatically loaded by \usepackage[table]{xcolor}
\usepackage{ragged2e}
%%%%% Show border of textblock. Do not use in real document
\usepackage{showframe}
\renewcommand*\ShowFrameColor{\color{red}}
%%%%%%%
\usepackage{tabularx} % Only used for third example
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hspace{0pt}}p{#1}}
%\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash\hspace{0pt}}p{#1}}
%\newcolumntype{C}[1]{>{\Centering\arraybackslash\hspace{0pt}}p{#1}}
\definecolor{rowcolor}{cmyk}{0.11,0.08,0.07,0}
\newcommand{\colhead}[1]{\sffamily\textbf{#1}}
\begin{document}
\begin{table}[!h]
\renewcommand\arraystretch{1.7}
\rowcolors{1}{rowcolor}{white}
\begin{tabular}{L{230pt}L{140pt}}
\colhead{Subject}
&
\colhead{Paragraphs}
\\
Selection and application of accounting policies
&
7–12
\\
Consistency of accounting policies
&
13
\\
Changes in accounting policies
&
14–27
\\
Disclosure of changes in accounting policies
&
28–31
\\
Changes in accounting estimates
&
32–40
\\
Errors
&
41–42
\\
XX&YY\\
\hline
\end{tabular}
\end{table}
\begin{table}[!h]
\renewcommand\arraystretch{1.7}
\rowcolors{1}{rowcolor}{white}
\begin{tabular}{ll}
\colhead{Subject}
&
\colhead{Paragraphs}
\\
Selection and application of accounting policies
&
7–12
\\
Consistency of accounting policies
&
13
\\
Changes in accounting policies
&
14–27
\\
Disclosure of changes in accounting policies
&
28–31
\\
Changes in accounting estimates
&
32–40
\\
Errors
&
41–42
\\
XX&YY\\
\hline
\end{tabular}
\end{table}
\begin{table}[!h]
\renewcommand\arraystretch{1.7}
\rowcolors{1}{rowcolor}{white}
\begin{tabularx}{\textwidth}{Xl}
\colhead{Subject}
&
\colhead{Paragraphs}
\\
Selection and application of accounting policies
&
7–12
\\
Consistency of accounting policies
&
13
\\
Changes in accounting policies
&
14–27
\\
Disclosure of changes in accounting policies
&
28–31
\\
Changes in accounting estimates
&
32–40
\\
Errors
&
41–42
\\
XX&YY\\
\hline
\end{tabularx}
\end{table}
\end{document}