Skip to main content
replaced http://tex.stackexchange.com/ with https://tex.stackexchange.com/
Source Link

The \if primitive tests purely on the basis of character code, with only the need to watch out for active characters:

\long\def\example#1{% \if\noexpand#1;% ... 

and so on. Alternatively, you could use \pdfstrcmp to do a string-based comparison, and therefore not worry about only grabbing a single token.

\usepackage{pdftexcmds} % For \pdf@strcmp \makeatletter \long\def\example#1{% \ifnum\pdf@strcmp{\unexpanded{#1}}{;}=\z@ % Gives 0 when TRUE ... 

(See the recent how to create switch structure comparing strings in latexhow to create switch structure comparing strings in latex for more on \pdfstrcmp.)

The \if primitive tests purely on the basis of character code, with only the need to watch out for active characters:

\long\def\example#1{% \if\noexpand#1;% ... 

and so on. Alternatively, you could use \pdfstrcmp to do a string-based comparison, and therefore not worry about only grabbing a single token.

\usepackage{pdftexcmds} % For \pdf@strcmp \makeatletter \long\def\example#1{% \ifnum\pdf@strcmp{\unexpanded{#1}}{;}=\z@ % Gives 0 when TRUE ... 

(See the recent how to create switch structure comparing strings in latex for more on \pdfstrcmp.)

The \if primitive tests purely on the basis of character code, with only the need to watch out for active characters:

\long\def\example#1{% \if\noexpand#1;% ... 

and so on. Alternatively, you could use \pdfstrcmp to do a string-based comparison, and therefore not worry about only grabbing a single token.

\usepackage{pdftexcmds} % For \pdf@strcmp \makeatletter \long\def\example#1{% \ifnum\pdf@strcmp{\unexpanded{#1}}{;}=\z@ % Gives 0 when TRUE ... 

(See the recent how to create switch structure comparing strings in latex for more on \pdfstrcmp.)

Source Link
Joseph Wright
  • 271.1k
  • 35
  • 729
  • 1.1k

The \if primitive tests purely on the basis of character code, with only the need to watch out for active characters:

\long\def\example#1{% \if\noexpand#1;% ... 

and so on. Alternatively, you could use \pdfstrcmp to do a string-based comparison, and therefore not worry about only grabbing a single token.

\usepackage{pdftexcmds} % For \pdf@strcmp \makeatletter \long\def\example#1{% \ifnum\pdf@strcmp{\unexpanded{#1}}{;}=\z@ % Gives 0 when TRUE ... 

(See the recent how to create switch structure comparing strings in latex for more on \pdfstrcmp.)