0

I'm trying to patch \\ in tabular enviros using \@tabularcr as I've read that it uses it internally, and I'd like to simply add \midrule on each row (my real-life use is a bit more complex, but simplified here for MWE sake). I've tried \apptocmd as well but got a failure. Please see below. I don't get a failure for trying to patch it this way, but the midrules do not print.

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

%%% patching does not work \makeatletter \let\old@tabularcr@tabularcr \def@tabularcr{\old@tabularcr\midrule} \makeatother

\begin{document}

\begin{tabular}{l}

%%% patching in here doesn't work either \makeatletter \let\old@tabularcr@tabularcr \def@tabularcr{\old@tabularcr\midrule} \makeatother

Hello\ World\ \end{tabular}

\end{document}

  • you are using the array package, so you need to patch another command, see https://tex.stackexchange.com/questions/111668/tabular-with-automatic-hline – Ulrike Fischer Nov 27 '22 at 18:26
  • I see now tht \@arraycr is needed. – likethevegetable Nov 27 '22 at 18:27
  • @likethevegetable no, it isn't, and the suggestion to patch \@xarraycr in the linked question's answers will not lead to correct results as well (it will kill the optional argument of \\). Correct would be to patch both \@xargarraycr and \@yargarraycr. – Skillmon Nov 27 '22 at 18:44
  • 1
    @likethevegetable I've added my own code to patch tabular and array in the linked question (it does more than just patching \\ but I guess you could take a look). – Skillmon Nov 28 '22 at 19:57
  • Thanks for nothing that @Skillmon, some good ideas there. – likethevegetable Nov 29 '22 at 12:34

0 Answers0