[texhax] The last character of a string

Michael Barr barr at math.mcgill.ca
Fri Jan 29 01:57:30 CET 2010


Yes, inside TeX.  Since it pertains only to a few macros, I could search 
them by hand.  An example is that I might get a paper to edit and it has 
\subjclass{...}.  If it ends with a period, then I want to set it as is. 
If it doesn't, I want to add one.  Some authors do the one and some do the 
other.  Another one is \subsection{...} whose parameter might end in a 
period, a question mark, or even an exclamation point.  Same issue.  A few 
authors use \subsubsection.  I am ambivalent about \section since the 
section headers are separated.  If it were just my own work, I could be 
consistent, but I am TeX editor for an online journal.

Michael

On Thu, 28 Jan 2010, Pierre MacKay wrote:

> On 01/28/2010 03:25 PM, Michael Barr wrote:
>>  Is there a simple way to find the last character of a string?  Assume the
>>  string is brace delimited.  What I want to do is add a period unless the
>>  string already ends in a period, question mark, or exclamation mark, but I
>>  don't see any way short of going through the string knocking off one
>>  character at a time.
>>  _______________________________________________
>>  TeX FAQ: http://www.tex.ac.uk/faq
>>  Mailing list archives: http://tug.org/pipermail/texhax/
>>  More links: http://tug.org/begin.html
>>
>>  Automated subscription management: http://tug.org/mailman/listinfo/texhax
>>  Human mailing list managers: postmaster at tug.org
>> 
> I assume that this has to be done within TeX.  Otherwise it is a function of 
> whatever editor you are using:
>
> It is a problem I often find, and I use the emacs "narrow-to-region" command. 
> Find whatever triggers the opening brace,
> save the position and then (if there are no intervening paired braces) find 
> the closing brace. Narrow to region, and then search just before the closing 
> brace.  It is very fast indeed.
>
> The need for this ability to narrow to a specific context is one of the 
> reasons for providing specific *begin* and *end* macros in many contexts, 
> rather than insisting that the context appear as a macro parameter.  The 
> LaTeX adapters of Ibycus have insisted on the macro parameter model, but in 
> Plain Tex I stick with \GK{} and \RM{} which allow a clean "narrow-to-region" 
> operation on any passage of any size.  These macros make it possible to run 
> efficiently through a long article and check the correctness of the Greek 
> without having to scroll through all the non-Greek text.
>
> Pierre MacKay
>
>


More information about the texhax mailing list