[Tex/LaTex] Typesetting <= and < symbols using the default document font

fontssymbols

I am writing a document where I need to describe the behaviour of a given system when a parameter is in a given range (e.g. 1 <= x < 100). The document does not otherwise contain equations or any math stuff. I am using the Source Sans Pro font from Adobe and I am having trouble with the <= and < symbols.

  • If I use $\leq$ for the <= symbol, it looks different than the rest of the text, but more specifically, quite different than the < symbol
  • If I use $\leq$ and $<$, then they look 'similar' but the baselines don't seem to be aligned (and anyway they look different from the rest of the text)

Here's an image showing both options:

enter image description here

Is there a way to typeset the <= symbol using the same font as the rest of the document? Failing that, is there a way to have the baselines of the <= and < symbols aligned?

Update: I am using pdflatex. Here's a MWE:

\documentclass{book}

\usepackage[default]{sourcesanspro}

\begin{document}

1 $\leq$ abs(x) < 100

1 $\leq$ abs(x) $<$ 100

\end{document}

Best Answer

With lualatex/xelatex using the glyph from SourceSansPro is easy:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{SourceSansPro}
\DeclareTextSymbol{\textlessthanequal}       \UnicodeEncodingName{"2264}
\begin{document}
1 ^^^^2264 x < 2

1 ≤  x < 2 

1 \textlessthanequal{} x < 2
\end{document}

enter image description here

With pdflatex it is more difficult. This here is a hack to avoid to have to do much work. It assumes that less equal as the same width as less.

  1. Find SourceSansPro-Regular-lf-t1--base.tfm (in fonts/tfm)
  2. Copy it e.g. to your current folder.
  3. Rename the copy to XSourceSansPro-Regular-lf-t1--base.tfm
  4. Find a_ggs4wk.enc (in fonts/enc)
  5. Copy it.
  6. Rename the copy to Xa_ggs4wk.enc
  7. Open Xa_ggs4wk.enc
  8. Change the line /AutoEnc_ggs4wkuzes44fkerkgtyzffacb [ to /XAutoEnc_ggs4wkuzes44fkerkgtyzffacb [
  9. Find in the file /less and change it to /lessequal
  10. Save the file.
  11. Test if it works with this document:

     \documentclass{book}
    
    \usepackage[default]{sourcesanspro}
    
    \pdfmapline{=XSourceSansPro-Regular-lf-t1--base XSourceSansPro-Regular "XAutoEnc_ggs4wkuzes44fkerkgtyzffacb ReEncodeFont" <[Xa_ggs4wk.enc <SourceSansPro-Regular.pfb}
    
    \makeatletter
    \DeclareFontEncoding{U}{}{}
    \DeclareFontFamily{U}{xsourcesans}{}
    \DeclareFontShape{U}{xsourcesans}{m}{n}
     { <->  XSourceSansPro-Regular-lf-t1--base
      }{}
    \newcommand\textlessequal{{\fontencoding{U}\fontfamily{xsourcesans}\selectfont <}}
    \begin{document}
    
    1 \textlessequal{} abs(x) < 100
    
    \end{document}
    

enter image description here

In both cases the less sign is not aligned along the baseline of the less equal sign. You can do it with your raisebox command, but imho it will look odd.