% 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 --$-$, 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