The \noindent
control sequence is not a macro, but a primitive. It is not something that remains in effect for an entire paragraph. It instructs TeX to leave (internal) vertical mode and enter horizontal mode. (I sort of described TeX's vertical and horizontal modes in a blog post.)
More relevant to your question, there's no good way to distinguish which control sequences have arguments. The LaTeX 3 team has taken some pains to provide a consistent naming convention that lets the user know how many arguments and what type are expected. See the expl3
documentation for details.
To complicate matters, there are many LaTeX macros which, strictly speaking, do not take any arguments, but do in reality. For example, according to TeX, the \emph
macro takes no arguments. To see this, we can ask TeX to show the implementation of a macro using the \show
primitive:
*\show\emph
> \emph=macro:
->\protect \emph .
<*> \show\emph
This is a little tricky to read at first, but in the first line, I've asked TeX to show me the definition of \emph
(the *
is TeX's prompt). TeX responded by telling me that \emph
is a macro which takes no arguments and expands to \protect \emphÂ
. (There's actually a space in the name of the latter control sequence, which is why there are two spaces between \emph
and the period.)
As an example of a macro which takes arguments, we can define \def\foo#1{asdf}
which takes a single argument. When we ask TeX for the definition, it responds as follows.
*\show\foo
> \foo=macro:
#1->asdf.
<*> \show\foo
Here, it's showing us that it takes a single argument (denoted #1
) and then expands to asdf
(note that we didn't actually use the argument).
What this means is that we can't even interrogate TeX to ask it which macros require arguments and which do not. (Technically speaking, the problem of deciding if a given macro requires an argument is undecidable. The proof is a simple reduction to the Halting problem.)
Unfortunately, this means that differentiating control sequences that require arguments from those that remain in effect until some point in the future (like the end of a group, or the end of a paragraph) from those that perform some discrete action right then is just a matter of experience and reading documentation. Hopefully LaTeX 3 will improve the situation.
Let's look at what is happening here. The construct
\@namedef{saveBox}{<what was inbetween \csname \endcsname>}
is defining \saveBox
as a macro with replacement text <what was inbetween \csname \endcsname>
. That's because \@namedef
is defined as
#1->\expandafter\def\csname #1\endcsname
That means that what it does is first convert #1
(saveBox
in your case) into a control sequence (\saveBox
here), the apply \def
. So it's become the same as doing
\def\saveBox{<what was inbetween \csname \endcsname>}
This is a useful-enough thing to do, but in the current case isn't actually what you want!
The second line
\expandafter\newsavebox\@nameuse{saveBox}
is going to fail badly for several reasons, as comments already mention. \@nameuse
is a wrapper around \csname ...\endcsname
, and so with only one expansion you get to
\newsavebox\csname saveBox\endscsname
which tries to define \csname
as a new box!. If we do two expansions we get to
\newsavebox\saveBox
which is still wrong as you've already defined \saveBox
as a macro.
Based on the linked question, what you seem to want is more of the form
\def\my@name{MyString\@alph\count@}
\expandafter\newsavebox\csname\my@name\endcsname
...
\expandafter\usebox\csname\my@name\endcsname
i.e. to save the form of the name in a macro and reuse that.
You may wonder what \@nameuse
is for, as it seems to make things more not less complex (\@namedef
is handy). This is at least partly historical: when LaTex2e was written, tokens were very 'expensive', so the saving of \@nameuse
(one token) over \csname ...\endcsname
(two tokens) was worth making when you look at all of the uses in the kernel. Today, that's much less important, although there is an argument that
\def\foo#1{% Some function
...
\@nameuse{my@#1}%
}
is clearer than
\def\foo#1{% Some function
...
\csname my@#1\endcsname
}
as it shows up that something is being used rather than say defined by name.
Using \@namedef
is more common, as it allows easy construction of 'on the fly' names. For example, we can imagine storing some user input:
\newcommand{\mycommand}[2]{%
\@namedef{mycommand@store@#1}{#2}%
}
This might then say be used to save some user information: I'll use e-mail addresses but it could be anything
\mycommand{Joe Bloggs}{joe.blogs@some.domain}
If you have a bigger set up doing this, say storing several pieces of data about several 'keys', then using \@namedef
keeps things a lot more readable than using \expandafter\def\csname ...
.
\mycommand{A. N. Other}{another@place.com}
Best Answer
It is sort of legal latex but clearly not "good latex style".
\noindent
shouldn't normaly be used, and\vskip
shouldn't be used. (\vspace
) Normally within a document one would use a blank line rather than\par
(\par
is more use within macro definitions where a blank line often looks less convenient, as you may wish to indent code).LaTeX counters like
a
have a print representation command\thea
which should be used to print the value. The document sets this up so that if the value is2
it may print as 2 or 3.1.2 or a or ii depending on the style specified.\value{a}
returns the underlying number in the register.\number\value{a}
prints the decimal value of that value but is almost never used.Note also that
c7
while a latex counter in some sense is inconvenient as the print commandthec7
is not accessible as\thec7
so you would have to use\csname thec7\endcsname
but really there is no advantage in using non-letters in the counter name.