summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ncctools/source/nccstretch.dtx
blob: f4d53ea7e32daaed1c565a008af8c2c43c52d759 (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
69
70
71
72
73
74
75
% \iffalse
%%
%% File: nccstretch.dtx Copyright (C) 2004 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{nccstretch}
%<package>         [2004/11/30 v1.0 Text Stretch Package (NCC)]
%
% \changes{v1.0}{2004/11/30}{This version was uploaded to CTAN}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{nccstretch}
\GetFileInfo{nccstretch.sty}
\begin{document}
\title{The \textsf{nccstretch} package\thanks{This file
        has version number \fileversion, last
        revised \filedate.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{nccstretch.dtx}
\end{document}
%</driver>
% \fi
% \section{User Interface}
%
% \DescribeMacro{\stretchwith}
% The package implements the command
% \begin{quote}
% |\stretchwith|\marg{foo}\marg{text}
% \end{quote}
% that stretches the \meta{text} parameter inserting the
% \meta{foo} sequence between every pair of neighbour tokens of
% the \meta{text}. Spaces in the text are ignored. So, to save
% a space, you need to insert a backslash before it or enclose
% a space in braces. If you do not want to insert \meta{foo}
% between some tokens, enclose them in braces. While stretching,
% all first-level braces are removed. The examples below
% show some use cases (we delimit the results with rules to show
% exactly how the command works):
% \begin{center}\small%
% \newcommand*\ruled[1]{\rule{.4pt}{2ex}#1\rule{.4pt}{2ex}}%
% \begin{tabular}{@{}l@{\qquad}l@{}}
% \textbf{Command} & \textbf{Result}\\
% |\stretchwith{\,}{Proof\ of\ Theorem\ 1}| &
% \ruled{\stretchwith{\,}{Proof\ of\ Theorem\ 1}}\\
% |\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}| &
% \ruled{\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}}\\
% |\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}| &
% \ruled{\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}}
% \end{tabular}
% \end{center}
% \StopEventually{}
%
% \section{The Implementation}
% \begin{macro}{\stretchwith}
% The command is implemented using |\@tfor| cycle.
% The |\@tempa| command contains a sequence to be inserted
% before the next token. It is set to |\relax| before the
% cycle and is set to \meta{foo} after every inserted token.
% This trick allows insert \meta{foo} \textbf{between}
% neighbour tokens only.
%    \begin{macrocode}
%<*package>
\newcommand*\stretchwith[2]{%
  \let\@tempa\relax
  \def\@tempb{#1}%
  \@tfor\@tempc:=#2\do {\@tempa \@tempc \let\@tempa\@tempb}%
}
%</package>
%    \end{macrocode}
% \end{macro}
\endinput