[texhax] Last char of a string

Uwe Lueck uwe.lueck at web.de
Sun Jul 10 18:38:07 CEST 2011

"Uwe Lueck" uwe.lueck at web.de[mailto:uwe.lueck at web.de] wrote 07.07.2011 21:58:49:
> In any case, (a) the original question was about *any* punctuation,
> which may as well be a question mark, (b) some macros such as
> \section need to be modified. The conceptually most straightforward
> way doing this is defining some \extramacro and applying it about as
>    \let\wasSection\Section
>    \renewcommand\Section[1]{\wasSection{\extramacro{#1}}}
> or 
>    \renewcommand\Section[1]{\wasSection{#1\extramacro}}
> The first version was just to cover Paul's approach. The second may be
> more straightforward and refers to Donald's idea from January 2010,
> about as
>    \newcommand\extramacro{\ifnum\spacefactor>1000 \else.\fi}
> A better name for \extramacro then would be something like \ensurepunct.
> Something like this is in some theorem packages too, maybe even amsthm.

Considering that in a Canadian Journal most articles are English
and some articles may be in French (European point of view),
the latter articles may use \frenchspacing. Then the version
\extramacro{...} or \ensurepunct{...} may be better.
This macro could add 1 to the \sfcode of dots etc. before typesetting
and perform the final test and addition (\ifnum\spacefactor...) after typesetting.

Instead of referring to some \wasSection, \section etc. could be redefined
by modifying their definitions through \@startsection,
its sixth parameter should be a new one-parameter macro like


However, punctuation may be missing in the TOC this way.
You may prefer this (when there are those filling dots anyway),
or instead of the above redefine latex.ltx's \@sect.



More information about the texhax mailing list