inaccessible when using nth in title expansion with fancyhdr and biblatex?

Short answer

Use

 \let\tmptitle\@title

Analysis

Your problem is

\edef\tmptitle{\@title}

as \nth is not expandable nor robust. One should not in most cases \edef 'general' text, but rather use \protected@edef

\protected@edef\tmptitle{\@title}

This will fix the issue though the text of \tmptitle isn't quite what one would expect:

> \tmptitle=macro:
->Oh, Latex 1\relax \protect \textsuperscript  {st}....

One could make \nth engine-robust

\usepackage{etoolbox}
\robustify\nth

as you can then use it safely in an \edef and will get

> \tmptitle=macro:
->Oh, Latex \nth {1}....

However, you really want to simply make a copy of \@title here, which can be done using \let

\let\tmptitle\@title

and which works with no other 'fiddling'.


Your problem is in \edef\tmptitle{\@title}.

You can solve it more generally by making LaTeX not forget \@title after having done \maketitle.

\documentclass[a4paper,12pt]{article}
\usepackage[super]{nth} % ordinals
\usepackage{fancyhdr}
\usepackage{etoolbox}

\makeatletter
\patchcmd{\maketitle}{\global\let\@title\@empty}{}{}{}
\patchcmd{\maketitle}{\global\let\@author\@empty}{}{}{}
\makeatother

\pagestyle{fancy}
\fancyhf{}% clear all fields
\makeatletter
\fancyhead[L]{\small\@title}
\makeatother
\setlength{\headheight}{13.6pt}

\begin{document}

\title{Oh, Latex \nth{1}...}
\author{Bob Whoever}
\maketitle

\clearpage
\mbox{} % let's produce a new page

\end{document}

An indirect strategy may be simpler:

\documentclass[a4paper,12pt]{article}
\usepackage[super]{nth} % ordinals
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}% clear all fields
\fancyhead[L]{\small\papertitle}
\setlength{\headheight}{13.6pt}

\newcommand{\papertitle}{Oh, Latex \nth{1}...}

\begin{document}

\title{\papertitle}
\author{Bob Whoever}
\maketitle

\clearpage
\mbox{} % let's produce a new page

\end{document}