Assuming \author{FirstName LastName}, how do I obtain only the last name from \@author? My objective is to use it as in \lhead{\@author[1]}, without having to write the last name manually.


Taking the main code from this nice answer,

% Function to extract the last word of a sentence
\newcommand*\TheLastWord[1]{\expandafter\xreverseit\expandafter{\expandafter}#1 \relax}
\def\xreverseit#1#2 #3{%
  \xreverseit{#1 #2}#3% 
\newcommand\thevariable{The example sentence} % Store the sentence in a variable
\author{Filippo Bistaffa}

enter image description here

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.