The following code from Automatically remove ruler when no header is present compiles fine in Tex Live 2016:
\documentclass{article}
\usepackage{fancyhdr}
\makeatletter
\let\org@fancyhead\@fancyhead
\renewcommand*{\@fancyhead}[5]{\sbox0{#2#3#4}\ifdim\wd0=\z@ \let\headrule\relax \fi \org@fancyhead{#1}{#2}{#3}{#4}{#5}} % remove ruler if header is empty
\makeatother
\begin{document}
Foo
\end{document}
But in Tex Live 2017, it gives the error LaTeX Error: \@fancyhead undefined. Why? And how can I fix this?
\@fancyheadmacro has been renamed\f@nch@head(and a lot of other similar macros have also been renamed.) – Alan Munn Jun 20 '17 at 18:57