我发现 longtabu 里面的 longtabu 是不可能的,但也许存在另一种解决方案。我正在自动生成大量 latex 代码来记录某种二进制通信协议,我需要表格跨越嵌入另一个表格的页面,而该表格本身最多可以跨越两页。下面的代码并不漂亮,但它可以使用 TexLive 和 TexLive 额外字体(适用于 LY1)进行编译。任何关于如何实现的建议都会受到欢迎。我的
\documentclass[oneside,a4paper,12pt,notitlepage]{report}
\usepackage[top=3cm, bottom=4.5cm, left=3cm, right=3cm]{geometry}
\usepackage[LY1]{fontenc}
\usepackage{mathptmx} % Add bold and italic
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{longtable} % also needed by longtabu
\usepackage{tabu}
\usepackage{multirow}
\begin{document}
\hspace{-0.6cm}\begin{longtabu}{| l | l | l | X | l | l |}
\firsthline
\textbf{Id} & 20 & \textbf{Name}: &Settings & \textbf{Data Size}: & 26 bytes\\
\hline
\multicolumn{6}{|l|}{
\begin{minipage}[t]{0.97\textwidth}
\textbf{Description}: This packet is being sent ..ehehe
\vspace{1mm}
\end{minipage}
} \\
\hline
\multicolumn{6}{|c|}{ \textbf{Fields:} } \\
\multicolumn{6}{ | l |}{
% I would like to have another longtable here .. the nested table does not break across pages
\begin{tabularx}{0.95\textwidth}{ | l | l | X |}
\firsthline
\textbf{Bits} & \textbf{Field Name} & \textbf{Description}\\
\hline
0 : 2 & SETTING\_A &
\begin{minipage}[t]{0.47\textwidth}
\textbf{Values}:\\0 - MODE\_A \\ \textit{Comment A.}\\1 - MODE\_B\\\textit{Comment B . dsdsjkhdsakjahsasd}\\2 - MODE\_C\\\textit{Comment C. asdsadasfsddssd}\\3 - MODE\_D\\\textit{Comment D. fdassdaskjdhasd}\\4 - MODE\_E\\\textit{Comment E. fdjksfdsjhgffhjjjhsfd}\\5 - MODE\_F\\\textit{Comment F}\\6 - MODE\_G\\\textit{Comment E}\\\vspace{-0.27cm}
\end{minipage}
\tabularnewline \hline
3 : 7 & SETTING\_B &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
8 : 10 & SETTING\_C &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
11 : 13 & SETTING\_D &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
14 : 16 & SETTING\_E &
\begin{minipage}[t]{0.47\textwidth}
\textbf{Values}:\\0 - PH\_A\\\textit{Aomment A}\\1 - PH\_B\\\textit{Comment B}\\2 - PH\_C\\\textit{Comment C dsasdjka hsdkjah dsakjsadh kjdash ksaj}\\3 - PH\_D\\\textit{Comment D fdsfdsfdsf sdsdfds}\\4 - PH\_E\\\textit{Comment E asdkhdaskjdshjsakhasdkjds}\\5 - PH\_F\\\textit{Comment F. dsajashsaddsasfdfsddsf}\\\vspace{-0.27cm}
\end{minipage}
\tabularnewline \hline
17 : 29 & SETTING\_F &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
30 : 42 & SETTING\_G &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
43 : 48 & SETTING\_H &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
49 : 54 & SETTING\_I &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
55 : 61 & SETTING\_J &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
62 : 77 & SETTING\_K &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
78 : 93 & SETTING\_L &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
94 : 109 & SETTING\_M &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\\\hline
110 : 125 & SETTING\_N &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
126 : 141 & SETTING\_L &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
142 : 150 & PULSE\_WIDTH &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
151 : 159 & PULSE\_WIDTH\_HIGH &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
160 : 175 & DELAY &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
176 : 188 & TOTAL\_PROGRAM\_TIME &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
189 : 201 & TOTAL\_PHASE\_TIME &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \lasthline
\end{tabularx}
} \\
\lasthline
\end{longtabu}
\end{document}
答案1
你需要把需要破坏的任何部分都做成外表的一部分,就像这样
\documentclass[oneside,a4paper,12pt,notitlepage]{report}
\usepackage[top=3cm, bottom=4.5cm, left=3cm, right=3cm]{geometry}
\usepackage[LY1]{fontenc}
\usepackage{mathptmx} % Add bold and italic
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{longtable} % also needed by longtabu
\usepackage{tabu}
\usepackage{multirow}
\begin{document}
\hspace{-0.6cm}
\begin{longtabu}{ | l | l | X |}
\firsthline
\multicolumn{3}{|c|}{
\begin{tabularx}{\linewidth}{ l | l | l | X | l | l }
\textbf{Id} & 20 & \textbf{Name}: &Settings & \textbf{Data Size}: & 26 bytes\\
\end{tabularx}}\\
\hline
\multicolumn{3}{|l|}{
\begin{minipage}[t]{0.97\textwidth}
\textbf{Description}: This packet is being sent ..ehehe
\vspace{1mm}
\end{minipage}
} \\
\hline
\multicolumn{3}{|c|}{ \textbf{Fields:} } \\
\firsthline
\textbf{Bits} & \textbf{Field Name} & \textbf{Description}\\
\hline
0 : 2 & SETTING\_A &
\begin{minipage}[t]{0.47\textwidth}
\textbf{Values}:\\0 - MODE\_A \\ \textit{Comment A.}\\1 - MODE\_B\\\textit{Comment B . dsdsjkhdsakjahsasd}\\2 - MODE\_C\\\textit{Comment C. asdsadasfsddssd}\\3 - MODE\_D\\\textit{Comment D. fdassdaskjdhasd}\\4 - MODE\_E\\\textit{Comment E. fdjksfdsjhgffhjjjhsfd}\\5 - MODE\_F\\\textit{Comment F}\\6 - MODE\_G\\\textit{Comment E}\\\vspace{-0.27cm}
\end{minipage}
\tabularnewline \hline
3 : 7 & SETTING\_B &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
8 : 10 & SETTING\_C &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
11 : 13 & SETTING\_D &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
14 : 16 & SETTING\_E &
\begin{minipage}[t]{0.47\textwidth}
\textbf{Values}:\\0 - PH\_A\\\textit{Aomment A}\\1 - PH\_B\\\textit{Comment B}\\2 - PH\_C\\\textit{Comment C dsasdjka hsdkjah dsakjsadh kjdash ksaj}\\3 - PH\_D\\\textit{Comment D fdsfdsfdsf sdsdfds}\\4 - PH\_E\\\textit{Comment E asdkhdaskjdshjsakhasdkjds}\\5 - PH\_F\\\textit{Comment F. dsajashsaddsasfdfsddsf}\\\vspace{-0.27cm}
\end{minipage}
\tabularnewline \hline
17 : 29 & SETTING\_F &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
30 : 42 & SETTING\_G &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
43 : 48 & SETTING\_H &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
49 : 54 & SETTING\_I &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
55 : 61 & SETTING\_J &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
62 : 77 & SETTING\_K &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
78 : 93 & SETTING\_L &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
94 : 109 & SETTING\_M &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\\\hline
110 : 125 & SETTING\_N &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
126 : 141 & SETTING\_L &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
142 : 150 & PULSE\_WIDTH &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
151 : 159 & PULSE\_WIDTH\_HIGH &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
160 : 175 & DELAY &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
176 : 188 & TOTAL\_PROGRAM\_TIME &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}
\tabularnewline \hline
189 : 201 & TOTAL\_PHASE\_TIME &
\begin{minipage}[t]{0.47\textwidth}
\end{minipage}\\
\tabularnewline
\lasthline
\end{longtabu}
\end{document}