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'm trying to redefine \rule to make cleaner underscores, but my book file (in memoir class) is having problems with the following:

\RequirePackage{letltxmacro}
\LetLtxMacro{\oldrule}{\rule}
\renewcommand{\rule}[1]{\oldrule[0pt]{#1}{0.4pt}}

I get an "undefined control sequence" on \LetLtxMacro{\oldrule}{\rule}.

share|improve this question
5  
It's a very bad idea to redefine an important command of LaTeX, which is used in many places with a different syntax. –  egreg Dec 2 '11 at 20:29
1  
It was suggested to me here: [tex.stackexchange.com/a/36922/9757]. If there's a better way of doing this, though, that would be helpful too. Thanks! –  jamaicanworm Dec 2 '11 at 20:30
2  
The suggestion was bad. You won't be able to typeset footnotes, for example. Why not defining a command as I suggested you? \newcommand{\blank}[1]{\rule{#1}{0.4pt}} –  egreg Dec 2 '11 at 20:36
1  
@egreg: Note that in my answer to @ jamaicanworm's question there was no mention of using memoir. Moreover, the example given had no mention of the scope. Using something else (like your suggestion) would work fine. –  Werner Dec 2 '11 at 20:38
2  
@Werner It doesn't matter much what class is being used: don't ever advise to redefine kernel commands other than those that simply produce text; for instance \let\phi\varphi is OK, but redefining \parbox would be disastrous. –  egreg Dec 2 '11 at 20:42
show 2 more comments

1 Answer

up vote 9 down vote accepted

The purpose of \newcommand in LaTeX is exactly to protect users from redefining a command that can be very important for the system.

For instance, if one tries to redefine \fi, all sorts of strange things will happen, starting from LaTeX throwing an error when finding \begin{document} and telling

Missing \begin{document}.

Really. :)

The command \rule is used in the LaTeX kernel when typesetting footnotes and redefining it will break the feature. Classes and packages may use \rule as well: it appears 14 times in memoir.cls.

In some cases it's good to redefine also kernel commands; Heiko Oberdiek's packages do it frequently and for this the package letltxmacro has been devised. However users should know precisely what they're doing, and never change the command syntax (the number and nature of arguments).

It's quite strange that you get an error, because your code works for me. However, don't use it. Rather define a personal command such as

\newcommand{\blank}[1]{\rule{#1}{0.4pt}}

You'll have only benefits from this: you give semantic value to your code.

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.