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




        \begin{tikzpicture}[remember picture]

            \draw (current bounding box.center) node (__head_c)





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?
    – nsx
    Commented Jan 13, 2014 at 6:28
  • 1
    Your writelatex example doesn't match the code above. Especially it has blank lines inside the tikzpicture environment, which is causing the problem.
    – Werner
    Commented Jan 13, 2014 at 6:32
  • You are right @Werner, I deleted one blank line after \begin{tikzpicture}, the one that was causing the problem. Thanks.
    – nsx
    Commented Jan 13, 2014 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?
    – nsx
    Commented Jan 13, 2014 at 17:56

1 Answer 1


The problem here is the blank lines inside your definition of \fancyhead. However, this translates to \fancyfoot. The reason here is that \fancyhead (\fancyfoot) - defined using \newcommand - calls an internal, universal macro \f@ncyhf - defined using \def - that stores the header/footer. The former \newcommand-created macros accept paragraph breaks (I'll call it \long-content), but the latter \def-created macro only accepts non-\long content. That is, you can't have paragraphs inside them, and since an empty line denotes a paragraph break, it flags an error.

Solution: Remove the blank lines, or use % as a line separator if you wish to air out your code.

As reference, see

  • Thanks for the explanation @Werner. It is quite a tough-to-resolve problem.
    – nsx
    Commented Jan 13, 2014 at 18:13
  • 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 Commented Jan 14, 2014 at 11:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .