[texhax] \newcommand

Barbara Beeton bnb at ams.org
Thu Sep 25 16:42:51 CEST 2003


roger,
you've fallen into a most common patch of quicksand.

control sequences containing @ signs are "internal" ones,
and must be given special attention.  the fix, fortunately,
is simple.  two possibilities:

 - put your new command in a file named whatever.sty and
   then \usepackage{whatever}

 - leave the definition in the preamble of your document
   and surround it by the commands
     \makeatletter
     ...
     \makeatother

this is almost certainly described in the very fine uktug
faq; i think the url is
    http://www.tex.ac.uk/faq/
(you really should become acquainted with the faq -- it's
worth your effort.)
							-- bb

---------- Original message ----------
Date: Thu, 25 Sep 2003 16:45:33 -0230 (NDDT)
From: Roger Mason <rmason at sparky2.esd.mun.ca>
To: texhax at tug.org
Subject: [texhax] \newcommand

Hello,

I am trying to define a command in latex with this code in the preamble:

\newcommand{\mybox}[2]{%
  \setlength{\unitlength}{1pt}
  \makeatletter
  \begin{picture}(\strip at pt\linewidth,#1)
    \put(0,0){\framebox(\strip at pt\linewidth,#1)[tl]{#2}}
  \end{picture}
  \makeatother}

It is designed to produce a box that is the width of the \linewidth
currently in use at height #1 containing text #2.  The code in the
definition was obtained from the archives of this list and runs fine when
embeded in a LaTeX document (with numbers for #1 & #2).  When I define the
command above and invoke it using (for example)

\mybox{72}{Zn}

in the body of the document, compilation fails and the log file says:

! Undefined control sequence.
<argument> \strip
                  @pt\linewidth
l.90 \mybox{72}{Zn}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

Is there some simple step I am missing?

Thanks for any replies,

Roger Mason

P.S. Is it considered good etiquette on this list to thank responders on
the list or should that be done privately?


More information about the texhax mailing list