I have to write pmatrix in the l3doc class when conducting a math-related package, and I also have to use the mathtools package to typeset the small matrix. I found that after I define a token list (It's a l3tl, but I use it in l2e environment just for writing this MWE :-))
\ExplSyntaxOn\tl_set:Nn \foo { r }\ExplSyntaxOffThen, I can use it directly like
% \usepackage{mathtools}\[ \begin{psmallmatrix*}[\foo] 1 & 2\\ 3 & 4 \end{psmallmatrix*}\]But I could not use it like the case
\[ \begin{pmatrix*}[\foo] 1 & 2\\ 3 & 4 \end{pmatrix*}\]which differs with a small prefix, returns me the following error 10 times!
Package array: Illegal pream-token (\foo): `c' used.But if I switch to the standard class, like article, the errors disappeared.
I've referred l3doc.dtx, and I think it's due to shortvrb, and I disabled | and ", but this does not work, and I've also tried applying \expandafter, it's also not work.The full MWE is the following
\documentclass{l3doc}\usepackage{mathtools}\begin{document}\ExplSyntaxOn\tl_set:Nn \foo { r }\ExplSyntaxOff\[ \begin{psmallmatrix*}[\foo] 1 & 2\\ 3 & 4 \end{psmallmatrix*}\]\[ \begin{pmatrix*}[\foo] 1 & 2\\ 3 & 4 \end{pmatrix*}\]\end{document}