Automatically capitalize first letter of first word in a new sentence in LaTeX

后端 未结 3 989
情书的邮戳
情书的邮戳 2021-02-06 01:06

I know one of LaTeX\'s bragging points is that it doesn\'t have this Microsoftish behavior. Nevertheless, it\'s sometimes useful.

LaTeX already adds an extra space after

3条回答
  •  春和景丽
    2021-02-06 01:52

    ages ago there was discussion of this idea on comp.text.tex, and the general conclusion was you can't do it satisfactorily. satisfactory, in my book, involves not making characters active, but i can't see how that could work at all.

    personally, i would want to make space active, and have it then look at \spacefactor and \MakeUppercase the following character if the factor is 3000.

    something like

    \catcode\ \active % latex already has a saved space character -- \space
    \def {\ifhmode% \spacefactor is invalid
    % (or something) in vertical mode
    \ifnum\spacefactor<3000\else% note: with space active,
    % even cs-ended lines need %-termination
    \expandafter\gobbleandupper\fi}%
    \def\gobbleandupper#1{\def\tempa{#1}\def\tempb{ }%
    \ifx\tempa\tempb% can''t indent the code, either :-(
    % here, we have another space
    \expandafter\gobbleandupper% try again
    \else\space% insert a "real" space to soak up the
    % space factor
    \expandafter\MakeUppercase\fi}%
    

    this doesn't really do the job -- there are enough loose ends to knit a fairisle jumper. for example, given that we can't rely on \everypar in latex, how do you uppercase the first letter of a paragraph?

    no ... however much it hurts (which is why i avoid unnecessary key operations) we need to type latex "properly" :-(

提交回复
热议问题