# Tag Info

1

When I first got in contact with LaTeX, I bought Lamport’s LaTeX: A Document Preparation System, but, alas, I found it too superficial and didn’t understand many (even basic) things. So, as I later took notice that all started with Knuth’s TeX, I felt that it might be the logical way to begin with looking at TeX. In consequence I bought Knuth’s The TeXbook, ...

3

My solution redefines \newif macro. The new \newif\iffoo declares \iffoo and \ifnotfoo testing macros and (as usually) \footrue and \foofalse setting macros. Of course, no packages are needed. The testing macros are skipable in nested \if..\fi constructions. \def\sdef#1{\expandafter\def\csname#1\endcsname} ...

2


4

Having the full conditional in the argument to \ifnot is essential for the macro to work, or it cannot appear in another conditional, because TeX keeps track of \if..., \else and \fi in skipped text. Assuming the conditional \iftobe is defined, your macro should work like \ifnot{tobe}Not to be\else To be\fi Now let's try \iftrue \ifnot{tobe}Not to ...

6

Using e-TeX and assuming \escapechar is printable and not a space: \documentclass{standalone} \makeatletter \newif\if@to@be@ \def\if@not#1{% \expandafter\unless\csname \expandafter\expandafter\expandafter i% \expandafter\expandafter\expandafter f% \expandafter\@gobble\string#1\endcsname } \begin{document} \@to@be@true \if@not\@to@be@ Not ...

6

Possibly something like this? It preserves the OP's desired syntax \ifnot\tobe, while at the same time not demanding that \tobe be predefined. Additionally, for those who don't like using \tobe without defining it, it allows the alternate syntax \ifnot{tobe}, without any changes whatsoever. \documentclass{article} \makeatletter % Following 3 lines thanks ...

3

When TeX finds \TheLastWord{\thevariable} it transforms it into \xreverseit{}\thevariable•\relax (the • denotes a space token). Now the first argument to \xreverseit is empty, the second is \thevariable and the third is \relax, so TeX does \ifx\relax\relax\thevariable\expandafter\xthree\fi\xreverseit{•\thevariable}\relax Since the test returns true, ...

1

The solution by Steven is based on the fact that the parameter is processed. I show another solution here: the parameter is only scanned token by token. The solution is based on the code available at OPmac tricks www page. Only few lines are added in order to implement the actual task here. %% the code from http://petr.olsak.net/opmac-tricks-e.html#readtoks ...

3

Since counters are global quantities in LaTeX, I decided to use them to approach your problem. This doesn't give quite the answer you requested, because it prints the innermost result before it prints the outermost result in the nest. That means, for your first example, that the output is "0 1" rather than "1 0". But I'm thinking that, for what you want ...

Top 50 recent answers are included