1

I am having a tinker in the internals of REVTeX (and more specifically its component ltxfront package), with the goal of writing a package to handle author ORCID iDs, and I would like to understand how the data structures in use work, so I can replicate them.

I am particularly mystified by the variable (?) \@author, which seems to be where most of the action is. From what I can tell, the key places where the package code interacts with this data structure are:

  • The \@author@init function

    \def\@author@init{%
      \let\@author\@author@cleared
      \@booleanfalse\collaboration@sw
     }%
    
  • ... which seems to reset it using \@author@cleared,

    \def\@author@cleared{{}{}{}}%
    
  • The \@author@def command, which seems to initialize \@author to the author name and a blank trailer:

    \def\@author@def#1#2{%
     \frontmatterverbose@sw{\typeout{\string\author\space\string\collaboration}}{}%
     \move@AU\move@AF\move@AUAF
     \let\@AF@join\@author@join
     #1%
     \def\@author{{#2}{}}%
    }%
    
  • The \@author@join function, which seems to append data to it:

    \def\@author@join@#1#2#3{%
      \def\@author{{#1}{\@join{\@separator}{#2}{#3}}}%
    }%
    \def\@author@join{\expandafter\@author@join@\@author}%
    

    and which then gets called during e.g. the \email handling:

    \newcommand*\email[1][]{\begingroup\sanitize@url\@email{#1}}%
    \def\@email#1#2{%
     \endgroup
     \@AF@join{#1\href{mailto:#2}{#2}}%
    }%
    
  • The specific output of the author seems to be written by the \doauthor function

    \def\doauthor#1#2#3{%
      \ignorespaces#1\unskip\@listcomma
      \begingroup
       #3%
      \@if@empty{#2}{\endgroup{}{}}{\endgroup{\comma@space}{}\frontmatter@footnote{#2}}%
      \space \@listand
    }%
    
  • which is then called within \@author@present@script for the superscript-addresses variant

    \def\@author@present@script#1#2#3{%
     \begingroup
      \gdef\comma@space{\textsuperscript{,\,}}%
      \doauthor{#2}{#3}{\@affil@present@script}%
     \endgroup
     \advance\@tempcnta\m@ne
    }%
    

    and by \@author@present@group for the group-addresses variant

    \def\@author@present@group#1#2#3{%
      \gdef\comma@space{\gdef\comma@space{\textsuperscript{,\,}}}%
      \doauthor{#2}{#3}{\@affil@present@group}%
      \advance\@tempcnta\m@ne
    }%
    
  • Both of these seem to be aliases for \@author@present and from there for \AU@opr:

    \def\frontmatter@author@produce@script{%
      \begingroup
        \let\@author@present\@author@present@script
        %[...]
        \def\AU@opr{\@author@count\@tempcnta}%
        %[...]
        \begingroup
         %[...]
         \let\AU@opr \@author@present
         %[...]
         \@AAC@list %%% maybe this is the key operative part?
         %[...]
        \endgroup
        %[...]
      \endgroup
    }%
    

Anyways, this brings me to my questions:

  • What is \@author? Is it a variable? Is it a command? Is it a macro? Does it evaluate to a single token? Is it a series of tokens?

    After more thought, I understand that it is "just" a macro, but I find it to be a very slippery one -- its value seems to be reset for each author, and I am having trouble finding places where it retains its value.

  • What is the intended structure for the value of \@author? There is at least some mild conflict in the number of {}-delimited elements: \@author@init seems to use \@author@cleared to set it to {}{}{}, but \@author@def uses \def\@author{{#2}{}} with only two elements. I imagine the latter is the correct version, with the first {} holding the author name, and the second one holding the email/thanks/etc to be put as a footnote?

  • How is the value of \@author accessed? How can it be printed out to the log file for debugging purposes? How can its value be accessed to print it out onto the document?

  • How is the value of \@author edited? I imagine this has a lot to do with the \expandafter in \@author@join but the details are still not very clear.

  • What are the input parameters of \@author@present? The definition \@author@present@script#1#2#3 just indicates that there are three arguments without specifying what those are, and I'm having some trouble understanding how the package pulls the value of \@author into this call. If I try to trace it upstream to where it is called during the output production, it just gets lost in a sea of different versions of \AU@opr, which seems to play multiple different roles depending on where it appears.

Thanks for bearing with me! I am attempting to replicate a parallel data structure to handle ORCID iDs, so any clarity would be extremely welcome.


Edit: I have tried to contact the maintainers of REVTeX; it seems there isn't any developer specifically assigned to it but I got an informative reply from the APS CIO. It seems that REVTeX might be posted on GitHub at some point in the mid-term future, at which point it could be possible to submit pull requests that add this functionality.

In the meantime, I have put together a prototype of the functionality as I envision it (available on GitHub as the ORCIDinREVTeX package). This code could be suitable for further distribution (?), but I don't think it is a good solution, as it appends a rendered iD icon into the author text (i.e. at the end of the first element of \@author). It is clear to me that a sustainable long-term solution would involve either a separate data structure or an additional element in \@author which carries only the numeric iD, with the actual rendering postponed until \doauthor.

As such, I would like to keep this question open -- I would like to understand the details of how the existing data structure works, with the goal of helping to write an expanded version in the future.

8
  • 1
    Bottom line is that (almost) all the things which you would call variables/commands are in fact macros. Basically \author is a macro taking one parameter, and it assigns this parameter as definition of a further macro \@author. The macro \maketitle will use the content of \@author to typeset the title page. The whole rest are further macros to handle multiple authors and affiliations. – campa Dec 7 '20 at 12:23
  • @campa Sure. The thing that confuses me overall is that the \@author macro seems to take on new values for each author, and its value seems to be lost after it's reset, so I'd like to know how and where its nontrivial values can be accessed. – E.P. Dec 7 '20 at 12:56
  • 1
    The expansion of \author@def involves \move@AU\move@AF\move@AUAF. I don't have time right now to disentangle everything but yes, \author is setting \@author every time new, but before it does that it does other things with the values of \@author which have been collected until that point. – campa Dec 7 '20 at 13:52
  • if you want to write something that should be used with revtex, you should better contact the maintainer of the package and ask if and how at best the data structure could be extended. If you want to write something unrelated to revtex, then I wouldn't start with their commands which are quite specific. – Ulrike Fischer Dec 7 '20 at 14:23
  • @UlrikeFischer Thanks for the prompt -- I've written to Arthur Ogawa. I've managed to hack together a prototype that sidesteps this data structure (available here), but those hacks could probably use significant improvement. – E.P. Dec 7 '20 at 19:17

Your Answer

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

Browse other questions tagged or ask your own question.