10

The $\ell$ character in math-mode is clearly slanted to match the usual slant of math-mode characters. Is there a way to typeset an upright version, that won't look slanted amid other upright-math-mode characters?

jub0bs
  • 58,916
  • 2
    Why do you need such a char? \ell is after all just a way of making l 'show up' more. – Joseph Wright May 04 '14 at 18:13
  • \ell is a nice symbol, I prefer it especially in math mode or in diagrams to differ from I, 1 or l. I also wonder why you want to make it 'upright'? –  May 04 '14 at 18:22
  • 2
    Since \ell denotes the character SCRIPT SMALL L, which is derived from an italic l (as the Unicode Standard says), it is in essence italic. It is illogical to try to make it upright. – Jukka K. Korpela May 04 '14 at 19:12
  • 1
    For those asking why I want such a thing, I typeset scalar quantities in italic, and vector quantities in upright bold. \boldsymbol\ell suffices to make \ell boldface, but it is still italic. I wanted to know how to make it upright as well. \mathbf{l} is unsatisfactory to me because it is confusable with a 1 even more so upright than italicized. – thecommexokid May 04 '14 at 21:35
  • You have an upright ell in the Minion Pro Regular text font (U2113). I suppose you could declare this character as a math symbol. – Bernard May 07 '14 at 20:54
  • 1
    Another possible reason: the \ell in $\ell^p$-space is a constant, and ‘should’ therefore be set upright (as far as I know nobody does this, however). – equaeghe Aug 27 '14 at 15:04

1 Answers1

15

I defined a new control sequence \uell which typesets an \ell but rotated by 10 degrees. It also adjusts the spacing around the rotated \ell to be the same as for unrotated \ell.

\documentclass{article}
\pagestyle{empty}% for cropping
\usepackage{graphicx}
\makeatletter
\DeclareRobustCommand*\uell{\mathpalette\@uell\relax}
\newcommand*\@uell[2]{
  % We need to adjust the width of \uell to be the same as \ell
  \setbox0=\hbox{$#1\ell$}
  \setbox1=\hbox{\rotatebox{10}{$#1\ell$}}
  \dimen0=\wd0 \advance\dimen0 by -\wd1 \divide\dimen0 by 2
  \mathord{\lower 0.1ex \hbox{\kern\dimen0\unhbox1\kern\dimen0}}
}
\begin{document}
\section{$\uell$}
\ttfamily
\begin{tabular}{ll}
  \string\ell  & $jk\ell mn$                  \\
  \string\uell & $jk\uell mn$                 \\
  \string\ell  & $jk\ell_{\ell_{\ell}} mn$    \\
  \string\uell & $jk\uell_{\uell_{\uell}} mn$ \\
\end{tabular}
\end{document}

enter image description here

Using expl3

The output stays the same, of course.

\documentclass{article}
\pagestyle{empty}% for cropping
%\usepackage{xparse} expl3 is now default since 2020
\ExplSyntaxOn

\box_new:N \l_uell_box \dim_new:N \l_uell_dim

\cs_new_protected:Npn __uell:nn #1#2 { % We need to adjust the width of \uell to be the same as \ell \hbox_set:Nn \l_uell_box { $#1\ell$ } \dim_set:Nn \l_uell_dim { \box_wd:N \l_uell_box } \box_rotate:Nn \l_uell_box { 10 } \dim_set:Nn \l_uell_dim { (\box_wd:N \l_uell_box - \l_uell_dim) / (-2) } \tex_mathord:D { \box_move_down:nn { .1ex } { \hbox:n { \tex_kern:D \l_uell_dim \hbox_unpack_drop:N \l_uell_box \tex_kern:D \l_uell_dim } } } }

\NewDocumentCommand\uell{} { \mathpalette __uell:nn \scan_stop: }

\ExplSyntaxOff \begin{document} \section{$\uell$} \ttfamily \begin{tabular}{ll} \string\ell & $jk\ell mn$ \ \string\uell & $jk\uell mn$ \ \string\ell & $jk\ell_{\ell_{\ell}} mn$ \ \string\uell & $jk\uell_{\uell_{\uell}} mn$ \ \end{tabular} \end{document}

T.D
  • 147
Henri Menke
  • 109,596
  • \mathpalette\@uell\relax uses one token less. ;-) – egreg May 04 '14 at 20:23
  • @egreg I updated my answer. Maybe we can now save half a nanosecond. – Henri Menke May 04 '14 at 20:52
  • 1
    I had already upvoted it; but saving half a nanosecond might be decisive. ;-) – egreg May 04 '14 at 20:59
  • This solution is definitely good enough for me as is, but since you seem to be the sort interested in matters of half-a-nanosecond, I would point out that this solution raises the baseline of \uell slightly relative to other characters, as you can see if you place it in context rather than alone on a line. Example. – thecommexokid May 04 '14 at 21:45
  • @thecommexokid I updated my answer. – Henri Menke May 04 '14 at 21:52
  • Great! Thanks also for indirectly teaching me about the \string command, too. I suspect that could come in handy someday. – thecommexokid May 04 '14 at 21:59
  • For those for which this is not obvious: \uell is fragile, so be ready to \protect it when using it in headings and the like. – equaeghe Aug 27 '14 at 15:08
  • @equaeghe You don't need to \protect it everytime. Just make it robust. I updated my answer accordingly. – Henri Menke Aug 27 '14 at 19:19
  • You should still define \__uell:nn with two parameters. By the way, also \@uell should have two arguments. In both cases, #2 is not used. – egreg Aug 27 '14 at 20:48
  • @egreg I don't understand. Why two arguments? – Henri Menke Aug 27 '14 at 20:56
  • @HenriMenke That's what \mathpalette expects. The first argument to \mathpalette should be a macro with two arguments, the first of which should be a style declaration. With only one argument, you leave a {\relax} or {{}} atom in the math list. – egreg Aug 27 '14 at 20:58
  • @egreg Does it matter, whether \relax is put back in the input stream by mathpalette or gobbled by \@uell? – Henri Menke Aug 27 '14 at 21:00
  • @HenriMenke It can matter. – egreg Aug 27 '14 at 21:02