# New command not working as expected

When using \fbox on its own, it creates a border around the text. However, I want to create a new command so I can create a boxed code example. Written 'inline', it works as expected:

\fbox{\scriptsize{\texttt{example}}}

However, when I put it into a new command:

\newcommand{codelist}[1]{\fbox{\scriptsize{\texttt{#1}}}

It doesn't apply the border, nor does it apply the font and sizing.

I am completely new to LaTeX, so any help will be much appreciated in identifying what the problem is.

-

Try

\newcommand{\codelist}[1]{\fbox{\scriptsize{\texttt{#1}}}

You missed a backslash.

EDIT

As Herbert pointed out in his answer, a couple of the curly braces are not required, since \scriptsize is a switch and takes no arguments. i.e.

\newcommand{\codelist}[1]{\fbox{\scriptsize\texttt{#1}}

is sufficient since the script sized text is contained within the scope of fbox.

-
That worked, thank you. I assumed the slash was implicit. Will accept answer once it lets me. –  Saladin Akara Nov 12 '11 at 13:53
@SaladinAkara: You're welcome. It seemed strange to me too the first time! –  qubyte Nov 12 '11 at 13:55
As pointed out by Herbert, the curly brackets to the right of \scriptsize don't do anything since it's a switch. The \fbox is really what is containing it, and in general you'd want to do it like this: {\scriptsize stuff}. –  qubyte Nov 12 '11 at 14:06

use it this way:

\newcommand\codelist[1]{\fbox{\scriptsize\texttt{#1}}

\scriptsize is a switch and not a command with an argument. A command has to befined with a backslash and an environment by its name without a backslash:

\newcommand\foo[..]{...}
\newenvironment{foo}[...]
{...}
{...}
-