Package array has a \newcolumntype but seemingly no \renewcolumntype. But it makes a lot of sense to have a column type X whose meaning could be changed depending on context. When one does \newcolumntype again, it works, the only thing is that an innocent warning is written to the log. Is there some official way I missed from reading the doc which would allow of genuinely renewing an array-declared column type?
Asked
Active
Viewed 881 times
7
lockstep
- 250,273
1 Answers
11
Elaborating on David's idea:
\newcommand\undefcolumntype[1]{\expandafter\let\csname NC@find@#1\endcsname\relax}
\newcommand\forcenewcolumntype[1]{\undefcolumntype{#1}\newcolumntype{#1}}
I don't call it \renewcolumntype since it works even if the column type is not defined (which is a different behaviour from \renewcommand). Whence the name \forcenewcolumntype.
Thanks to jfbu for spotting out a crucial typo in the code.
\newcolumntypeis it that you want to suppress the warning? – David Carlisle Nov 11 '13 at 17:27\newcolumntype, where the identifier is one and the same, private to the package, and to not worry the user, suppressing the warning would be just fine. – Nov 11 '13 at 17:39\let\NC@find@X\relaxto undefine the column before defining it. – David Carlisle Nov 11 '13 at 17:42\MATdisplaymacro sets up a simple*{N}carray preamble, whereNis the variable number of columns, and I wanted to make it easy for the user to replacecbyrfor example. So currently the type is calledXand renewed with the resulting warning. – Nov 11 '13 at 17:44\NC@list? – Nov 11 '13 at 17:44multicolumninstead of redefinitions:\begin{tabular}{|l|l|l|} column1 & column2 & column 3\\hline A & B & \multicolumn{1}{|r|}{C}\\end{tabular}– masu Nov 11 '13 at 17:45\newcolumntype\MATdisplaycoltype {c} \newcolumntype\MATdisplaypreamble [1]{@{}*{#1[J]}\MATdisplaycoltype@{}}. I use the possibility of having a column type stand for an entire preamble, and furthermore to have a parameter (the#1[J]will expand to a number of columns). The user should be able to easily switch\MATdisplaycoltypefromctor. But redefining it issues the warning. – Nov 11 '13 at 17:51\NC@find@\stuff, thanks. – Nov 11 '13 at 18:04