Tag Info

New answers tagged

2

It is intentional, but, as far as I know, there are still discussions about it. The problem appeared several years ago within amsmath, when something like \begin{align} a &= b \\ [c] &= d \end{align} was considered. With the default LaTeX setup, this triggers an error (Missing number, treated as zero), because \\ would ignore spaces when looking ...


0

Try the ifmtarg package. For instance (less any typos): ... \usepackage{ifmtarg} \makeatletter \newcommand{\isempty}[1]{% \@ifmtarg{#1}{YES}{NO}} \newcommand{\isnotempty}[1]{% \@ifnotmtarg{#1}{YES}} \makeatother ... then some results are: \isempty{} --> YES \isempty{ } --> YES \isempty{E} --> NO \isempty{ E } ...


5

Here is an alternative expandable solution: it uses no e-TeX, no TeX conditionals, no \expandafter's, no \string's. it expands in three steps in all cases (with some usual \romannumeral0 wrapper one could get it to expand in two steps), which presumably makes it reasonably fast, it is entirely based on expansion of suitably delimited macros, but the ...


10

The method of the question \bgroup \setbox0=\hbox{#1} \ifdim\wd0=0pt it is empty \else it is not empty \fi \egroup has several problems, if used for a general test: \setbox0\hbox{#1} leak color specials, when #1 contains top level \color commands, because the color macros use \aftergroup to reset the color after the current group (\hbox). This ...


6

In case you just wish to know whether the macro-argument in question consists of some tokens or doesn't consist of any token: As macro-arguments in any case are brace-balanced, Robert R. Schneck in june 2003 presented in the usenet-newsgroup comp.text.tex the idea of nesting the argument into a brace-group and then "hitting" it with \stringand then ...


3

EGreg had a nice answer on that, check http://tex.stackexchange.com/a/127506/65222 Here's the relevant part: A clever example of \if is for testing whether an argument is empty: \def\cs#1{% \if\relax\detokenize{#1}\relax The argument is empty% \else The argument #1 is non empty% \fi } It uses \detokenize which is an e-TeX feature. If ...


1

A workaround, not a recommendation, would be \makeatletter \NewDocumentEnvironment{optional} { O{first} t\@sptoken O{second} t\@sptoken O{third} } {\section{Optional}} {#1\par #3\par #5} \makeatother


6

The two settings control different behaviours. Setting -interaction=nonstopmode tells the TeX engine to run with minimal interaction with the user and as far as possible to 'go past' errors. It's therefore very useful in automation. Setting -halt-on-error tells the engine to stop processing the document at the first error, rather than trying to keep going. ...



Top 50 recent answers are included