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.

I have a command \putansline{1}{2} that inserts 1 line of dots and prints the total score as [2]. I want to define a new command that if issued, will redefine this command so that it prints only the score. Here's what I have for this new command:

\newcommand{\hideanslines}{%
  \renewcommand{\putansline}[2]{[#2]}
}% 

I get an illegal parameter number error for this new command though. How can I define this new command hideanslines so that after I issue it, putansline can only print the points and not the lines?

share|improve this question
4  
The nested-ness of a macro definition increases the number of #'s by a factor of 2. See the following UK TeX FAQ entries: Illegal parameter number in definition, followed by Defining LaTeX commands within other commands (for a LaTeX reference) and Defining macros within macros (for a TeX reference). –  Werner Dec 26 '11 at 7:23
add comment

1 Answer

up vote 17 down vote accepted

Use two #'s.

\newcommand{\hideanslines}{%
  \renewcommand{\putansline}[2]{[##2]}%
}
share|improve this answer
    
Perfect. Thanks. –  recluze Dec 26 '11 at 7:09
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.