[texhax] How I do This ? ["autocorrect"]

Uwe Lueck uwe.lueck at web.de
Wed Nov 15 14:29:22 CET 2006


At 00:12 14.11.06, wa2n wrote:
> When I type for example. "TypeSomethingHere" can I have the result is
> "Type Something Here"
> 
> The point here is can I use Latex to autocorrect ?
> Adding space after have character following with Caps ?
> or doing something that similiar with that ?

Nice question. 

I doubt that this can be done with LaTeX only. 
I know a way doing it with TeX -- see below -- 
and some other people reading this mailing list 
will know well how to do this. 
One running gag is "making ... characters active"!. 

Next time, please indicate in your subject line 
what kind of problem you are concerned with. 
Please tell something more than that you need help. 

Best, 

  Uwe. 



\documentclass[12pt]{article}

\begin{document}

\newcommand{\ensureinterwordspace}{% 
  \ifhmode \ifdim\lastskip>0pt \else \space \fi \fi}
%% <- Sometimes this must be overridden. 
%%    Use the following command for this. 
%%    Place it so that it is executed immediately 
%%    before \ensureinterwordspace is expanded. 
\newcommand{\nopleasenointerwordspace}{% 
  \ifhmode \nobreak\hskip1sp \fi}
\let\thecapitala=A \catcode`\A=\active 
  \defA{\ensureinterwordspace\thecapitala}
\let\thecapitalb=B \catcode`\B=\active 
  \defB{\ensureinterwordspace\thecapitalb}
%% <- So please note: there are two lowercase occurrences 
%%    and three uppercase occurences that must be changed 
%%    for each letter. One might render this more comfortable 
%%    by some \RefineCharacter macros, yet this is so difficult 
%%    that you wouldn't understand it (without TeXpertise). 
%%    Some silent readers of the list probably can do this 
%%    more elegantly. 
%%    And note: after doing this, you can't define macros 
%%    whose names contain uppercase characters. Indeed this 
%%    fact makes the procedure so difficult (using lowercase 
%%    letters for storing uppercase letters). 

X\par AB

\end{document}



More information about the texhax mailing list