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?)
- 259,911
- 34
- 706
- 1,036
- 885
4 Answers
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}
- 259,911
- 34
- 706
- 1,036
- 45,462
-
-
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
breqnthat 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
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.)
- 153,724
- 43
- 389
- 751
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.
- 1,306
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.
- 259,911
- 34
- 706
- 1,036
-
Why did you have do delete your other answer? Now I have to share the
disciplinedbadge ;-) – 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
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\mathbb Rcame 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\mathbbsince that's what's expected.) – TH. Aug 19 '10 at 22:21