1

I am trying to implement my own version of \affiliation and \author to use in my posters. I would like to have options to show indices of affiliations in the form of \arabic, \alph and \fnsymbol. Arabic and alph outputs both work correctly, but not \fnsymbol.

MWE:

\documentclass[]{article}
\usepackage{etoolbox}
\begin{document}
\newcounter{x}
\csxdef{tmp}{}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\alph{x},}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\alph{x}}
Authorname$^{\csuse{tmp}}$ %
\setcounter{x}{0}
\csxdef{tmp}{}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\arabic{x},}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\arabic{x}}
Authorname$^{\csuse{tmp}}$ %
\setcounter{x}{0}
\csxdef{tmp}{}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\fnsymbol{x},}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\fnsymbol{x}}
Authorname$^{\csuse{tmp}}$ %
\setcounter{x}{0}
\csxdef{tmp}{}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\alph{x},}
\stepcounter{x}
\csxdef{tmp}{\csuse{tmp}\alph{x}}
Authorname$^{\csuse{tmp}}$ %
\end{document}

The output:

Output

And error messages:

 Missing } inserted. ...csuse{tmp} $\to$ Authorname$^{\csuse{tmp}

I understand, that \fnsymbol produces math-mode output, and my code is missing proper switching between text and math modes, but I cannot find where this happens.

  • In general, I find simple solution: instead of putting indices into superscript in formula - just use \raisebox{...}{\scriptsize{...}}. But I still wonder if there is a proper solution – Intercombats Sep 21 '15 at 14:44
  • I can't say exactly where the problem lies (that's why I am posting this as a comment and not as answer), but using \textsuperscript{...} instead of $^{...}$ seems to be fine. – campa Sep 21 '15 at 15:15
  • @campa Thanks! At first, this makes the code cleaner. However, I was not happy that the letters are roman, not italic, but I checked how \textsuperscript is implemented and made proper correction for my purpose. – Intercombats Sep 21 '15 at 15:55
  • Why do you use \csuse etc. here? I can't say whether they cause the problem, but it looks strange on first glance – user31729 Sep 21 '15 at 18:43
  • @ChristianHupfer here I showed simple version which fully reproduces the behavior of all my code including error. My main function is the following: \newcommand{\printauthor}[1]{ \csuse{author#1}$^{\csuse{authfa#1}}$% } , where auth#N stores name of the author, and authfa#N - symbols, corresponding to affiliations (numbers, letters or fnsymbols). – Intercombats Sep 21 '15 at 19:04
1

Thanks to all, my messy final code is ready. My first experience in writing packages & using etoolbox.

% avauthors.sty
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{avauthors}[2015/09/20 Authors and Affiliations]
\RequirePackage{etoolbox}
\RequirePackage{xstring}
\RequirePackage{tikz}
\newcommand{\avindex}[1]{\arabic{#1}}
\newif\if@alph\@alphfalse
\DeclareOption{alph}{\@alphtrue%
    \renewcommand{\avindex}[1]{\alph{#1}}%
}
\DeclareOption{fn}{\renewcommand{\avindex}[1]{\fnsymbol{#1}}}
\DeclareOption{roman}{\renewcommand{\avindex}[1]{\roman{#1}}}
\DeclareRobustCommand*\superscript[1]{%
  \@superscript{\selectfont#1}%
}
\def\@superscript#1{%
   \if@alph
      {\m@th\ensuremath{^{\textit{\mbox{\fontsize\sf@size\z@#1}}}}}%italic for letters
   \else
      {\m@th\ensuremath{^{\mbox{\fontsize\sf@size\z@#1}}}}%
   \fi
}
\ProcessOptions\relax
\newcounter{avnumauthor}
\newcounter{avnumaffil}
\newcounter{avnumauthaffil}
\newcounter{avnumaffils}
\newcounter{avaffilindex}
\newcounter{avcounta}
\newcounter{avcntb}
\newcounter{avcntc}
\renewcommand{\author}[1]{
    \stepcounter{avnumauthor}
    \setcounter{avnumaffil}{0}
    \listadd{\authors}{#1}
    \csdef{author\theavnumauthor}{#1}
}
\newcommand{\affiliation}[1]{
    \stepcounter{avnumaffils}
    \stepcounter{avnumaffil}
    \stepcounter{avaffilindex}
    \stepcounter{avnumauthaffil}
    \foreach \i in {1,...,\theavaffilindex}{
        \setcounter{avcounta}{\i}
            \IfStrEq
                {\csuse{affil\theavcounta}}
                {#1}
                {\setcounter{avaffilindex}{\theavcounta}
                    \addtocounter{avnumaffils}{-1}
                }{}
    }
    \csxdef{affil\theavaffilindex}{#1}
    \csxdef{affindex\theavnumauthaffil}{\theavaffilindex}
    \csxdef{auth\theavnumauthor}{\theavnumaffil}
    \setcounter{avaffilindex}{\theavnumaffils}
}
\newcommand{\processall}{
    \setcounter{avcounta}{0}
    \foreach \i in {1,...,\theavnumauthor}{
        \stepcounter{avcntb}
        \csxdef{tmpb}{}%
        \foreach \j in {1,...,\csuse{auth\theavcntb}}{%
            \stepcounter{avcounta}%
            \setcounter{avcntc}{\csuse{affindex\theavcounta}}
            \csxdef{tmpb}{\csuse{tmpb}\avindex{avcntc}}
            \ifnum \j < \csuse{auth\theavcntb}
                \csxdef{tmpb}{\csuse{tmpb},}
            \fi
        }%
        \csxdef{authfa\theavcntb}{\csuse{tmpb}}
    }
}
\newcommand{\printauthor}[1]{
    \csuse{author#1}\superscript{\csuse{authfa#1}}%
}
\newcommand{\printaffil}[1]{
    \setcounter{avcntb}{#1}%
    \superscript{\avindex{avcntb}}\csuse{affil#1}
}
\endinput

WE:

\documentclass[]{article}
\usepackage[fn]{avauthors} % no option: arabic; options: roman, alph and fn
\begin{document}
\author{Author A}
\affiliation{Physics Dept.}
\author{Author B}
\affiliation{Physics Dept.}
\affiliation{Chemistry Dept.}
\author{Author C}
\affiliation{Chemistry Dept.}
\affiliation{Biology Dept.}
\author{Author D}
\affiliation{Physics Dept.}
\affiliation{Geology Dept.}
\processall{}

\printauthor{1} 
\printauthor{2} 
\printauthor{3} 
\printauthor{4}

\printaffil{1} 
\printaffil{2} 
\printaffil{3} 
\printaffil{4} 
\end{document}

Output: Output

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.