summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/jknapltx/smartmn.sty
blob: 393becb607fe945b6928f0c14bd3f7aeef2d5369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
% smartmn.sty
% 
% (c) 1996--1999 Copyleft J"org Knappen
% Licence: GNU public licence version 2

\NeedsTeXFormat{LaTeX2e}[1994/12/01] % \DeclareRobustCommand
\ProvidesPackage{smartmn}[1999/06/01 v 1.1b Intelligent hyphen/minus (jk)]

\newcommand*\oriminus{-}
\providecommand\emdash{---} 
\def\aft@rfi#1\fi{\fi#1}
\chardef\m@nuscode=\catcode"2D %
\catcode"2D=\active
\def\sm@rtm@nus{\ifmmode\oriminus\else\aft@rfi\sm@rtm@n@s\fi }
\def\sm@rtm@n@s{\futurelet\sm@rtminus@next\sm@rtminus}
\def\sm@rtminus#1{%
             \expandafter\ifx \space\sm@rtminus@next\oriminus\space#1% 
             \else\ifx \ #1\oriminus\space
             \else\ifx -#1\oriminus\oriminus
             \else\ifx 0#1\textminus0%
             \else\ifx 1#1\textminus1%
             \else\ifx 2#1\textminus2%
             \else\ifx 3#1\textminus3%
             \else\ifx 4#1\textminus4%
             \else\ifx 5#1\textminus5%
             \else\ifx 6#1\textminus6%
             \else\ifx 7#1\textminus7%
             \else\ifx 8#1\textminus8%
             \else\ifx 9#1\textminus9%
             \else \oriminus#1%
             \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
\DeclareRobustCommand\p@m@nus{\sm@rtm@nus}
\let-\p@m@nus

\catcode"2D=\m@nuscode % Unactivate the hyphen/minus till \begin{document}

\providecommand{\textminus}{\ensuremath{\oriminus}}


\AtBeginDocument{\catcode"2D=\active}

\endinput

Description:

This style file makes the ASCII character `-' (hyphen/minus) active, so 
that it guesses, whether to print as a minus sign or as a hyphen.
The used heuristic is simple: It turns to a minus in math mode, or if it
is followed directly by a digit. Two dashes between digits are interpreted as
number range dash, no minus is inserted there. In other cases, it is just 
the plain old hyphen. The ligature `--' works as usual, but the em dash 
`---' is broken. If --- is followed by a digit, it prints as --$-$<digit>,
in the other case it is an en dash followed by a hyphen. The emdash can be
produced with the command \emdash.

Know deficiencies:

* You can't produce an em-dash by the input `---', use \emdash instead.
* The input `- -' produces an error message and wrong output.
* A space after the minus sign is eaten in moved text (like inside the 
  table of contents).
  Workaround for the later two deficiencies: -{}

J"org Knappen, Barbarossaring 43, D-55118 Mainz, Allemagne. 
Author of the Book: Schnell ans Ziel mit LaTeX2e, Oldenbourg-Verlag
M"unchen, 1997, ISBN 3-486-24199-0.

% /smartmn.sty