# Longtable breaks PDFtex output with table in fancyhdr header

I'm having an issue where if the table I pull using csvsimple is too long, the PDF won't build. BUT this is only an issue if my fancyhdr header has a table of any kind in it. If you take 20 or so lines out of the parts_list_test.csv it builds correctly. Here is the relevant code.

\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{\footrulewidth}{0pt} % Removes lines above footer

{\Large\bfseries\stcholder \\}
{\large\bfseries\makemodel \\}
{\large\bfseries SPECIAL HARDWARE PARTS LIST AND INSTRUCTIONS \\}
{\begin{center}
table head=\hline\bfseries REVISION & \bfseries DRAWING NUMBER & \bfseries PREPARED BY &
\bfseries DATE
\\\hline, late after line=\\\hline,]
{\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}
|>{\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
\bfseries ITEM &
\bfseries PART NUMBER &
\bfseries EQ. PART NUMBER(S) &
\bfseries DESCRIPTION &
\bfseries NOTE &
\bfseries UNITS PER ASSY
late after line=\\\hline,]
{parts_list_test.csv}{}
{\csvlinetotablerow}
\end{center}

\pagebreak

\end{document}


Here is the error log

]
! 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.


Any ideas?

EDIT: Here is the link to the .csv files https://github.com/megacorvega/latex

• Welcome to TeX.SX! Unfortunately, your issue is not reproducible without header_rev_log.csv and parts_list.csv. – leandriis Nov 5 '19 at 19:43
• @leandriis Ah of course, I just added dummy .csv files that reproduce the issue, and updated the code to reflect the file name changes. – Tom Nov 5 '19 at 19:57
• The problem seems to be caused by the \csvreader call in the header. Replacing that with a standard tabular fixes the issue. I do not know what the reason is though... – wimi Nov 5 '19 at 21:58
• @wimi Yep, I was able to get it to build with just tabular for once as well. I must have screwed something up trying that before. I'm gonna call that the solution and just use DTLassign to get the variables in the table. Thanks for the help! – Tom Nov 5 '19 at 23:20