下表包含一个包含 > 1 行的文件。当行数 = 10000 时,输出中将显示以下消息并导致编译失败。有什么办法可以避免插入 }?
! Missing } inserted.
<inserted text>
}
l.10001 0
6-Jun-2014 & Chq - \#9113 & 60.60 & & 3,564,175.18 \\
! Argument of \LT@max@sel has an extra }.
<inserted text>
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{float}
\usepackage{lipsum}
\usepackage{import}
\usepackage{longtable}
\usepackage{tabu}
\usepackage[table]{xcolor} % loads also »colortbl«
\usepackage{pgf}
\usepackage[top=0.4in, bottom=0.5in, left=0.1in, right=0.1in, tmargin = 0.9in] {geometry}
\usepackage{lastpage}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
% define lightgray
\definecolor{lightgray}{gray}{0.9}
\definecolor{darkgray}{gray}{0.5}
\definecolor{darkgreen}{RGB}{0,63,55}
\let\oldlongtabu\longtabu
\let\endoldlongtabu\endlongtabu
\newenvironment{newlongtabu}{\rowcolors{2}{white}{white}
\oldlongtabu} {\endlongtabu}
\renewenvironment{longtabu}{
\rowcolors{2}{white}{lightgray}
\oldlongtabu} {\endoldlongtabu}
\begin{document}
\newdimen\mylength
\setlength{\mylength}{7.0in}
{\small \tabulinesep=1.2mm
\begin{longtabu}to\textwidth{Xp{10.0cm}rrr}
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & col5 \\
\rowcolor{white}\\
\endfirsthead
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & co5 \\
\rowcolor{white}\\
\endhead
\endfoot
\endlastfoot
\input blah_short.tex
\end{longtabu}
}
\end{document}
blah_short 包含:
blah & blah & blah & blah & blah \\
blah & blah & blah & blah & blah \\
blah & blah & blah & blah & blah \\
blah & blah & blah & blah & blah \\
blah & blah & blah & blah & blah \\
blah & blah & blah & blah & blah \\
常规的行数会超过 10000。
答案1
如果我将您的输入文件扩展到 11001 个相同的行,tabu 会出现内存不足错误
!TeX 容量超出,抱歉 [主内存大小=5000000]。而不是您显示的错误?
底层的 longtable 代码旨在处理基本上任意长度的表格(最长可达 pdftex 和 pdf 格式规定的文档长度)
就像是
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{float}
\usepackage{lipsum}
\usepackage{import}
\usepackage{longtable}
\usepackage[table]{xcolor} % loads also »colortbl«
\usepackage{pgf}
\usepackage[top=0.4in, bottom=0.5in, left=0.1in, right=0.1in, tmargin = 0.9in] {geometry}
\usepackage{lastpage}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
% define lightgray
\definecolor{lightgray}{gray}{0.9}
\definecolor{darkgray}{gray}{0.5}
\definecolor{darkgreen}{RGB}{0,63,55}
\begin{document}
\newdimen\mylength
\setlength{\mylength}{7.0in}
{\small
\begin{longtable}{p{5cm}p{10.0cm}rrr}
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & col5 \\
\rowcolor{white}\\
\endfirsthead
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & co5 \\
\rowcolor{white}\\
\endhead
\endfoot
\endlastfoot
\input blah_short.tex
\end{longtable}
}
\end{document}
答案2
如果需要,那么您可以通过在制作表格时longtabu
覆盖计数器来为大型数据集提供工作空间。LTChunkSize
\documentclass{article}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{framed}
\usepackage{float}
\usepackage{lipsum}
\usepackage{import}
\usepackage{longtable}
\usepackage{tabu}
\usepackage[table]{xcolor} % loads also »colortbl«
\usepackage{pgf}
\usepackage[top=0.4in, bottom=0.5in, left=0.1in, right=0.1in, tmargin = 0.9in] {geometry}
\usepackage{lastpage}
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}
% define lightgray
\definecolor{lightgray}{gray}{0.9}
\definecolor{darkgray}{gray}{0.5}
\definecolor{darkgreen}{RGB}{0,63,55}
\let\oldlongtabu\longtabu
\let\endoldlongtabu\endlongtabu
\newenvironment{newlongtabu}{\rowcolors{2}{white}{white}
\oldlongtabu} {\endlongtabu}
\renewenvironment{longtabu}{
\rowcolors{2}{white}{lightgray}
\oldlongtabu} {\endoldlongtabu}
\begin{document}
\newdimen\mylength
\setlength{\mylength}{7.0in}
{\small \tabulinesep=1.2mm
\begin{longtabu}to\textwidth{Xp{10.0cm}rrr}
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & col5 \\
\rowcolor{white}\\
\endfirsthead
\rowcolor{lightgray}
\textbf{col1} & \textbf{col2} & ~ & ~ & co5 \\
\rowcolor{white}\\
\endhead
\endfoot
\endlastfoot
\setcounter{LTchunksize}{250000}
\input blah_short.tex
\end{longtabu}
}
\end{document}
这 \setcounter{LTchunksize}{250000}
将允许您创建 250000 条记录的表。将其与 200000 行输入文件相结合,lualatex 编译时您还将看到 1.2 GB 的内存占用,持续几分钟。