diff options
Diffstat (limited to 'macros/latex/contrib/ncctools/source/extdash.dtx')
-rw-r--r-- | macros/latex/contrib/ncctools/source/extdash.dtx | 329 |
1 files changed, 329 insertions, 0 deletions
diff --git a/macros/latex/contrib/ncctools/source/extdash.dtx b/macros/latex/contrib/ncctools/source/extdash.dtx new file mode 100644 index 0000000000..597ef17cd7 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/extdash.dtx @@ -0,0 +1,329 @@ +% \iffalse +%% +%% File: extdash.dtx Copyright (C) 1998-2018 by Alexander I. Rozhenko +%% +%<package>\NeedsTeXFormat{LaTeX2e} +%<package>\ProvidesPackage{extdash} +%<package> [2018/06/24 v1.3 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} +% \changes{v1.3){2018/06/24}{Add more em-dash configuring options by request from Frank Mittelbach} +% +%<*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| occurs, 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). Sometimes the line break immediately after +% the dash is inadmissible. To avoid this, you can write +% \begin{center} +% |something\Hyphdash* something|\quad or easier\quad +% |something\=/something| +% \end{center} +% (the last case is also a shortcut). An example is the word +% \emph{$L$-approximation} which can't be broken at the dash.\pagebreak +% +% \DescribeMacro{\Endash} +% \DescribeMacro{\Endash*} +% Analogously, you can use |\Endash| command (and its star version) to join +% words with \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 nonbreakable elastic space. All these commands have +% shortcuts +% \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 and German +% typesetting rules. To decrease its length to the required one, you can +% use this package with |shortemdash| option +% (the |cyremdash| option is also supported for compatibility with the previous +% version). +% +% Note: Some more options are available from the version 1.3. They control +% the spacing around |\Emdash| and the breaking strategy to be applied +% before it. +% +% \section{Package Options} +% +% \subsection{Shortcuts} +% +% \begin{center} +% |\usepackage[shortcuts]{extdash}| +% \end{center} +% +% The |shortcuts| 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. +% +% \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.} +% +% \subsection{Breaks before em-dash} +% +% All dash commands defined in this package disallow line breaks before a dash. +% For em-dash this rule can be changed. To allow breaks before a em-dash, please +% use the option +% +% \begin{center} +% |\usepackage[allowbreakbefore]{extdash}| +% \end{center} +% +% \subsection{Shorter em-dash} +% +% \begin{center} +% |\usepackage[shortemdash]{extdash}| +% \end{center} +% +% This option redefines |\Emdash| to be shorter than the standard +% em-dash (0.8~em). +% +% \subsection{Spaces around em-dash} +% +% By default, the half-space is inserted before and after em-dash. +% This behavior can be changed with option +% +% \begin{center} +% |\usepackage[wordspacearound]{extdash}| +% \end{center} +% +% \noindent or +% +% \begin{center} +% |\usepackage[nospacearound]{extdash}| +% \end{center} +% +% The first option provides interword spaces around em-dash and the +% last one removes spaces around em-dash. Of course, these two +% options are mutually exclusive. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \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{\EXD@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@nobreak} +% \begin{macro}{\EXD@embreakbefore} +% \begin{macro}{\EXD@spacecalc} +% \begin{macro}{\EXD@space} +% and then the basic commands +% \begin{macrocode} +\def\EXD@nobreak{\ifvmode\leavevmode\else\nobreak\fi} +\def\EXD@dash#1{% + \EXD@nobreak\hbox{#1}\EXD@break\hskip\z@skip \ignorespaces +} +\def\EXD@emnobreak{\nobreak} +\def\EXD@emd@sh{% + \ifvmode + \leavevmode\EXD@emdash\nobreak\hskip.35em + \else + \unskip\EXD@emnobreak \@tempcnta\m@ne + \EXD@space \EXD@emdash \EXD@break \EXD@space + \fi \ignorespaces +} +\DeclareOption{allowbreakbefore}{% + \let\EXD@emnobreak\@empty +} +% \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. +% +% The meaning of negative and positive values of |\@tempcnta| +% is redefined with |wordspacearound| and |nospacearound| options. +% \begin{macrocode} +\def\EXD@spacecalc{% + \edef\@tempa{% + \ifnum\@tempcnta<\z@ .4\else \ifnum \@tempcnta=\z@ .5\else .6\fi\fi + }% + \def\@tempb{.5}% +} +\def\EXD@space{% + \EXD@spacecalc + \hskip \@tempa\fontdimen2\font \@plus \@tempb\fontdimen3\font + \@minus \@tempa\fontdimen4\font + \@tempcnta -\@tempcnta +} +\DeclareOption{wordspacearound}{% + \def\EXD@spacecalc{% + \edef\@tempa{\ifnum \@tempcnta=\z@ .5\fi}% + \let\@tempb\@tempa + } +} +\DeclareOption{nospacearound}{% + \def\EXD@spacecalc{% + \edef\@tempa{\ifnum \@tempcnta=\z@ .5\else0\fi}% + \let\@tempb\@tempa + } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \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 |shortemdash| option. +% \begin{macrocode} +\def\EXD@emdash{\hbox{---}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\DeclareOption{shortcuts}{% +% \end{macrocode} +% +% \begin{macro}{\HyphOrDash} +% \begin{macro}{\BarOrDash} +% The commands |\HyphOrDash| and |\BarOrDash| are called by |\-| and |\=| commands +% and can appear in aux file. They choose the corresponding shortcut or the original +% command saved in |\EXD@hyph| and |\EXD@bar|. +% \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} +% +% \begin{macrocode} +\DeclareOption{shortemdash}{% + \def\EXD@emdash{\hb@xt@.8\fontdimen6\font{--\hss--}} +} +\DeclareOption{cyremdash}{% + \def\EXD@emdash{\hb@xt@.8\fontdimen6\font{--\hss--}} +} +\ProcessOptions\relax +%</package> +% \end{macrocode} +% +\endinput |