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?)
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}
-
Nice approach: probably better than mine (still risky, though).– Joseph Wright ♦Aug 18, 2010 at 19:33
-
I've used this approach for a while and I haven't noticed any problems. Maybe I was just lucky... Aug 18, 2010 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, 2010 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.)
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.
-
2
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.
-
Why did you have do delete your other answer? Now I have to share the
disciplined
badge ;-)– CaramdirAug 21, 2010 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, 2010 at 13:27
\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.)