我遇到了一个问题,如果我使用 csvsimple 提取的表太长,PDF 将无法构建。但只有当我的 fancyhdr 标头中包含任何类型的表时,这才会成为问题。如果您从 parts_list_test.csv 中取出 20 行左右,它就可以正确构建。以下是相关代码。
\documentclass{article}
\usepackage{fancyhdr} % Header and Footer package
\usepackage[includeheadfoot,margin=2cm,headheight=70pt]{geometry} % Necessary for footer to stay on page
\geometry{letterpaper, portrait}
\usepackage{array} % Required for table typesetting
\usepackage{csvsimple} % Necessary for importing .csv files
\usepackage{longtable} % Required for tables spanning multiple pages
\usepackage{datatool} % Imports .xls files for use in Latex
\DTLloaddbtex{\PL}{./Resources/parameters.dbtex} % *NOTE* USE CORRECT .dbtex LOCATION, also \PL callout is arbitrary, just ensure it is nominal throughout the document
\usepackage{lastpage} % Required to show X of X pages in footer
\setlength{\headheight}{70pt} % NOTE distance here must match distance set above
\begin{document}
\DTLassign{\PL}{1}{\article=var}
\DTLassign{\PL}{2}{\rev=var}
\DTLassign{\PL}{3}{\docno=var}
\DTLassign{\PL}{4}{\docdate=var}
\DTLassign{\PL}{5}{\stcholder=var}
\DTLassign{\PL}{6}{\makemodel=var}
\DTLassign{\PL}{7}{\stcno=var}
\DTLassign{\PL}{8}{\projno=var}
\DTLassign{\PL}{9}{\preby=var}
\DTLassign{\PL}{10}{\insa=var}
\DTLassign{\PL}{11}{\insb=var}
\DTLassign{\PL}{12}{\insc=var}
\DTLassign{\PL}{13}{\insd=var}
\DTLassign{\PL}{14}{\inse=var}
\DTLassign{\PL}{15}{\insf=var}
\DTLassign{\PL}{16}{\insg=var}
\DTLassign{\PL}{17}{\insh=var}
\DTLassign{\PL}{18}{\insi=var}
\DTLassign{\PL}{19}{\insj=var}
\DTLassign{\PL}{20}{\insk=var}
\DTLassign{\PL}{21}{\insl=var}
\DTLassign{\PL}{22}{\insm=var}
\DTLassign{\PL}{23}{\insn=var}
\DTLassign{\PL}{24}{\inso=var}
\DTLassign{\PL}{25}{\insp=var}
\DTLassign{\PL}{26}{\insq=var}
\DTLassign{\PL}{27}{\insr=var}
\DTLassign{\PL}{28}{\inss=var}
\DTLassign{\PL}{29}{\inst=var}
%----------------------------------------------------------------------------------------
% Header & Footer
%----------------------------------------------------------------------------------------
\pagestyle{fancy}
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt} % Removes lines under header
\renewcommand{\footrulewidth}{0pt} % Removes lines above footer
\chead{
{\Large\bfseries\stcholder \\}
{\large\bfseries\makemodel \\}
{\large\bfseries SPECIAL HARDWARE PARTS LIST AND INSTRUCTIONS \\}
{\begin{center}
\csvreader[tabular=|c|c|c|c|,
table head=\hline\bfseries REVISION & \bfseries DRAWING NUMBER & \bfseries PREPARED BY &
\bfseries DATE
\\\hline, late after line=\\\hline,]
{header_rev_log_test.csv}{}
{\csvlinetotablerow}
\end{center}
\vspace{-10mm} % Brings Parts List table closer to header
}
}
\cfoot{
{\large\bfseries\docno \\}
{\bfseries SPECIAL HARDWARE PARTS LIST AND INSTRUCTIONS \\}
{\bfseries\docdate \ REV \rev \\}
Page \thepage \hspace{0pt} of \pageref{LastPage}
}
%----------------------------------------------------------------------------------------
% Parts List
%----------------------------------------------------------------------------------------
\begin{center}
{\bfseries\large PARTS LIST}
\csvreader[longtable=
|>{\centering\arraybackslash}m{11mm} % ITEM
|>{\centering\arraybackslash}m{25mm} % PART NUMBER
|>{\centering\arraybackslash}m{25mm} % EQ. PART NUMBER(S)
|>{\raggedright\arraybackslash}m{54mm} % DESCRIPTION
|>{\centering\arraybackslash}m{12mm} % NOTE
|>{\centering\arraybackslash}m{22mm}|, % UNITS PER ASSY
table head=\hline
\bfseries ITEM &
\bfseries PART NUMBER &
\bfseries EQ. PART NUMBER(S) &
\bfseries DESCRIPTION &
\bfseries NOTE &
\bfseries UNITS PER ASSY
\\\hline\endhead,
late after line=\\\hline,]
{parts_list_test.csv}{}
{\csvlinetotablerow}
\end{center}
\pagebreak
\end{document}
这是错误日志
]
! Extra }, or forgotten $.
<recently read> \egroup
l.106 {\csvlinetotablerow}
I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.
! LaTeX Error: \begin{longtable} on input line 106 ended by \end{tabular}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.106 {\csvlinetotablerow}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
! Missing $ inserted.
<inserted text>
$
l.106 {\csvlinetotablerow}
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! LaTeX Error: \begin{longtable} on input line 106 ended by \end{center}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.107 \end{center}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
[2] [3]
AED: lastpage setting LastPage
[4]
! LaTeX Error: \begin{center} on input line 86 ended by \end{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.162 \end{document}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
有任何想法吗?
编辑:这是 .csv 文件的链接https://github.com/megacorvega/latex