Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
    
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
2  
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
add comment

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}[...]
  {...}
  {...}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.