1

I want to override the look of the letter I in mathsf's font as it looks like a vertical bar and the letter l. By default, it looks like the following:

enter image description here

My goal is to have look like that:

Desired output

How can I change this single letter in mathsf's font only?

I have looked at How do I change the font of a letter and Changing one letter changes that letter throughout a paper but they didn't help me very much. I even used Detexify but it didn't help either.

Edit:

With the help of @David Carlisle's answer, I came up with a semi-solution by declaring a new command called \I and assigned it the following:

\newcommand{\I}{{\fontfamily{lcmss}\selectfont\ensuremath{\mathrm{I}}}}

So that $\I$, \I gives:

Output

  • You could search for an I that matches your needs in other fonts, make I math-active and have it switch the font family and input an I from that family. – Skillmon likes topanswers.xyz Jan 9 at 20:07
  • @Skillmon, Can you please direct me to place showing how to do all of this? I am not comfortable with changing fonts like that. I want to make sure I do it properly. – M. Al Jumaily Jan 9 at 20:36
  • @M.AlJumaily I have no idea how to do it properly :) I'm not good with fonts, too. But I did something like that once. My solution didn't cover shape or series changes though, just so you're warned. The first step you have to do is find a font that contains the letter you want to use. If you got that, you have to make it available with \DeclareSymbolFont and then you can use \DeclareMathSymbol (see tex.stackexchange.com/a/2972/117050 for a rough idea). – Skillmon likes topanswers.xyz Jan 9 at 21:14
  • @Skillmon, thanks for the honesty and the reference :). – M. Al Jumaily Jan 9 at 21:16
  • Can you show us what you've got so far? Do you have a font you want to use? Do you know arevmath? It's a package that defines an sans-serif math alphabet with unambiguous letters. Maybe you want to ditch sfmath and use arevmath instead. Or do you need a very specific font? – Skillmon likes topanswers.xyz Jan 9 at 21:25
5

LaTeX includes a modified sans serif font lcmss derived from cmss but with adjustments to make more characters distinguishable, including the capital i.

enter image description here

\documentclass{article}

\DeclareMathAlphabet\mathsf{OT1}{lcmss}{m}{n}

\begin{document}


$ 1+2 +3 + \mathsf{IJK} + \mathsf{ijk} $

\end{document}
|improve this answer|||||
  • Thank you for the answer. Is there a way to only change the letter I and keep the everything else untouched? – M. Al Jumaily Jan 9 at 22:15
  • Ow, I never heard about lcmss. Nice. – Sigur Jan 9 at 22:16
  • @Sigur slides class (people lured to beamer but slides still has some hidden tricks:-) – David Carlisle Jan 9 at 22:17
  • @M.AlJumaily in theory yes but it's considerably more complicated and fragile. Also it would be a completely different answer. The point of this answer is rather to suggest using a different font rather than patching individual letters. So someone else will no doubt post a different technique, if you accept that answer that's fine, but I don't want to change the message of this one. – David Carlisle Jan 9 at 22:26
  • @DavidCarlisle the other answer (changing only a single glyph/letter) would be a duplicate from the ones linked in the OP. – Skillmon likes topanswers.xyz Jan 9 at 22:34
1

With the unicode-math package, you can override a single math-mode character with the [range=...] option of \setmathfont, in this case, \setmathfont[range=\msansI] to change only the mathematical sans-serif I. You might, however, have better results loading an entire sans-serif alphabet as \setmathfont[range=sfup].

With legacy fonts, you can load a \mathsf alphabet with the [sfdefault=...] option of the isomath package. The supported options in OML encoding are cmbr, fav, hvm, iwona, jkpfss and llcmss.

|improve this answer|||||
0

You're going to need to descend to some low-level TeX to make this work. The command you care about is \mathcode which is described in chapter 17 of The TeXbook. I don't have my copy handy to give you a complete accounting of what you need to do, but you'll do something along the lines of

\mathcode`I="7A49

where the A is going to need to be changed to correspond to the numeric value for the math font family—it will be a value somewhere in the range 8–F depending on when the alphabet gets declared.

I hope this is enough to get you started.

|improve this answer|||||
  • Can I confirm that this will change a specific letter only when using the mathsf font? – M. Al Jumaily Jan 9 at 22:44
  • 1
    This is equivalent to doing \DeclareMathSymbol, so you won't need some low-level TeX, see tex.stackexchange.com/a/2970/117050 (as linked in the OP). – Skillmon likes topanswers.xyz Jan 9 at 23:08
  • @M.AlJumaily the 7 at the start means that it will be affected by math alphabet commands (e.g. \mathbf). – Skillmon likes topanswers.xyz Jan 9 at 23:11
  • Note that in latex math alphabets like \mathsf are allocated on demand when (if) first used so the hex digit you need to use in the \mathcode to represent the math font family depends on the specific document and the order that \mathsf, \mathfrak etc are used. – David Carlisle Jan 9 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.