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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
% \iffalse
%%
%% File: extdash.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{extdash}
%<package> [2005/01/29 v1.2 Extended Dash Package (NCC)]
%
% \changes{v1.0}{1998/12/20}{Initial version}
% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation}
% \changes{v1.2}{2005/01/29}{Change spaces surround em-dash}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{extdash}
\GetFileInfo{extdash.sty}
\begin{document}
\title{The \textsf{extdash} package\thanks{This file
has version number \fileversion, last
revised \filedate.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{extdash.dtx}
\end{document}
%</driver>
% \fi
% The package implements the commands, |\Hyphdash|, |\Endash|, and
% |\Emdash|, to control hyphenation of compound words and ordinary
% words dashed by \emph{em-dash}. Some additional commands and
% shortcuts are also introduced.
%
% \tableofcontents
%
% \section{User Interface}
%
% \DescribeMacro{\Hyphdash}
% \DescribeMacro{\Hyphdash*}
% The main purpose of the |extdash| package is to allow hyphenation
% of compound words. When the word |something-something| occur the only
% hyphenation point after the dash is available. To allow hyphenation
% of both words joint by dash you can write
% \begin{center}
% |something\Hyphdash something|\quad or easier\quad
% |something\-/something|
% \end{center}
% (the last case is available if\/ you use the package |extdash|
% with |shortcuts| option). Some times the line break immediately after
% the dash is inadmissible. To avoid it you can write
% \begin{center}
% |something\Hyphdash* something|\quad or easier\quad
% |something\=/something|
% \end{center}
% (the last case is also shortcut). An example is the word
% \emph{$L$-approximation} which can't be broken at the dash.
%
% \DescribeMacro{\Endash}
% \DescribeMacro{\Endash*}
% Analogously, you can use |\Endash| command (may be with star) to join
% words by \emph{en-dash}. Shortcuts for it are |\--| and |\==|.
%
% \DescribeMacro{\Emdash}
% \DescribeMacro{\Emdash*}
% The last case is the use of \emph{em-dash} when some glue
% before and after em-dash have to be added. The command |\Emdash| adds
% this glue, named |\Halfspace|, which natural width is equal to the
% \DescribeMacro{\Halfspace}
% \DescribeMacro{\Halfspace*}
% half of the ordinary interword space. The |\Halfspace| command
% produces the \emph{elastic} horizontal space and its |*|-form
% produces the unbreakable elastic space. All these commands have
% shortcuts, named
% \begin{center}
% |\---|\qquad |\===|\qquad |\-,|\qquad |\=,|
% \end{center}
% Note, that |\Emdash| command removes extra space before and after it.
% When |\Emdash| appears at the beginning of a paragraph (the direct
% speech) the space after it will be rigid and unbreakable.
%
% The standard em-dash is longer that it is required by Russian
% typesetting rules. To decrease its length to required one you have
% to use |extdash| package with |cyremdash| option.
%
% \section{The Package Options}
%
% The |extdash| package provides two options, |shortcuts| and
% |cyremdash|:
% \begin{center}
% |\usepackage[shortcuts,cyremdash]{extdash}|
% \end{center}
%
% First option redefines \LaTeX{} commands |\-| and |\=| in
% such a way to recognize shortcut sequences. If\/ no shortcut
% recognized the corresponding original command will be called.
% In other words, when no shortcut recognized the command |\-|
% sets extra hyphenation point and |\=| means the accent command.
%
% The last option redefines |\Emdash| to be shorter than the standard
% em-dash.
%
% \section{The Shortcuts Table}
%
% \begin{center}
% \begin{tabular}{l@{\qquad}l@{\qquad\qquad}l@{\qquad}l}
% Command & Shortcut & Command & Shortcut \\
% \cs{Hyphdash} & \cs{-/} & \cs{Hyphdash*} & \cs{=/} \\
% \cs{Endash} & \cs{--} & \cs{Endash*} & \cs{==} \\
% \cs{Emdash} & \cs{---} & \cs{Emdash*} & \cs{===} \\
% \cs{Halfspace}& \cs{-,} & \cs{Halfspace*}& \cs{=,}
% \end{tabular}
% \end{center}
%
% \emph{All described commands and shortcuts are robust.}
%
% \StopEventually{}
%
% \section{The Basic Implementation Part}
%
% \begin{macro}{\EXD@test}
% \begin{macro}{\EXD@break}
% First we implement the command, |\EXD@test|. It recognizes the
% star after the command, sets |\EXD@break| command to be equal
% to |\nobreak| if\/ star is found or |\@empty| if\/ not, and calls
% its parameter.
% \begin{macrocode}
%<*package>
\def\EXD@test#1{%
\@ifstar{\let\EXD@break\nobreak #1}{\let\EXD@break\@empty #1}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\Hyphdash}
% \begin{macro}{\Endash}
% \begin{macro}{\Emdash}
% \begin{macro}{\Halfspace}
% Now we declare user's level commands
% \begin{macrocode}
\DeclareRobustCommand{\Hyphdash}{\EXD@test{\EXD@dash-}}
\DeclareRobustCommand{\Endash}{\EXD@test{\EXD@dash{--}}}
\DeclareRobustCommand{\Emdash}{\EXD@test{\EXD@emd@sh}}
\DeclareRobustCommand{\Halfspace}{\@tempcnta\z@
\@ifstar{\nobreak\EXD@space\ignorespaces}{\EXD@space\ignorespaces}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \begin{macro}{\EXD@dash}
% \begin{macro}{\EXD@emd@sh}
% \begin{macro}{\EXD@space}
% and then the basic commands
% \begin{macrocode}
\def\EXD@dash#1{%
\nobreak\leavevmode\hbox{#1}\EXD@break\hskip\z@skip \ignorespaces
}
\def\EXD@emd@sh{%
\ifvmode
\EXD@emdash\nobreak\hskip.35em
\else
\unskip\nobreak\@tempcnta\m@ne
\EXD@space \EXD@emdash \EXD@break \EXD@space
\fi \ignorespaces
}
% \end{macrocode}
% The |\@tempcnta| specifies the width of half-space. It can have
% the following values: |-1|, |0|, or |+1|. The negative value
% means using the space before em-dash (the space is narrow at this point),
% zero value means an ordinary half space, and the positive value
% means a half-space after em-dash (the space is wider at this point).
% This trick compensates a visual effect of wider space before an em-dash
% especially if the punctuation mark goes before.
% \begin{macrocode}
\def\EXD@space{%
\edef\@tempa{%
\ifnum\@tempcnta<\z@ .4\else \ifnum \@tempcnta=\z@ .5\else .6\fi\fi
}%
\hskip \@tempa\fontdimen2\font \@plus .5\fontdimen3\font
\@minus \@tempa\fontdimen4\font
\@tempcnta -\@tempcnta
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\EXD@emdash}
% The last basic command is the default \emph{em-dash}. It could be
% redefined later in |cyremdash| option.
% \begin{macrocode}
\def\EXD@emdash{\leavevmode\hbox{---}}
% \end{macrocode}
% \end{macro}
%
% \section{Shortcuts}
%
% \begin{macrocode}
\DeclareOption{shortcuts}{%
% \end{macrocode}
%
% \begin{macro}{\HyphOrDash}
% \begin{macro}{\BarOrDash}
% The commands |\HyphOrDash| and |\BarOrDash| will be called by |\-| and
% |\=| commands. They choose the corresponding shortcut or the original
% commands saved in |\EXD@hyph| and |\EXD@dash|.
% \begin{macrocode}
\DeclareRobustCommand{\HyphOrDash}{%
\let\EXD@break\@empty
\@ifnextchar/{\EXD@d@sh}{%
\@ifnextchar-{\EXD@hdash}{%
\@ifnextchar,{\EXD@sp@ce}{\EXD@hyph}%
}%
}%
}
\DeclareRobustCommand{\BarOrDash}{%
\let\EXD@break\nobreak
\@ifnextchar/{\EXD@d@sh}{%
\@ifnextchar={\EXD@bdash}{%
\@ifnextchar,{\nobreak\EXD@sp@ce}{\EXD@bar}%
}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% Shortcuts:
% \begin{macrocode}
\def\EXD@d@sh/{\EXD@dash-}
\def\EXD@sp@ce,{\EXD@space}
\def\EXD@hdash-{\@ifnextchar-{\EXD@hhdash}{\EXD@dash{--}}}
\def\EXD@bdash={\@ifnextchar={\EXD@bbdash}{\EXD@dash{--}}}
\def\EXD@hhdash-{\EXD@emd@sh}
\def\EXD@bbdash={\EXD@emd@sh}
% \end{macrocode}
%
% We turn on the shortcuts mechanism at the beginning of the document to
% avoid conflict with |fontenc| package which redefines accents.
% \begin{macrocode}
\AtBeginDocument{%
\let\EXD@hyph\- \let\@dischyph\HyphOrDash \let\-\@dischyph
\let\EXD@bar\= \let\@acciii\BarOrDash \let\=\@acciii
}
}
% \end{macrocode}
%
% \section{Cyrillic Em-dash}
%
% \begin{macrocode}
\DeclareOption{cyremdash}{%
\def\EXD@emdash{\leavevmode\hb@xt@.8\fontdimen6\font{--\hss--}}
}
\ProcessOptions\relax
%</package>
% \end{macrocode}
%
\endinput
|