Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 }
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
    
But I need a minus, not the en dash...? –  Jörg Aug 24 '12 at 15:43
    
@Jörg There's no minus sign in the T1 encoding. –  egreg Aug 24 '12 at 16:28
    
Brilliant, thanks. But I think there is no need to load amsmath here. –  Jörg Aug 24 '12 at 17:52
    
Sorry, I'm lost. I do not understand that is intended here. Even zooming at huge font size, I cannot see any difference between the customized $-$ with \textminus nor the simple -- in text mode using this MWE. –  Fran Aug 24 '12 at 18:03
    
@Jörg You need at least amstext for \text. –  egreg Aug 24 '12 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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