Código

Código

Aqui eu acrescento o código \\que olha para o futuro para ver se o \endin \end{tabular}está próximo ao bastão. Este código está oculto em um arquivo \noalign. O \\tem código que procura uma estrela e depois um [antes de finalmente chamar o \cr. Suspeito que é aí que reside o problema.

Não tenho certeza se isso se aplica:

Código

Consulte Saída de registro para\typeout{\noexpand\reserved@a value: \meaning\reserved@a}

\documentclass{article}
\usepackage{fontspec}
\usepackage{booktabs}

\catcode`@=11 % or \catcode"0040=11 or \makeatletter to change category code of @ to 11 and temporarily to access kernel macro \@tabularcr
\let\clone@tabularcr\@tabularcr%
\def\@tabularcr{\clone@tabularcr \mymidline}%

% Using \hline and \midrule as a model, I made my own hybrid with some extra end of tabular logic
\def\mymidline{%
  \noalign{\ifnum0=`}\fi\@aboverulesep=\aboverulesep\global\@belowrulesep=\belowrulesep \futurelet
    \reserved@a\@mymidline}%
\def\@mymidline{\typeout{\noexpand\reserved@a value: \meaning\reserved@a}\ifx\reserved@a\end\else% <-- Here is the value test. I need \reserved@a to eventually equal \end
               \vskip\@aboverulesep%
               \hrule \@height \lightrulewidth%
               \vskip\@belowrulesep%
             \fi
      \ifnum0=`{\fi}}
\catcode`@=12 % or \catcode"0040=12 or \makeatother to restore category code of @ to 12

\begin{document}
\makeatletter
\begin{tabular}{ccc}
col1 & col2 & col3 \\
\meaning\@tabularcr & col2 & col3 \\
\meaning\\ & col2 & col3 \\
col1 & col2 & col3 \\
\meaning\clone@tabularcr & col2 & col3 \\
\end{tabular}
\makeatother
\end{document}

Saída atual

insira a descrição da imagem aqui

Saída Desejada

insira a descrição da imagem aqui

Responder1

de \\qualquer maneira, pulando espaços procurando, *você pode deixá-lo fazer o trabalho e perguntar se encontrou um\end

isso só funciona para o kernel latex, embora algumas alterações de nome também tabularpossam ser feitas para o pacote.array

\documentclass{article}

\usepackage{booktabs}

\catcode`@=11 % or \catcode"0040=11 or \makeatletter to change category code of @ to 11 and temporarily to access kernel macro \@tabularcr
\def\addmyrule{\noalign{%
           \vskip\@aboverulesep%
           \hrule \@height \lightrulewidth%
           \vskip\@belowrulesep}}

\let\old@xtabularcr\@xtabularcr

\def\@xtabularcr{%
\ifx\@let@token\end\else
\aftergroup\aftergroup\aftergroup
\aftergroup\aftergroup\aftergroup
\aftergroup
\addmyrule
\fi
\old@xtabularcr}

\catcode`@=12 % or \catcode"0040=12 or \makeatother to restore category code of @ to 12

\begin{document}
\makeatletter
\begin{tabular}{ccc}
col1 & col2 & col3 \\
\meaning\@tabularcr & col2 & col3 \\
\meaning\\ & col2 & col3 \\
col1 & col2 & col3 \\
\meaning\clone@tabularcr & col2 & col3 \\
\end{tabular}
\makeatother
\end{document}

informação relacionada