4

The \saythanks command chokes when \thanks has been called with a macro that takes (and executes!) another macro as argument:

\documentclass[twocolumn,a5paper]{paper}
\usepackage{abstract}

\newcommand\thanksdefiner[1]{}
\newcommand\firstauthorthanks{\thanksdefiner{my thanks}}
\newcommand\extractthanks[1]{%
    \renewcommand\thanksdefiner[1]{##1}%
    #1
}

\title{Title}
\author{First Author \\Institution \thanks{\extractthanks\firstauthorthanks}}

\begin{document}
    \twocolumn[
        \maketitle
        % need full-width title
        \begin{onecolabstract}
            abstract text...
        \end{onecolabstract}
    ]
    \saythanks

    % works here:
    \extractthanks\firstauthorthanks
\end{document}

The sequence \extractthanks\firstauthorthanks expands to my thanks, and works when used within the document. Is there any way to call \thanks in this setting with a correct result? The definition of "thanks" for the first author

\newcommand\firstauthorthanks{\thanksdefiner{my thanks}}

is provided externally and should not be changed.

I have tried using \DeclareExpandableDocumentCommand to declare \extractthanks, without success. What kind of treatment would \firstauthorthanks require so that it can be passed safely as argument to \thanks?

  • The argument to \thanks is massaged with \protected@xdef and so the \renewcommand fails miserably. It's quite difficult to understand what you're trying to obtain. – egreg Oct 9 '13 at 20:15
  • @egreg: Right, if I define \thanksdefiner externally and do not change it in \extractthanks, it works. For my application, \thanksdefiner takes 7 arguments, which later have to be extracted from \{first,second,third,...}authorthanks macros. The \newcommand\firstauthorthanks{\thanksdefiner{...}} is a predefined idiom which I don't want to change. – krlmlr Oct 9 '13 at 20:28
  • After the explanation, I'm understanding less. – egreg Oct 9 '13 at 20:31
  • @egreg: \firstauthorthanks is supplied by the user in the \thanksdefiner syntax. Definition of \author is packaged and must read "thanks" information from \firstauthorthanks. That's the situation. I can't answer the "why?" question that I feel coming, because I inherited this setup. Also, I'm willing to keep things that way, because there's a fairly large user base with quite a lot of existing documents that rely on this syntax. – krlmlr Oct 9 '13 at 20:37
  • @egreg: To put it in another way: In the example above, only the line \newcommand\firstauthorthanks{\thanksdefiner{my thanks}} is supplied by the user. Everything else I can change. – krlmlr Oct 9 '13 at 20:39
1

Avoiding the use of \renewcommand inside \extractthanks solves the issue, at least for me:

\newcommand\thanksdefiner[1]{#1}%
\newcommand\firstauthorthanks{\thanksdefiner{my thanks}}
\newcommand\extractthanks[1]{%
    #1
}

Also, adding the necessary amount of \protection solves the issue, too (don't need to change first part in this case):

\author{First Author \\Institution
       \thanks{\protect\extractthanks{\protect\firstauthorthanks}}}

I still don't know enough about \protected@xdef to be able to explain any of this. It's just observed behavior...

  • As I said, the argument to \thanks is massaged by \protected@xdef; since \renewcommand makes assignments it fails there, but defining \thanksdefiner essentially as a no-op in advance doesn't suffer from this problem. It remains a mystery why \thanksdefiner should appear in the first place. – egreg Oct 9 '13 at 20:48

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.