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.

How do I overwrite the default $l$ character so that it is substituted by $\ell$ throughout math mode? (More generally, is there an easy way to make such symbol substitutions?)

share|improve this question
1  
I think this is generally a bad idea. The reason that people write cursive ls is to differentiate them from 1s when writing on a black board. In typeset material, there is no need for the \ell as l and 1 are already visually distinct. I realize some book authors use it, but I believe the majority do not. I see the \ell mostly in conference proceedings where the authors do not know better. –  TH. Aug 18 '10 at 20:57
3  
@TH: I disagree with the implication that there is no need to use \ell. Particularly as a subscript (a common use especially for letters near the middle of the alphabet) l can be an indistinct squiggle. And there are some specific uses (the sequence space \ell^p, for example) for which \ell really is a now-standard notation and using l instead comes across as lazy typesetting. Nevertheless, I agree that making this substitution everywhere isn't a great idea. –  Mark Meckes Aug 19 '10 at 14:13
    
@Mark Meckes: I guess it makes sense that it would start to be used. \mathbb R came about as a way to bold on the blackboard and is now standard. I actually think that just normal bold is more elegant, somehow. (I still use \mathbb since that's what's expected.) –  TH. Aug 19 '10 at 22:21
    
@TH: I'm not fond of normal bold in math myself. It may not be difficult in practice, but I just don't like the idea of distinguishing between characters based on the thickness of strokes, as opposed to their number, location, intersections, etc. For similar reasons I prefer \ell to l. But I'm also usually guided more by prevailing practices than my own aesthetics. –  Mark Meckes Aug 20 '10 at 15:30

4 Answers 4

up vote 11 down vote accepted

This is similar to how MinionPro deals with open vs closed mathematical g's.

\documentclass{article}
\mathcode`l="8000
\begingroup
\makeatletter
\lccode`\~=`\l
\DeclareMathSymbol{\lsb@l}{\mathalpha}{letters}{`l}
\lowercase{\gdef~{\ifnum\the\mathgroup=\m@ne \ell \else \lsb@l \fi}}%
\endgroup
\begin{document}
\( l = 2 \) \( \lim = 2 \)
\end{document}
share|improve this answer
    
Nice approach: probably better than mine (still risky, though). –  Joseph Wright Aug 18 '10 at 19:33
    
I've used this approach for a while and I haven't noticed any problems. Maybe I was just lucky... –  Lev Bishop Aug 18 '10 at 19:39
    
I'm thinking of packages such as breqn that rely on all sorts of things being active. You might get something nasty happening: I've not tested this :-) –  Joseph Wright Aug 18 '10 at 19:52

There is if you are using Lyx or SWP. E.g., you can have SWP search for l in math (SWP is wysiwym) and replace it with \ell. It will do this and ignore l in text.

share|improve this answer
1  
Please give more details! –  Joseph Wright Aug 18 '10 at 18:34
    
Thanks for that. –  Joseph Wright Aug 18 '10 at 19:18

To do it via an external search-and-replace, you could use a script that I wrote called mathgrep. It's a perl script designed to do search and search-and-replace within maths sections of a LaTeX document.

The main limitation of this script is that it doesn't regard dollars as valid maths delimiters - but then, no-one uses them, right? Actually, I wrote a script to deal with that as well, which I called debuck for some reason that escapes me now.

(Oh yeah, I remember: dollar = buck.)

share|improve this answer
1  
@Caramdir: well spotted! Thanks. –  Loop Space Aug 18 '10 at 20:38

I think your best plan is to do a search and replace. You'll need to use some kind of regular expression (or, as user714 notes, so set up that can search selectively within math). The advantage of altering the source is you avoid any nasty side issues.

share|improve this answer
    
Why did you have do delete your other answer? Now I have to share the disciplined badge ;-) –  Caramdir Aug 21 '10 at 13:09
    
I was thinking about the 'let people get answers in' point, and decided that I should lead by example :-) –  Joseph Wright Aug 21 '10 at 13:27

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.