----- Original Message ----- From: "Micha Feigin" <michf-+lLcF8/[EMAIL PROTECTED]>
Newsgroups: gmane.editors.lyx.general
Sent: Wednesday, June 22, 2005 12:49 PM
Subject: Changing case of word


Is it possible in latex to automatically change the case of a word (capitalize
all/first letter)?

+++++++++++++++++++++++++++++++++++++++++++
This Mail Was Scanned By Mail-seCure System
at the Tel-Aviv University CC.


It is possible inside a text file and some other kinds.
You are looking for a "script", an automated procedure.
This works best with Windows and Cygwin; or you can
use Perl or Python for Windows which are free downloads.
This type of file manipulation is part regular expressions.
Maybe LyX can use sed, another search and replace loop method from the command line with Cygwin.

For instance here is a Perl script that will work for most sentences:

First, let's assume that the entire file is in one scalar (using $/ =
undef to read it in). Second, assume that the beginning of a
sentence needing capitalization is reliably detectable using
/((?:^|[.?!]\s+)[a-z])/ ("Either the start of the string or a period,
question mark, or exclamation point followed by one or more
spaces, followed by a lower-case character").

Then, assuming your file text is in $text, you can just do

 $text =~ s/((?:^|[.?!]\s+)[a-z])/\U$1/g­;
----------------------------------------------------------------------------

They also have some sophisticated Windows software for doing elaborate search and replace. The easier kind tends to be expensive but there is freeware also, which means reading the documentation.

I suppose you could run the first letter capitalization script on a document that was in text. And then import into Lyx, the text by line, or paragraph, whatever works best to texify. (X)Emacs can do this also but it still requires quite a bit of reading, even if you get lucky and find an elisp file already written to do what you want.

Regards, Stephen





Reply via email to