# expanding variable inside picture environment

(this version of this question is highly edited based on suggestions)

I thought to quickly create a fax cover sheet last night and, quickly creating one, I ran into a problem I can't figure out so I thought I'd ask around. First, the structure: I have 2 files: one is the style file and the other is the file with the specific fax info. In the style file I've created some variables to hold data that is specified in the info file. Here is the style file:


\newsavebox{\faxcover}
\savebox{\faxcover}{%
\put(0,7){\makebox{\bfseries Date:} \@myfaxdate}
\put(0,6){\makebox{\bfseries To:} \@myfaxto}
\put(0,5){\makebox{\bfseries From:} \@myfaxfrom}
\put(0,4){\makebox{\bfseries Re:} \@myfaxre}
\put(0,2){\makebox{\bfseries From:} \@myfaxtelnum}
\put(0,1){\makebox{\bfseries Re:} \@myfaxnum}
}

\newcommand{\makefax}{%
\begin{picture}(10,10)
\put (0,0){\usebox\faxcover}
\end{picture}
}


Here's the other file (the top-level file)

\documentclass[10pt]{report}
\usepackage{./myfax}
\begin{document}

\myfaxdate{09-28-2011}
\myfaxto{Ozymandius, King of Kings}
\myfaxfrom{Bev}
\myfaxre{Two vast and trunkless legs of stone}
\myfaxnumpages{3 counting the cover sheet}
\myfaxtelnum{(516) 676-4099}
\myfaxnum{(800) 123-4567}

\makefax

\end{document}


When I compile, I get an error telling me that \@myfaxdate is an undefined control sequence. I should add that the purpose of dividing into 2 files is because I want to create my own fax style that I may want others in my org to use (maybe). This will simplify it so all they have to know how to do is to fill in some blanks in the main file.

-
There should be a problem either inside or outside: @ is not considered a letter normally by LaTeX. Please add a minimal working example (MWE). –  Andrey Vihrov Sep 29 '11 at 7:39
@AndreyVihrov: except in packages ;-) –  ℝaphink Sep 29 '11 at 8:07
@Andrey - Sorry, I thought that was an MWE. Apparently too much so. I hope this one is clearer. –  bev Sep 29 '11 at 20:46
@Werner - I think that you're correct. I was messing about last night and saw that if I eliminate the boxes, and just use the picture env it compiles. The trouble is that I want to use the boxes as it makes structuring the page so much easier. Do your comments still apply given the edited version of my question? Thx. –  bev Sep 29 '11 at 20:49

Try this:

\documentclass{article}
\begin{document}
\newcommand{\myfaxdate}[1]{#1}
\begin{picture}(5,5)
\put(30,30){Date: \myfaxdate{9-12-2011}}
\end{picture}
\end{document}

-
well, it works, but it doesn't conform to my wish to have a style file and a user's main file containing the specific info for that specific fax. Thanks tho... –  bev Sep 29 '11 at 20:51

The box in \savebox is constructed at "save" time, not at "use" time. By that time the commands have not yet been defined.

Try not using \savebox and \usebox at all:

\newcommand{\makefax}{%
\begin{picture}(10,10)
\put(0,7){\makebox{\bfseries Date:} \@myfaxdate}
\put(0,6){\makebox{\bfseries To:} \@myfaxto}
\put(0,5){\makebox{\bfseries From:} \@myfaxfrom}
\put(0,4){\makebox{\bfseries Re:} \@myfaxre}
\put(0,2){\makebox{\bfseries From:} \@myfaxtelnum}
\put(0,1){\makebox{\bfseries Re:} \@myfaxnum}

• The \makebox seems like it could be replaced with just \textbf.
• If you use tabular or \parbox (or nothing at all) instead of picture, you need not worry about interline space.
@bev: You seem to misunderstand the purpose of \savebox. It's not to create a box, it's to typeset text and store the result in a box register. If you say \usebox{\mybox} n times, you get n copies of the same, already typeset content. To put content in a box so that you can treat it as a unit use \parbox or similar. –  Andrey Vihrov Sep 30 '11 at 4:58