Skip to content

Allow an empty color parameter in \columncolor #58

@tro100

Description

@tro100

How about allowing for an empty color parameter to specify no column color.
This would be very useful for defining column types that may be colored, for instance
\newcolumntype{L}[1]{>{\columncolor{#2}}l}
which then can be used also for columns without coloring.
For the use of \columncolor without optional parameters this could be done by changing the definition of \CT@extract as follows (inserted lines marked as inserted)

\def\CT@extract#1\columncolor#2#3\@nil{%
	\if!\noexpand#2%
		\let\CT@column@color\@empty%
	\else%
		\if[\noexpand#2%
			\CT@extractb{#1}#3\@nil%
		\else%
			\if\relax\detokenize{#2}\relax% inserted
				\let\CT@column@color\@empty% inserted
			\else% inserted
				\def\CT@column@color{%
						\CT@color{#2}}%
			\fi% inserted
			\CT@extractd{#1}#3\@nil%
		\fi%
	\fi%
}%

For the use of \columncolor with optional parameters

\def\CT@extractb#1#2]#3{%
	\if\relax\detokenize{#2}\relax% inserted
		\let\CT@column@color\@empty% inserted
	\else% inserted
		\def\CT@column@color{%
			\CT@color[#2]{#3}}%
	\fi% inserted
	\CT@extractd{#1}%
}%

should do the trick (although I haven't tested this).

Best regards
Rene

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions