# from string to command

What exactly happens in:

\newcommand{\mystring}[1]{\gdef\@mystring{#1}}

when \mystring{mystring} is used later in the document? It is known that mystring will be put in \mystring but I would like to know how in a Latex sense.

Edit: More information is given below. My programming skills in general and especially my Latex programming skills are decently low. I want to prepare a template for conference proceedings where specific information should be stored in appropriate strings that can be used later. Typically, authors' names could be stored in a variable that we will call \AuthorNames so that \AuthorNames (or more exaclty \@AuthorNames as indicated by Ulrike) can be indicated in the right footer of the paper for instance. Since I do not know much, I decided to mimic existing Latex classes (probably the article class). By travelling through the class examples, I figured out that:

\newcommand{\AuthorNames}[1]{\gdef\@AuthorNames{#1}}

was doing was I needed. I can know reformulate my question through a comparison with FORTRAN. What is the LaTeX version of:

CHARACTER :: AuthorNames

Or in other terms, is there a LaTeX guide somewhere saying: "if you want to declare a string of characters in LaTeX", use this: [blablabla]. I should probably read "texbytopic", that's all.

-
I really don't understand this question. Could you add a little more context? – Seamus Sep 7 '12 at 11:30
yes but the question behind is: why the command \@mystring contains the string mystring. Is this just the default functioning of such command? (in other words, is this the only way to assign a string of characters to a command in Latex) – pluton Sep 7 '12 at 12:17
"mystring" is not put in \mystring but in \@mystring. That's a different command. The purpose of \mystring is 1. to give a better interface. users can store a string with \mystring{string} instead of having to do \gdef\@mystring.... and 2. in this way you can store the value in a command with @ in its name which can't be changed easily by a user and so it is (a bit) protected. – Ulrike Fischer Sep 7 '12 at 13:57
@pluton your question even after the comment above is not at all clear. But perhaps Ulrike's comment answered it. If not I suggest you edit your question to be more explicit, and we can try again. – David Carlisle Sep 7 '12 at 16:32

TeX is a macro replacement language. That means that when we do

\def\foo{bar}

TeX simply stores bar as the replacement text for \foo. Thus when we use \foo, TeX replaces it exactly with bar, and carries on working. The content of a macro is not a string: it's a token list: thus we can do

\def\fooa{\foob}
\def\foob{bar}


The \gdef primitive works in the same way as \def except it applies globally (\def is local, obeying TeX's grouping system). Thus

\newcommand{\AuthorNames}[1]{\gdef\@AuthorNames{#1}}

works by defining \@AuthorNames as a macro to be replaced by whatever is given as the argument to \AuthorNames. As mentioned in the comments, this approach means that the user has a simple interface

\AuthorNames{whatever}

rather than needing to know \gdef and why it should be used here.

TeX also has another form of token storage: the token register or 'toks'. There are reasons for picking a toks over a macro for storage in some cases. However, most of the time you can happily use a macro: they are in many ways more convenient.

-
Maybe to make things clear, just a remark that @ is treated as a letter in some contexts, see tex.stackexchange.com/q/8351/11002 – yo' Sep 8 '12 at 9:02