2

Do postscript fonts such as libertine (from the libertine-legacy package) or mathpazo have a minus sign that can be accessed when in text mode? What I am trying to do is substitute the normal dash with a minus symbol, following this answer from David Carlisle.

His solution works perfectly when using open type fonts as most of them have a minus character that can be easily accessed:

\def\yyy{%
  \bgroup\uccode`\~\expandafter`\string-%
  \uppercase{\egroup\edef~{\noexpand\text{\char"2212\relax}}}%
  \mathcode\expandafter`\string-"8000 }

However, my attempts to do something similar with pdfLaTeX and Libertine or Pagella have been futile. Using a symbol like hyphen (\textendash) works perfectly:

\def\yyy{%
  \bgroup\uccode`\~\expandafter`\string-%
  \uppercase{\egroup\edef~{\noexpand\text{\llap{\textendash}\relax}}}%
  \mathcode\expandafter`\string-"8000 }

But is not exactly what I want. How can I access the minus symbol of that font? Or, if that is not possible, is it possible to resize the hyphen to "fake" a minus symbol?

Edit: egreg provided the solution below. Embedded into my framework the code is:

\def\yyy{% Thanks to egreg
  \begingroup\uccode`~=`-
  \uppercase{\endgroup\def~}{\mathbin{\text{\llap{\textminus}}}}
  \mathcode`-="8000 }
Jörg
  • 7,653

1 Answers1

2

The en dash is in position "15 in the T1 encoding:

\begingroup\uccode`~=`-
  \uppercase{\endgroup\def~}{\mathbin{\text{\char"15 }}}
\AtBeginDocument{\mathcode`-="8000 }

Alternatively, there's \textminus in the TS1 encoding:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{textcomp}
\usepackage{amsmath}
\begingroup\uccode`~=`-
  \uppercase{\endgroup\def~}{\mathbin{\text{\textminus}}}
\AtBeginDocument{\mathcode`-="8000 }

\begin{document}
$-$
\end{document}
egreg
  • 1,121,712