
Aquí agrego un código \\
que mira hacia adelante para ver si la \end
entrada \end{tabular}
está al lado del bate. Este código está oculto dentro de un archivo \noalign
. Tiene \\
un código que busca una estrella y luego una [
antes de finalmente llamar al archivo \cr
. Sospecho que aquí radica el problema.
No estoy seguro de si esto se aplica:
- Ignorar espacios y \par después de un entorno, porque
\\
se cambia dentro de la tabla para cumplir con TeX\cr
(retorno de carro de fin de fila).
Código
Consulte Salida 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}
Salida de corriente
Salida deseada
Respuesta1
Como \\
de todos modos, saltando espacios en busca, *
puede dejar que haga el trabajo y preguntarle si encontró un\end
Esto solo funciona para el kernel de látex, aunque también tabular
se pueden realizar algunos cambios de nombre para el paquete.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}