summaryrefslogtreecommitdiff
path: root/info/challenges/aro-bend/exercise.015
blob: 5f39444699d0a81b7d766f08d881a060e44bc427 (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
Date: 05 Nov 1993 16:34:28 -0500 (EST)
From: Michael Downes <MJD@MATH.AMS.ORG>
Subject: Around the Bend #15
To: info-tex@shsu.edu
X-ListName: TeX-Related Network Discussion List <INFO-TeX@SHSU.edu>

========================================================================
*** Exercise 15
(a) Write a macro \trimspace that takes another macro as its argument and
removes a trailing space from the replacement text of the macro, if one
is present, and otherwise leaves it unchanged.

(b) Write a macro \trimspaces that removes a leading space, if
present, and then calls \trimspace to remove a trailing space.

========================================================================

Motivation: If a user inadvertently includes an extra space
in a text argument, such as a section heading:

  \section{Title of the section }

then you must usually take care to remove the space when typesetting
the text. The simple way is to perform an \unskip at the end (if the
text is immediately followed by \par, the \unskip operation is
built-in) and an \ignorespaces at the beginning, but various
complications can arise, so it would be preferable to be able to apply
a \trimspaces function when an argument is first read, and then have
the information in proper form for all subsequent uses.

Send answers to the address below. A summary will be posted
November 23, 1993 or thereabouts.

Michael Downes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mjd@math.ams.org (Internet) ASCII 32--54,55--126: !"#$%&'()*+,-./0123456
789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~