下表包含一個包含 > 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 相同的行禁忌會給出記憶體不足錯誤
! 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 記憶體佔用幾分鐘。