I have need to split the table to next page without using longtable
package. Because longtable
package is not supporting directly float
.
MY MWE is:
\documentclass{article}
\usepackage{luacode}
\begin{document}
\begin{luacode*}
local domobject = require "luaxml-domobject"
sample = [[
<?xml version="1.0" encoding="utf-8"?>
<art>
<title>Scattering of flexural waves an electric current</title>
<p>From these observations, another important result is that the individual masses of such observed black hole–black hole (BBHs) binaries can be much larger than what were expected previously both theoretically and observationally [14], and various scenarios have been proposed [<xref ref-type="bibr" rid="cqgab7bbabib2">2</xref>, <xref ref-type="bibr" rid="cqgab7bbabib26">26</xref>]. In particular, observations of the same signal in two different detectors provides an efficient independent way to cross check and validate the instruments, which is particularly valuable for a space-based detector behavior of these parameters is presented in the table <xref ref-type="table" rid="cqgab7bbat1">1</xref>.</p>
<table-wrap id="tab1" position="float" tab-row-break="5"><label>Table 1.</label><caption id="tab1"><p>The large <italic>x</italic> behavior for different <italic>w</italic>, where <italic>F</italic> means finite.</p></caption><table><colgroup><col align="left"/><col align="center"/><col align="center"/><col align="center"/><col align="center"/><col align="center"/><col align="center"/></colgroup><thead><tr><th>Parameters:</th><th>e<sup>2<italic>γ</italic></sup></th><th><italic>r</italic><sup>2</sup></th><th><italic>ρ</italic></th><th><italic>L</italic></th><th><italic>V</italic></th><th><italic>E</italic></th></tr></thead><tbody><tr><td>A1</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr><tr><td>B2</td><td>0</td><td>∞</td><td><italic>F</italic></td><td><italic>F</italic></td><td><italic>F</italic></td></tr><tr><td>C3</td><td>∞</td><td>0</td><td><italic>F</italic></td><td><italic>F</italic></td><td><italic>F</italic></td></tr><tr><td>D4</td><td>0</td><td>∞</td><td><italic>F</italic></td><td><italic>F</italic></td><td><italic>F</italic></td><td><italic>F</italic></td></tr><tr><td>E5</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td><td><italic>F</italic></td><td><italic>F</italic></td></tr><tr><td>F6</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr><tr><td>G7</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr><tr><td>H8</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr><tr><td>I9</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr><tr><td>J10</td><td>∞</td><td>∞</td><td>0</td><td>∞</td><td>∞</td><td><italic>F</italic></td></tr></tbody></table></table-wrap>
</art>
]]
local dom = domobject.parse(sample)
\end{luacode*}
\end{document}
If table
is attribute is having tab-row-break='5'
, I have need to count the table-row from tbody
and not in thead
and need to give close tabular
and open new tabular
like \end{tabular}\pagebreak\begin{tabular}{...}
.
How to achieve this?
Best Answer
You can transform your XML using the
luaxml-transform
library, but this task is made more difficult by the request to split the table into two floats, based on thetab-row-break
attribute. We can use theluaxml-domobject
library to preprocess XML, split the table and then we can easily use the transform library.This is the full code, I will describe it bellow:
This is the part that deals with tables:
First of all, it converts the column alignment information to LaTeX tabular specification and saves it as an attribute for the
<table>
element. It makes the transformation easier. It then makes two float elements, and copies the original table content to them. We then remove spurious table rows from both copies, and set(continued...)
as table caption for the second float.This DOM object can then be transformed using the following rules:
There is nothing too special, only see that we need to handle last items in rows, in order to prevent insertion of the extra
&
character, it would cause compilation error. This we need thetbody td:last-of-type
rule.Also note that we use the
align
attribute that we defined by the DOM processing function earlier, to set the correct tabular declaration.We also expect that
<label>
and<caption>
elements are next to each other, because they produce the\tablecaption
command, and it would break if they weren't at their expected places.Lastly, see that you need to use a font that supports all special characters, like Linux Libertine in my example.
This is the result: