0

I was trying to redefine an old command \lightrule with the new syntax from xparse.

When I try to use \newlightrule unexpectedly it displays Misplaced \noalign error.

Minimal Working Example and desired result follows.


enter image description here


\documentclass[margin=2mm]{standalone}

\usepackage[table]{xcolor} \usepackage{booktabs}

\newcommand{\lightrule}{ \arrayrulecolor{black!30}% \midrule[\lightrulewidth]% \arrayrulecolor{black}% }

\usepackage{xparse} \NewDocumentCommand{\newlightrule}{}{ \arrayrulecolor{black!30}% \midrule[\lightrulewidth]% \arrayrulecolor{black}% }

\begin{document}

\begin{tabular}{c l} \toprule test & test\ \midrule test & test\ \lightrule test & test\ \bottomrule \end{tabular}

\end{document}

1 Answers1

4

You should use \NewExpandableDocumentCommand to define. As David said xparse is not needed unless you have an old latex release.

I also suggest you to use tabularray to typeset your table, it's easy to use.

\documentclass[margin=2mm]{standalone}

\usepackage[table]{xcolor} \usepackage{booktabs}

% \newcommand{\lightrule}{ % \arrayrulecolor{black!30}% % \midrule[\lightrulewidth]% % \arrayrulecolor{black}% % }

% \usepackage{xparse} \NewExpandableDocumentCommand{\newlightrule}{}{ \arrayrulecolor{black!30}% \midrule[\lightrulewidth]% \arrayrulecolor{black}% }

\usepackage{tabularray}

\begin{document}

\begin{tabular}{c l} \toprule test & test\ \midrule test & test\ \newlightrule test & test\ \bottomrule \end{tabular}

\begin{tblr} { colspec={Q[c,m]Q[l,m]}, hline{1,Z}={wd=.08em}, hline{2}={wd=.05em}, hline{3}={wd=.05em,fg=black!30}, } test & test\ test & test\ test & test\ \end{tblr}

\end{document}

enter image description here

Clara
  • 6,012