3

Currently I am making a template file for our conference, in which we need to write author names in the header.

If the number of authors is two then list those authors in If the number of authors is more than two then this should produce, "first author et.al".

How to acheive this?

MWE:

    \documentclass[a4paper,10pt]{article}
    \usepackage{amsmath,amsfonts,amsthm,dsfont,amssymb,lipsum}
    \usepackage[blocks]{authblk}
    \newenvironment{keywords}{\noindent\textbf{Keywords:}}{}
    \newenvironment{classification}{\noindent\textbf{AMS subject classifications.}}{}

    \newcommand{\email}[1]{\texttt{\small #1}}



    \usepackage{fancyhdr}

    \pagestyle{fancy}
    \fancyhf{}
\fancyhead[C]{%
\ifodd\value{page}
  \small\nouppercase\authors
\else
  \small\nouppercase\shorttitle
\fi
}

    \begin{document}
    % % % % %--------------------------------------------------------------------
    % % % % %          Title of the Paper and Acknowledgement
    % % % % %--------------------------------------------------------------------
            \title{Your Title of the Paper
                \thanks{Acknowledgement: The authors thanks the support of so and so project/funding \dots}
                }
    % % % % %--------------------------------------------------------------------
    % % % % %         Authors,, Affiliations and email ids
    % % % % %--------------------------------------------------------------------

    \author[1]{Author A\footnote{Presenting  Author.}}
    \author[2]{Author B}
    \author[3]{Author C}  % Author having same Affiliation that of Author A
    \author[4]{Author D}
    \affil[1]{Affiliation of Author A. \email{abcd@gmail.com}}
    \affil[2] {Affiliation of Author B. \email{authorb@gmail.com}}
    \affil[3] {Affiliation of Author C. \email{authorc@gmail.com}}
    \affil[4]{Department of Statistics, Manipal University, Manipal, India. \email{authord@gmail.com}}
    % % % % %--------------------------------------------------------------------

    \date{(Received on  , Accepted on )} 

    \newcommand\shorttitle{The Running title of the article(give a short title)}
    \newcommand\authors{Authors on the Author A et.al.,}


\maketitle

    \begin{abstract}
    Your abstract goes here\dots The citation can be done using \verb|\cite{key}| and this will result the respective number in the reference list, Eg.\cite{einstein}.
    \end{abstract}

    \begin{keywords}
    ginverse, drazin inverse, diffrential equation
    \end{keywords}

    \begin{classification}
    13C10; 15A09; 15A24; 15B57
    \end{classification}

    \section{Introduction}

    Use \verb|\section{}| command to type your sections.  Here, goes your introduction or preliminaries...

    \section{Your section title\dots}

    \lipsum[1-20]

     \begin{thebibliography}{100}

     \bibitem{einstein} 
     Albert Einstein. 
     {\em Zur Elektrodynamik bewegter K{\"o}rper}. 
     Journal of Mathematics, 322(10):89--921, 1905.


      \bibitem{impj}  The Japan Reader {\em Imperial Japan 1800-1945} 1973:
      Random House, N.Y.

      \bibitem{norman} E. H. Norman {\em Japan's emergence as a modern
      state} 1940: International Secretariat, Institute of Pacific
      Relations.

      \bibitem{fo} Bob Tadashi Wakabayashi {\em Anti-Foreignism and Western
      Learning in Early-Modern Japan} 1986: Harvard University Press.

      \end{thebibliography}

    \end{document}
David
  • 1,964

1 Answers1

5

authblk stores the authors in two macros \AB@authlist and \AB@authors. The first has the structure:

\protect\@nameuse{@sep1} \protect\Authfont AUTHORNAME\protect\footnote {AFFILL}\protect\textsuperscript {,}
\protect\@nameuse{@sep2} \protect\Authfont AUTHORNAME\protect\footnote {AFFILL}\protect\textsuperscript {,}
…

The second one is much complexer. The package counts the number of authors in counter authors.

If counter authors is less than 3, we can simply use \AB@authlist to show the authors in the running head. But if it is greater or equal 3 we have to split of the first author. This can be done by a simple delimited argument:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath,amsfonts,amsthm,dsfont,amssymb,lipsum}
\usepackage[blocks]{authblk}
\newenvironment{keywords}{\noindent\textbf{Keywords:}}{}
\newenvironment{classification}{\noindent\textbf{AMS subject classifications.}}{}

\newcommand{\email}[1]{\texttt{\small #1}}

\makeatletter
\newcommand*{\authors}{%
  \begingroup
    \let\footnote\@gobble% ignore \footnote
    \let\textsuperscript\@gobble% ignore protected \textsuperscript
    \expandafter\let\csname textsuperscript \endcsname\@gobble
    \let\Authfont\relax% do not use a special font
    \def\Authand{, }% separate list of authors by ,
    \ifnum\value{authors}<3 % one ore two authors
      \AB@authlist% show them all
    \else% 3 or more authors
      % show only the first one followed by "et.~al"
      \expandafter\@firstof@authlist\AB@authlist\@nil\ et.~al%
    \fi
  \endgroup
}
\def\@firstof@authlist#1\footnote#2\@nil{#1}% skip all from the first footnote
\makeatother

\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{%
  \ifodd\value{page}
    \small\nouppercase\authors
  \else
    \small\nouppercase\shorttitle
  \fi
}

\begin{document}
% % % % %--------------------------------------------------------------------
% % % % %          Title of the Paper and Acknowledgement
% % % % %--------------------------------------------------------------------
        \title{Your Title of the Paper
            \thanks{Acknowledgement: The authors thanks the support of so and so project/funding \dots}
            }
% % % % %--------------------------------------------------------------------
% % % % %         Authors,, Affiliations and email ids
% % % % %--------------------------------------------------------------------

\author[1]{Author A\footnote{Presenting  Author.}}
\author[2]{Author B}
\author[3]{Author C}  % Author having same Affiliation that of Author A
\author[4]{Author D}
\affil[1]{Affiliation of Author A. \email{abcd@gmail.com}}
\affil[2] {Affiliation of Author B. \email{authorb@gmail.com}}
\affil[3] {Affiliation of Author C. \email{authorc@gmail.com}}
\affil[4]{Department of Statistics, Manipal University, Manipal, India. \email{authord@gmail.com}}
% % % % %--------------------------------------------------------------------

\date{(Received on  , Accepted on )} 

\newcommand\shorttitle{The Running title of the article(give a short title)}

\maketitle

\begin{abstract}
Your abstract goes here\dots The citation can be done using \verb|\cite{key}| and this will result the respective number in the reference list, Eg.\cite{einstein}.
\end{abstract}

\begin{keywords}
ginverse, drazin inverse, diffrential equation
\end{keywords}

\begin{classification}
13C10; 15A09; 15A24; 15B57
\end{classification}

\section{Introduction}

Use \verb|\section{}| command to type your sections.  Here, goes your introduction or preliminaries...

\section{Your section title\dots}

\lipsum[1-20]

 \begin{thebibliography}{100}

 \bibitem{einstein} 
 Albert Einstein. 
 {\em Zur Elektrodynamik bewegter K{\"o}rper}. 
 Journal of Mathematics, 322(10):89--921, 1905.


  \bibitem{impj}  The Japan Reader {\em Imperial Japan 1800-1945} 1973:
  Random House, N.Y.

  \bibitem{norman} E. H. Norman {\em Japan's emergence as a modern
  state} 1940: International Secretariat, Institute of Pacific
  Relations.

  \bibitem{fo} Bob Tadashi Wakabayashi {\em Anti-Foreignism and Western
  Learning in Early-Modern Japan} 1986: Harvard University Press.

  \end{thebibliography}

\end{document}

results in:

4 authors but only one shown

or if you remove

\author[3]{Author C}  % Author having same Affiliation that of Author A
\author[4]{Author D}

in

two authors shown

Schweinebacke
  • 26,336
  • Waw...your are genius..Thank you so much...I think in the case of only two authors we can add "and" inbetween – David May 27 '17 at 05:54
  • I have done that by replacing the "," with "and"...Thank you so much..@Schweinebacke – David May 27 '17 at 06:01
  • For those interested, this solution applies a similar technique with \AB@authors. – Keith Prussing Mar 24 '20 at 17:53
  • The example runs ok. But after adding the code to my template I get an error: ! Undefined control sequence. <recently read> \@firstof@authlist. – LEo Dec 01 '20 at 15:05
  • @LEo I don't know your template. So what could I tell you? In such cases, I also recommend to ask a new question with minimal working example, that shows the issue. – Schweinebacke Aug 23 '23 at 09:13