[Tugindia] capitalization of the first letter in a sentence

David Kastrup dak at gnu.org
Fri May 26 10:17:42 CEST 2006


"Krishna Mohan Gundu" <gkmohan at gmail.com> writes:

> Hello,
>
> Is it possible to detect if a macro is expanded at the beginning of a
> sentence and thereby capitalize the first letter? Say I have a macro
>
> \newcommand{\fref}[1]{figure \ref{#1}}
>
> and a sentence begins with \fref{}. In this case how do I capitalize
> the "f" in the "figure"?

\DeclareRobustcommand{\fref}[1]{\ifvmode F\else
  \ifnum\spacefactor>2000 F\else f\fi\fi igure~\ref{#1}}

But this is not particularly reliable, so you should proofread.  It
will not work with \frenchspacing, for one thing.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
UKTUG FAQ: <URL:http://www.tex.ac.uk/cgi-bin/texfaq2html>


More information about the tugindia mailing list