2
\documentclass{article}

\def\ad#1{$^{#1}$}
\def\aff#1{$^{#1}$}
\def\address#1{#1}
\def\dept#1{#1}
\def\inst#1{#1}
\def\cyname#1{#1}
\def\country#1{#1}
\def\pcode#1{#1}
\def\stname#1{#1}
\def\phone#1{#1}
\def\fax#1{#1}
\def\ad#1{$^{\rm #1}$}
\def\aff#1{$^{#1}$}
\def\fn#1{#1}
\def\sn#1{#1}
\def\corr#1{#1}
\def\statename#1{#1}


\begin{document}

\title{Sample}

\author{Sas Santhome\ad{a} Author\ad{b} and Susanna Waxxarin\ad{c} }

\maketitle

\address{\aff{a}\dept{Department of Sciences}, \inst{University}, \cyname{City}, \country{Italy}; \aff{b}\dept{Department of Economics}, \inst{University}, \cyname{Trieste}, \country{Italy}}

\end{document}

what i want to acheive is in \author i have \ad{} 'n' number of times,

the link text \ad{a} should also be there in \aff{a} or else, i need to show compile error,

for example in the above coding, we can see

\ad{a} - \aff{a}
\ad{b} - \aff{b}
\ad{c} - Missing \aff{c}

\aff{c} is missing but \ad{c} is present, so i should throw compile error

Please guide

1

For example you can save the \ad labels into the \afflist macro and you can use these labels from \afflist when \aff is used. This means that you needn't to repeat the labels again and the \aff macro is used without parameter.

\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\def\ad#1{$^{\rm #1}$\global\addto\afflist{{#1}}}
\def\aff{%
   \ifx\afflist\empty \errmessage{There is more \noexpand\aff than \string\ad}%
   \else \expandafter\affA\afflist\end $^{\rm\tmp}$%
   \fi
}
\def\affA#1#2\end{\gdef\afflist{#2}\def\tmp{#1}}
\def\address#1{#1%
  \ifx\afflist\empty\else \errmessage{There is more \noexpand\ad than \string\aff}\fi
}
\def\afflist{}    

\def\dept#1{#1}   
\def\inst#1{#1}   
\def\cyname#1{#1} 
\def\country#1{#1}
\def\pcode#1{#1} 
\def\stname#1{#1}
\def\phone#1{#1}
\def\fax#1{#1} 
\def\fn#1{#1}  
\def\sn#1{#1}  
\def\corr#1{#1}
\def\statename#1{#1}

...

\address{\aff\dept{Department of Sciences}, \inst{University}, \cyname{City}, \country{Italy}; 
         \aff\dept{Department of Economics}, \inst{University}, \cyname{Trieste}, \country{Italy}; 
         \aff\dept{Somewhere}}

If you need to repeat the labels in the \aff macro again then you can check if the label is the same:

\def\aff#1{\def\tmpa{#1}%
   \ifx\afflist\empty \errmessage{There is more \noexpand\aff than \string\ad}%
   \else \expandafter\affA\afflist\end $^{\rm\tmp}$%
         \ifx\tmp\tmpa \else \errmessage{unmatched labels \tmpa--\tmp}\fi
   \fi
}

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.