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.

(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:

\newcommand{\myfaxdate}[1]{\newcommand{\@myfaxdate}{#1}}
\newcommand\myfaxto[1]{\newcommand{\@myfaxto}{#1}}
\newcommand\myfaxfrom[1]{\newcommand{\@myfaxfrom}{#1}}
\newcommand\myfaxre[1]{\newcommand{\@myfaxre}{#1}}
\newcommand\myfaxnumpages[1]{\newcommand{\@myfaxnumpages}{#1}}
\newcommand\myfaxtelnum[1]{\newcommand{\@myfaxtelnum}{#1}}
\newcommand\myfaxnum[1]{\newcommand{\@myfaxnum}{#1}}
\newcommand\myfaxcomments[1]{\newcommand{\@myfaxcomments}{#1}}

\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,3){\makebox{\bfseries Comments:} \@myfaxnumpages}
  \put(0,2){\makebox{\bfseries From:} \@myfaxtelnum}
  \put(0,1){\makebox{\bfseries Re:} \@myfaxnum}
  \put(0,0){\makebox{\bfseries Comments:} \@myfaxcomments}
} 

\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}
\myfaxcomments{blah not blee}

\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.

share|improve this question
1  
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
    
This probably has to deal with a scoping issue; that is, your command \@myfaxdate is defined locally and its definition is lost outside of the group it was created in. Perhaps try \newcommand{\@myfaxdate}{} outside of any group in your style file, and then use \newcommand{\myfaxdate}[1]{\renewcommand{\@myfaxdate}{#1}}? If this does not work, perhaps a little more context by expanding on your "simplified example". –  Werner Sep 29 '11 at 7:40
    
@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
add comment

2 Answers

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

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,3){\makebox{\bfseries Comments:} \@myfaxnumpages}
    \put(0,2){\makebox{\bfseries From:} \@myfaxtelnum}
    \put(0,1){\makebox{\bfseries Re:} \@myfaxnum}
    \put(0,0){\makebox{\bfseries Comments:} \@myfaxcomments}
 \end{picture}%
}

A few more suggestions:

  • Use \newcommand{\@someinfo}{} and \newcommand{\someinfo}[1]{\renewcommand{\@someinfo}{#1}}. This will allow you to invoke \someinfo any number of times.
  • 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.
share|improve this answer
    
thanks for you help. As I said in my comments to Werner, I tried your solution last night and it worked fine. The problem is that my actual fax cover is more complicated than my MWE, containing a header for my org and a top block and a bottom block. These 3 blocks I have in 3 boxes. When I constructed the page it's easier for me to move the 3 blocks around as blocks, so I can move the bottom block up as a unit rather than having to give each component of the block a new location individually. In my actual style file the \makefax command has 3 \put statements, one for each block. –  bev Sep 30 '11 at 0:21
    
So while your solution works, it's not optimal. The reason I posed this question, really, is not just to get this fax done, it's so that I know how to put variables inside of boxes, as my question states. So I need a solution that solves that problem, not one that sidesteps it. –  bev Sep 30 '11 at 0:23
    
@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
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.