diff options
author | Karl Berry <karl@freefriends.org> | 2009-09-18 00:01:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2009-09-18 00:01:50 +0000 |
commit | 8508e50c1ba6aedbcc89f9146c9d563478dcd193 (patch) | |
tree | 52d837e4a27a8542aee93bd088209c59f9d508ae /Master/texmf-dist | |
parent | 84ea92b10d85753f2d44ae4ce9b17d4338c40603 (diff) |
new latex package trimspaces (16sep09)
git-svn-id: svn://tug.org/texlive/trunk@15352 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/trimspaces/README | 12 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/trimspaces/trimspaces.pdf | bin | 0 -> 174846 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/trimspaces/trimspaces.ins | 4 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/trimspaces/trimspaces.tex | 240 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/trimspaces/trimspaces.sty | 58 |
5 files changed, 314 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/trimspaces/README b/Master/texmf-dist/doc/latex/trimspaces/README new file mode 100644 index 00000000000..0e4e8ac9f6d --- /dev/null +++ b/Master/texmf-dist/doc/latex/trimspaces/README @@ -0,0 +1,12 @@ +______________________ +The TRIMSPACES package +v1.1 + +This package provides commands that allow you to expandably +remove spaces around a token list or remove surrounding +spaces within a macro definition. + +Will Robertson +Copyright 2009 +Released under the LaTeX Project Public License + diff --git a/Master/texmf-dist/doc/latex/trimspaces/trimspaces.pdf b/Master/texmf-dist/doc/latex/trimspaces/trimspaces.pdf Binary files differnew file mode 100644 index 00000000000..50a6a8ef9b2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/trimspaces/trimspaces.pdf diff --git a/Master/texmf-dist/source/latex/trimspaces/trimspaces.ins b/Master/texmf-dist/source/latex/trimspaces/trimspaces.ins new file mode 100644 index 00000000000..7177afc608e --- /dev/null +++ b/Master/texmf-dist/source/latex/trimspaces/trimspaces.ins @@ -0,0 +1,4 @@ +%&latex +\def\pstoolCompile{N} +\input pstool.tex +\csname @@end\endcsname diff --git a/Master/texmf-dist/source/latex/trimspaces/trimspaces.tex b/Master/texmf-dist/source/latex/trimspaces/trimspaces.tex new file mode 100644 index 00000000000..d8041d36c7b --- /dev/null +++ b/Master/texmf-dist/source/latex/trimspaces/trimspaces.tex @@ -0,0 +1,240 @@ +\RequirePackage{filecontents} +\begin{filecontents*}{README.txt} +______________________ +The TRIMSPACES package +v1.1 + +This package provides commands that allow you to expandably +remove spaces around a token list or remove surrounding +spaces within a macro definition. + +Will Robertson +Copyright 2009 +Released under the LaTeX Project Public License + +\end{filecontents*} + +\begin{filecontents}{trimspaces.sty} +\ProvidesPackage{trimspaces}[2009/09/17 v1.1 + Trim spaces around a token list] + +% Trimming surrounding spaces: +\catcode`\Q=3 +\newcommand\trim@spaces[1]{% + \romannumeral-`\q\trim@trim@\noexpand#1Q Q% +} +\long\def\trim@trim@#1 Q{\trim@trim@@#1Q} +\long\def\trim@trim@@#1Q#2{#1} +\catcode`\Q=11 + +\newcommand\trim@spaces@noexp[1]{% + \unexpanded\expandafter\expandafter\expandafter + {\trim@spaces{#1}}% +} + +\newcommand\trim@spaces@in[1]{% + \edef#1{\expandafter\trim@spaces@noexp\expandafter{#1}}% +} + +% Trimming preceding spaces: +\newcommand\trim@pre@space[1]{% + \romannumeral-`\.\expandafter\noexpand#1% +} + +\newcommand\trim@pre@space@noexp[1]{% + \unexpanded\expandafter{% + \romannumeral-`\.\expandafter\noexpand#1% + }% +} + +\newcommand\trim@pre@space@in[1]{% + \expandafter\def\expandafter#1\expandafter{% + \romannumeral-`\.\expandafter\noexpand#1% + }% +} + +% Trimming trailing space: +\catcode`\Q=3 +\newcommand\trim@post@space[1]{\trim@trim@#1Q Q} +\catcode`\Q=11 + +\newcommand\trim@post@space@noexp[1]{% + \unexpanded\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + {\trim@post@space{#1}}% +} + +\newcommand\trim@post@space@in[1]{% + \edef#1{\expandafter\trim@post@space@noexp\expandafter{#1}}% +} + +% That's it. +\end{filecontents} +%%%%%%%%%1%%%%%%%%%2%%%%%%%%%3%%%%%%%%%4%%%%%%%%%5 + + +% Conditionally compile the documentation & generate the .ins file: +\providecommand\pstoolCompile{Y} +\if\pstoolCompile N + \expandafter\endinput +\fi + + +\begin{filecontents*}{trimspaces.ins} +%&latex +\def\pstoolCompile{N} +\input pstool.tex +\csname @@end\endcsname +\end{filecontents*} + + + + +\makeatletter +\documentclass{article} +\usepackage[rm,medium]{titlesec} +\usepackage{xcolor} +\usepackage[colorlinks,linktocpage]{hyperref} +\usepackage{gmdoc} +\usepackage{gmverb} +\dekclubs +\stanzaskip=\bigskipamount +\CodeSpacesGrey + +\let\pkg\textsf + +\usepackage{trimspaces} +\usepackage[T1]{fontenc} +\usepackage{microtype} +\usepackage{lmodern} +\usepackage[sc,osf]{mathpazo} +\linespread{1.1} +\frenchspacing + +\GetFileInfo{trimspaces.sty} +\begin{document} + +\title{The \pkg{trimspaces} package} +\author{Package author: Will Robertson\\Code thanks to Morten H\o gholm} +\date{\fileversion\qquad\filedate} + +\maketitle +\tableofcontents + +\section{Use of the package} +This package provides a collection of space trimming macros for the \LaTeX\ programmer. Tools are provided to remove either preceding space, trailing space, or both from a token list or the contents of a macro. + +For an extensive discussion on this topic, see chapter fifteen of Peter Wilson's compendium of Michael Downes' `Around the Bend' exercises: +\par\centerline{\url{http://tug.ctan.org/pkg/around-the-bend}} + +The code that this package is based on, however, originates with Morten H\o gholm. Thanks! + +\subsection{Trimming spaces} +\begin{itemize} +\item \cs{trim@spaces} \marg{text}\\ +\cs{trim@pre@space} \marg{text}\\ +\cs{trim@post@space} \marg{text}\par +Fully expandable, removes spaces at the beginning and/or end of \meta{text}. + +\item \cs{trim@spaces@noexp} \marg{text}\\ +\cs{trim@pre@space@noexp} \marg{text}\\ +\cs{trim@post@space@noexp} \marg{text}\par +Variants of the above that after full expansion result in the original unexpanded text stripped of surrounding spaces. +(\textit{Requires $\varepsilon$-\TeX}.) + +\item \cs{trim@spaces@in} \meta{macro}\\ +\cs{trim@pre@space@in} \meta{macro}\\ +\cs{trim@post@space@in} \meta{macro}\par +Re-defines \meta{macro} as itself stripped of its surrounding spaces +(these commands are obviously not expandable). +\end{itemize} + +\subsection{Examples} + +Trimming surrounding spaces: +\begin{verbatim} +\def\foo{bar} +\edef\a{\trim@spaces{ a \foo ! }} +\edef\aa{\trim@spaces@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@spaces@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{verbatim} +which produces: +\begin{quote} +\makeatletter +\def\foo{bar} +\edef\a{\trim@spaces{ a \foo ! }} +\edef\aa{\trim@spaces@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@spaces@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{quote} +Only removing preceding spaces: +\begin{verbatim} +\def\foo{bar} +\edef\a{\trim@pre@space{ a \foo ! }} +\edef\aa{\trim@pre@space@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@pre@space@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{verbatim} +which produces: +\begin{quote} +\makeatletter +\def\foo{bar} +\edef\a{\trim@pre@space{ a \foo ! }} +\edef\aa{\trim@pre@space@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@pre@space@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{quote} +Only removing trailing spaces: +\begin{verbatim} +\def\foo{bar} +\edef\a{\trim@post@space{ a \foo ! }} +\edef\aa{\trim@post@space@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@post@space@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{verbatim} +which produces: +\begin{quote} +\makeatletter +\def\foo{bar} +\edef\a{\trim@post@space{ a \foo ! }} +\edef\aa{\trim@post@space@noexp{ aa \foo ! }} +\def\b{ b \foo ! } +\trim@post@space@in\b +a: [\detokenize\expandafter{\a}] \\ +aa: [\detokenize\expandafter{\aa}] \\ +b: [\detokenize\expandafter{\b}] +\end{quote} + + +\section{Package information} +The most recent publicly released version of \pkg{trimspaces} is available at \textsc{ctan}: \url{http://tug.ctan.org/pkg/trimspaces/}. Historical and developmental versions are available at GitHub: \url{http://github.com/wspr/trimspaces/}. + +While general feedback via email is welcomed, specific bugs or feature requests should be reported through the issue tracker: \url{http://github.com/wspr/trimspaces/issues}. + +\subsection{Licence} + +This package is freely modifiable and distributable under the terms and conditions of the \LaTeX\ Project Public License,\footnote{Available at the \LaTeX\ Project website: \url{http://www.latex-project.org/lppl/}} version 1.3c or greater (your choice). This work consists of the source file \texttt{\jobname.tex} and the derived files \texttt{\jobname.sty}, \texttt{\jobname.ins}, and the documentation \texttt{\jobname.pdf}. + +This work is author-maintained by \textsc{Will Robertson}. + +\section{Implementation} +\parindent=0pt +\DocInput{trimspaces.sty} + +\end{document} diff --git a/Master/texmf-dist/tex/latex/trimspaces/trimspaces.sty b/Master/texmf-dist/tex/latex/trimspaces/trimspaces.sty new file mode 100644 index 00000000000..c4b681c3bd5 --- /dev/null +++ b/Master/texmf-dist/tex/latex/trimspaces/trimspaces.sty @@ -0,0 +1,58 @@ +%% LaTeX2e file `trimspaces.sty' +%% generated by the `filecontents' environment +%% from source `trimspaces' on 2009/09/17. +%% +\ProvidesPackage{trimspaces}[2009/09/17 v1.1 + Trim spaces around a token list] + +% Trimming surrounding spaces: +\catcode`\Q=3 +\newcommand\trim@spaces[1]{% + \romannumeral-`\q\trim@trim@\noexpand#1Q Q% +} +\long\def\trim@trim@#1 Q{\trim@trim@@#1Q} +\long\def\trim@trim@@#1Q#2{#1} +\catcode`\Q=11 + +\newcommand\trim@spaces@noexp[1]{% + \unexpanded\expandafter\expandafter\expandafter + {\trim@spaces{#1}}% +} + +\newcommand\trim@spaces@in[1]{% + \edef#1{\expandafter\trim@spaces@noexp\expandafter{#1}}% +} + +% Trimming preceding spaces: +\newcommand\trim@pre@space[1]{% + \romannumeral-`\.\expandafter\noexpand#1% +} + +\newcommand\trim@pre@space@noexp[1]{% + \unexpanded\expandafter{% + \romannumeral-`\.\expandafter\noexpand#1% + }% +} + +\newcommand\trim@pre@space@in[1]{% + \expandafter\def\expandafter#1\expandafter{% + \romannumeral-`\.\expandafter\noexpand#1% + }% +} + +% Trimming trailing space: +\catcode`\Q=3 +\newcommand\trim@post@space[1]{\trim@trim@#1Q Q} +\catcode`\Q=11 + +\newcommand\trim@post@space@noexp[1]{% + \unexpanded\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter\expandafter + {\trim@post@space{#1}}% +} + +\newcommand\trim@post@space@in[1]{% + \edef#1{\expandafter\trim@post@space@noexp\expandafter{#1}}% +} + +% That's it. |