I'm using fancyhdr, and following this answer I have redefined \sectionmark as:


so that


gives the name of the current section in the header on the right for odd pages and left for even pages. This may sound strange, but I would additionally like the short name of the section to go on the other side of the header. So, for example, if I've declared

\section[short name]{long name}

then my pages would have headers with "short name" on one side and "long name" on the other. Can this be done? I assume that I would need to use \fancyhead[RE,LO]{\rightmark} having engineered things so that \rightmark produced the short name of the section. But I haven't had success with that. Also by providing a short name for \section[]{}, the short name is used in \leftmark instead.

(Why am I doing this? Each of these sections has a new name under a new naming convention, and an old name under an old naming convention. I am trying to cheat and use \section[]{} to declare both the new and old name, and have both appear in the header. There will be no table of contents in this document and I foresee no other use of short names.)

  • 1
    If there is no toc, why not simply use \section[shortname longname]{longname}?
    – Johannes_B
    Commented Sep 26, 2014 at 7:16
  • You can't use the optional argument like this. Also rightmark outputs the first mark, while leftmark the last mark so if there are two sections you would get confusing output if you use both. Better code the two names like this \section{\oldandnew{old name}{new name}}. You can then locally redefine the command \oldandnew so that it outputs either the one or the other argument. Commented Sep 26, 2014 at 8:17

1 Answer 1


It's ugly, but it works.



\newcommand{\myhead}[2]% #1 = short name, #2 = long name
\settodepth{\headeroffset}{{#1}{#2}}% distance from baseline to bottom

\begingroup% preserve global \headeroffset
\advance \headeroffset by -\topmargin% to top of header
\advance \headeroffset by -\headheight% to botom of header
  \hspace{-\textwidth}\hspace{-\oddsidemargin}}% return cursor to left
  \hspace{-\textwidth}\hspace{-\evensidemargin}}% return cursor to left

\myhead{Short name}{This is a long name}

You must log in to answer this question.

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