This also supports booktabs
rules with a handy syntax.
Limitation. The cells in each row should have the same height. Double rules are not supported.
\documentclass{article}
\usepackage{xparse,environ,booktabs}
\ExplSyntaxOn
\NewEnviron{splittabular}[1]
{
\dim_set:Nn \lineskip { 2ex }
\phpirate_splittabular:nV { #1 } \BODY
\par
}
\int_new:N \l__phpirate_rows_int
\seq_new:N \l__phpirate_body_seq
\cs_generate_variant:Nn \seq_set_split:Nnn { c }
\cs_new_protected:Nn \phpirate_splittabular:nn
{
\seq_set_split:Nnn \l__phpirate_body_seq { \\ } { #2 }
\int_zero:N \l__phpirate_rows_int
\seq_map_inline:Nn \l__phpirate_body_seq
{
\int_incr:N \l__phpirate_rows_int
\seq_clear_new:c { \__phpirate_row:n { \l__phpirate_rows_int } }
\seq_set_split:cnn { \__phpirate_row:n { \l__phpirate_rows_int } } { & } { ##1 }
% check for \hline
\tl_clear_new:c { \__phpirate_hline:n { \l__phpirate_rows_int } }
\seq_pop_left:cN { \__phpirate_row:n { \l__phpirate_rows_int } } \l_tmpa_tl
\tl_set_eq:NN \l_tmpb_tl \l_tmpa_tl
\regex_replace_once:nnN { \c{hline|toprule|midrule|bottomrule} } { } \l_tmpa_tl
\seq_put_left:cV { \__phpirate_row:n { \l__phpirate_rows_int } } \l_tmpa_tl
\regex_replace_once:nnN { (\c{hline|toprule|midrule|bottomrule}+).* } { \1 } \l_tmpb_tl
\tl_set_eq:cN { \__phpirate_hline:n { \l__phpirate_rows_int } } \l_tmpb_tl
% end code for \hline
}
\int_step_inline:nnnn { 1 } { 1 } { \seq_count:c { \__phpirate_row:n { 1 } } }
{
\__phpirate_column:nn { #1 } { ##1 }
}
}
\cs_generate_variant:Nn \phpirate_splittabular:nn { nV }
\cs_new_protected:Nn \__phpirate_column:nn
{
\seq_clear:N \l__phpirate_column_seq
\int_step_inline:nnnn { 1 } { 1 } { \l__phpirate_rows_int }
{
\seq_put_right:Nx \l__phpirate_column_seq
{
\exp_not:v { \__phpirate_hline:n { ##1 } }
\seq_item:cn { \__phpirate_row:n { ##1 } } { #2 }
}
}
\begin{tabular}[t]{#1}
\seq_use:Nn \l__phpirate_column_seq { \\ }
\end{tabular}
\linebreak[0]
}
\cs_new:Nn \__phpirate_row:n
{
l__phpirate_row_ \int_eval:n { #1 } _seq
}
\cs_new:Nn \__phpirate_hline:n
{
l__phpirate_hline_ \int_eval:n { #1 } _tl
}
\ExplSyntaxOff
\begin{document}
\begin{center}
\begin{splittabular}{c}
\toprule
a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z\\
\midrule
z&y&x&w&v&u&t&s&r&q&p&o&n&m&l&k&j&i&h&g&f&e&d&c&b&a \\
one&two&three&four&five&six&seven&eight&nine&ten&eleven&twelve&
thirteen&fourteen&fifteen&sixteen&seventeen&eighteen&nineteen&
twenty&twenty-one&twenty-two&twenty-three&twenty-four&twenty-five&twenty-six \\
\bottomrule
\end{splittabular}
\end{center}
\end{document}
It works also with \hline
.
