# Fancyhdr and Tikz, runaway argument?

I am trying to draw some of the headers for a document with TikZ inside a fancy custom header, using the following code:

\documentclass[letter,11pt]{article}
\usepackage{tikz}
\usepackage{fancyhdr}
\usepackage{lastpage}

\fancypagestyle{aero450}
{
\fancyhf{}
\renewcommand{\footrulewidth}{0pt}

\begin{tikzpicture}[remember picture]

\draw (current bounding box.center) node (__head_c)
[font=\scriptsize]

\end{tikzpicture}

}
}

\pagestyle{aero450}

\begin{document}
TEST TEST TEST
\end{document}


However, either with xelatex, pdflatex or writelatex.com, I get the following error:

Runaway argument?
{ \begin {tikzpicture}[remember picture]
Paragraph ended before \f@ncyhf was complete. <to be read again>
\par l.23 \pagestyle{aero450}


What am I doing wrong? writelatex.com says that I might have forgotten a }, but I am pretty sure that I haven't...

• @Werner, have you taken a look at the writelatex example? What did you use for compiling it? – Ricardo Jan 13 '14 at 6:28
• Your writelatex example doesn't match the code above. Especially it has blank lines inside the tikzpicture environment, which is causing the problem. – Werner Jan 13 '14 at 6:32
• You are right @Werner, I deleted one blank line after \begin{tikzpicture}, the one that was causing the problem. Thanks. – Ricardo Jan 13 '14 at 6:34
• @Werner, so I can remake my question: I cannot add blank lines to the contents of a \chead{}-like command from the fancyhdr package? – Ricardo Jan 13 '14 at 17:56

Solution: Remove the blank lines, or use % as a line separator if you wish to air out your code.
• there's an [unouter](mirror.ctan.org/macros/plain/contrib/misc/unouter.tex which removes \outer flags from commands. a similar (possibly even less hair-raising) technique might well work for adding \long – wasteofspace Jan 14 '14 at 11:54