| 1 |
% smartmn.sty |
| 2 |
% |
| 3 |
% (c) 1996--1999 Copyleft J"org Knappen |
| 4 |
% Licence: GNU public licence version 2 |
| 5 |
|
| 6 |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] % \DeclareRobustCommand |
| 7 |
\ProvidesPackage{smartmn}[1999/06/01 v 1.1b Intelligent hyphen/minus (jk)] |
| 8 |
|
| 9 |
\newcommand*\oriminus{-} |
| 10 |
\providecommand\emdash{---} |
| 11 |
\def\aft@rfi#1\fi{\fi#1} |
| 12 |
\chardef\m@nuscode=\catcode"2D % |
| 13 |
\catcode"2D=\active |
| 14 |
\def\sm@rtm@nus{\ifmmode\oriminus\else\aft@rfi\sm@rtm@n@s\fi } |
| 15 |
\def\sm@rtm@n@s{\futurelet\sm@rtminus@next\sm@rtminus} |
| 16 |
\def\sm@rtminus#1{% |
| 17 |
\expandafter\ifx \space\sm@rtminus@next\oriminus\space#1% |
| 18 |
\else\ifx \ #1\oriminus\space |
| 19 |
\else\ifx -#1\oriminus\oriminus |
| 20 |
\else\ifx 0#1\textminus0% |
| 21 |
\else\ifx 1#1\textminus1% |
| 22 |
\else\ifx 2#1\textminus2% |
| 23 |
\else\ifx 3#1\textminus3% |
| 24 |
\else\ifx 4#1\textminus4% |
| 25 |
\else\ifx 5#1\textminus5% |
| 26 |
\else\ifx 6#1\textminus6% |
| 27 |
\else\ifx 7#1\textminus7% |
| 28 |
\else\ifx 8#1\textminus8% |
| 29 |
\else\ifx 9#1\textminus9% |
| 30 |
\else \oriminus#1% |
| 31 |
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} |
| 32 |
\DeclareRobustCommand\p@m@nus{\sm@rtm@nus} |
| 33 |
\let-\p@m@nus |
| 34 |
|
| 35 |
\catcode"2D=\m@nuscode % Unactivate the hyphen/minus till \begin{document} |
| 36 |
|
| 37 |
\providecommand{\textminus}{\ensuremath{\oriminus}} |
| 38 |
|
| 39 |
|
| 40 |
\AtBeginDocument{\catcode"2D=\active} |
| 41 |
|
| 42 |
\endinput |
| 43 |
|
| 44 |
Description: |
| 45 |
|
| 46 |
This style file makes the ASCII character `-' (hyphen/minus) active, so |
| 47 |
that it guesses, whether to print as a minus sign or as a hyphen. |
| 48 |
The used heuristic is simple: It turns to a minus in math mode, or if it |
| 49 |
is followed directly by a digit. Two dashes between digits are interpreted as |
| 50 |
number range dash, no minus is inserted there. In other cases, it is just |
| 51 |
the plain old hyphen. The ligature `--' works as usual, but the em dash |
| 52 |
`---' is broken. If --- is followed by a digit, it prints as --$-$<digit>, |
| 53 |
in the other case it is an en dash followed by a hyphen. The emdash can be |
| 54 |
produced with the command \emdash. |
| 55 |
|
| 56 |
Know deficiencies: |
| 57 |
|
| 58 |
* You can't produce an em-dash by the input `---', use \emdash instead. |
| 59 |
* The input `- -' produces an error message and wrong output. |
| 60 |
* A space after the minus sign is eaten in moved text (like inside the |
| 61 |
table of contents). |
| 62 |
Workaround for the later two deficiencies: -{} |
| 63 |
|
| 64 |
J"org Knappen, Barbarossaring 43, D-55118 Mainz, Allemagne. |
| 65 |
Author of the Book: Schnell ans Ziel mit LaTeX2e, Oldenbourg-Verlag |
| 66 |
M"unchen, 1997, ISBN 3-486-24199-0. |
| 67 |
|
| 68 |
% /smartmn.sty |