6

I'm currently working on several projects, where the authors are read from a textfile. I'm also displaying the authors in the header using fancyhdr. This works great if there are just 2 or 3 contributors, but if there are more, the text starts overlapping.

screenshot

The overlapping is also dependent on the document title, which is shown the left.

Is there a way to detect whether the text overlaps, and if it does, use a fallback text (an URL) instead of the authors instead?

Header specification looks like this at the moment:

\usepackage{fancyhdr} % Fancy headers

% Capture title and author
\makeatletter                                                                                                                                         
\let\Title\@title
\let\Author\@author
\makeatother

% Fancy headers configuration
\pagestyle{fancy}
\fancyhead{} % Clear all header fields
\fancyhead[LO,LE]{\bfseries \Title}
\fancyhead[RO,RE]{\Author}
\fancyfoot{} % Clear all footer fields
\fancyfoot[CO,CE]{Page \thepage}
\renewcommand{\headrulewidth}{0.3pt}
\renewcommand{\footrulewidth}{0pt}
6

I'd say

\makeatletter
\let\Title\@title
\let\Author\@author
\normalfont\sbox0{\normalfont\Title\quad\Author}
\ifdim\wd0>\textwidth\def\Author{<whatever>}\fi

This will use <whatever> if there's not at least a quad of space between the title and the list of authors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.