General ⇒ Is it possible to use only the first letters of a command ?
Is it possible to use only the first letters of a command ?
My purpose is to define new commands that help me to write ancient greek words with the simplest way. I have the following problem: I need to insert vareia(i.e. grave) to the letter o. Then it would be very easy to define a newcommand let say \vo to put the vareia accent(v) on the letter o. But the problem starts when one faces the situation to put vareia to words starting with vareia + o let say o, or, oras, orasi, orasia etc. My question is: it possible to define the \vo command such that the LaTeX would not complain with undefined command strings like \vor, \voras, \vorasi etc.(let say that there are thousands of them so it is not practice to define a new vareia command for each word) and just use the first and second letter of each such "command" string to replace o with o with a vareia on it! Also I don't like the idea to put a space after each use of \vo like \vo rasi instead of \vorasi.
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Is it possible to use only the first letters of a command ?
The question was also asked on TeX.SX and got an answer there by yo'
You can do this if the letter is not a letter. Anytime TeX reads the sequence:
<backslash><valid_nonletter>
(this is in the standard setting; "valid" means basically any printable ASCII character), then TeX interprets it as the control character and executes it, no matter whether a space follows. So you could use for instance:With `\7` defined in the preamble by:Code: Select all
gr\7a\7eal
Note that I do not consider this a good idea, but you asked for it. Also, please, do not use anything like this in files you will provide to anybody like journals, publishers, collaborators etc.Code: Select all
\let\7\t
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.