[texworks] New Command question from beginner

Reinhard Kotucha reinhard.kotucha at web.de
Mon Nov 26 01:23:11 CET 2012


On 2012-11-25 at 22:39:46 +0000, Philip TAYLOR wrote:

 > Schor, Robert H wrote:
 > 
 > > \newcommand{VIs}{VI\hspace{1pt}s}
 > 
 > > Is there a way to define the command so that the characters being output
 > > will ÒrespectÓ subsequent white space?  [IÕve done a quick Google
 > > search, but am new enough to TeX and LaTeX to not know what search terms
 > > to use].
 > 
 > All control words eat spaces by default (a control word consists of
 > a leading escape character followed by one or more letters).  There
 > is no simple way of avoiding this behaviour as it occurs before your
 > code has any chance to exercise control.  Therefore you have to
 > resort to workarounds such as
 > 
 > 1) Use the control word in braces :
 > 
 > 	Labview makes considerable use of {\VIs} in <whatever>
 > 
 > 2) Follow the control word with braces :
 > 
 > 	Labview makes considerable use of \VIs{} in <whatever>
 > 
 > 3) Make the control word a delimited macro :
 > 
 > 	\def \VIs.{VI\hskip 1 pt s}
 > 
 > and then use it accordingly (and consistently)
 > 
 > 	Labview makes considerable use of \VIs. in <whatever>
 > 
 > 4) Eschew mnemonic names and make use of a control symbol instead :
 > 
 > 	\def \1{VI\hskip 1 pt s}
 > 
 > 	Labview makes considerable use of \1 in <whatever>
 > 
 > 5) Give up raw TeX markup and use HTML-like markup instead :
 > 
 > 	\catcode `\< = \active
 > 	\def <#1>{\csname #1\endcsname}
 > 
 > 	Labview makes considerable use of <VIs> in <whatever>
 > 
 > Probably many more, but they may give you some ideas.  None rely
 > on intrinsic LaTeX functionality, all are Plain-TeX based.

Phil,
though your suggestions 1 and 2 are absolutely correct, I've seen that
even very experienced TeX users often forget the braces.

A very interesting LaTeX package is xspace.

 | Abstract
 |
 | \xspace should be used at the end of a macro designed to be used
 | mainly in text. It adds a space unless the macro is followed by
 | certain punctuation characters.

Try

  texdoc xspace


Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------



More information about the texworks mailing list