Hello Don,

how about the following:

        \def\title#1{\def\thetitle{#1}\ifx\thetitle\empty
\else{\centerline #1}\fi}

This works as follows: If #1 is empty, so is \thetitle. \ifx compares
whether macro definitions are identical, and in this case the \thetitle
definition equals the \empty macro definition, thus the \ifx will skip
the \else section. (Of course the \thetitle control sequence shouldn't
be used anywhere else.)

The following is easier:

        \def\title#1{\ifx\relax#1\relax \else{\centerline #1}\fi}

If #1 is empty, the \ifx finds \relax\relax, thus is true and skips the
\else section. If #1 is not empty, the first \relax won't match the
first element of #1, thus the rest of #1 will be skipped and the \else
section gets executed. However, this construct assumes that #1 doesn't
begin with \relax and that it doesn't contain unmatched \if constructs.

Best regards,

Rainer

> ----------
> Von:  [EMAIL PROTECTED][SMTP:[EMAIL PROTECTED]]
> Gesendet:     Sonntag, 15. November 1998 08:35
> An:   [EMAIL PROTECTED]
> Betreff:      TeX is impossible to understand
> 
> I still can't figure out how to make my \titles macro do what I want.
> 
> I have tried something like
> 
> \def\title#1{\if{#1}\empty\relax\else{\centerline #1}\fi}
> 
> If I say
> 
> \title{This is the tile}
> 
> I want it to print the title, but if I say
> 
> \title{}
> 
> I want it to do absolutely nothing.  The problem is that with a 
> 0-length argument like this, it still fails the \if test, moves past 
> the \else, and puts in a box which seems to takes up vertical space. 
> 
> Is there any logical test I can use for a 0-length argument?  I've 
> tried a zillion other combinations with \if, \ifx, with and without 
> {}, but I still haven't found any that pass the test. I can't even 
> find any that pass a comparison test with a non-blank argument unless 
> I remove the parentheses, e.g. if #1 is x, then \ifx#1x is true but 
> \ifx{#1}x and \ifx{#1}{x} are both false.  And as we saw before, 
> removing the parentheses defeats the whole process, because then the 
> test is true if #1 starts with any repeated character.
> 
> :-(
> 
> --Don Simons
> 
> 
> 
>  
> 

Reply via email to