Date: 05 Nov 1993 16:34:28 -0500 (EST) From: Michael Downes Subject: Around the Bend #15 To: info-tex@shsu.edu X-ListName: TeX-Related Network Discussion List ======================================================================== *** 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{|}~