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 large document with a lot of equation, the author overwritten the original \l (used to get polish letter ł) with \renewcommand\l{{\lambda}}. It would be to much work to find all the \l in all the equations and change it to \lambda. I only need couple of ł it the entire doc so I need to reset locally the \l command. How do I do that? \renewcommand\l{???}

share|improve this question
    
Would search and replace help, perhaps using regular expressions? –  Henry DeYoung Oct 29 '12 at 21:03
    
My bad, thank you for moving it. –  Tomasz Andrysiak Oct 30 '12 at 7:43
add comment

migrated from stackoverflow.com Oct 29 '12 at 20:04

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 5 down vote accepted

You cannot reset a \renewcommand. But there are several options.

The cleanest would be to write ł instead of \l directly. This merely requires saving the document as UTF-8 and either using a modern LaTeX processor (LuaTeX or XeLaTeX) or to include the inputenc package with the utf8 option (\usepackage[utf8]{inputenc}).

Alternatively, you can define a new command to include \l immediately before it’s redefined:

\let\lw\l
\renewcommand\l{{\lambda}}

… and then just use \lw in place of \l to typeset ł.

Or you could change the redefinition of \l so that it only includes the λ in math mode, and includes ł in text mode. But I wouldn’t do that – it’s very unintuitive and hard to understand as a reader of the source code. Still, here it is:

\let\oldl\l
\renewcommand\l{\relax\iffmode\lambda\else\oldl\fi}

% … usage:

Here’s a z\l oty for your effort. $\l = 1\ \mL$

… which will render as:

Here’s a złoty for your effort. λ = 1 µL

share|improve this answer
3  
It would be better to use \LetLtxMacro\oldl\l (requires loading the letltxmacro package) and \DeclareRobustCommand{\l}{\ifmmode\lambda\else\oldl\fi} –  egreg Oct 29 '12 at 20:15
    
Hey Konrad, all your suggestions work, I choose the first one since it's the fastest, but I like the one with it being different command if it's in math mode, very clever. Thank You! You saved me days of work this being a 700 page book! –  Tomasz Andrysiak Oct 30 '12 at 7:41
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.