6

I want to know how to throw a warning when latex reach to a certain point.

For instance:

\switch [\exp1]
\case{{case 0}}
        %do whatever
\case{{case 1}}
        %do whatever
\otherwise
        %throw warning
\endswitch

Is it possible to do it?

Vebjorn
  • 1,778

2 Answers2

9

LaTeX provides warnings, which are printed to the console/.log file, both with including the current line number and without.

A class has:

\ClassWarning{<class name>}{<message>}
\ClassWarningNoLine{<class name>}{<message>}

A package has:

\PackageWarning{<package name>}{<message>}
\PackageWarningNoLine{<package name>}{<message>}

LaTeX uses:

\@latex@warning{<message>}
\@latex@warning@no@line{<message>}

The documentation can be found in "LaTeX2e for class and package writers" (texdoc clsguide).

Heiko Oberdiek
  • 271,626
2

TeX (in all formats) provides messages, which are printed to the console/.log file.

\wlog{text}   % prints expanded text to log only, CR added

You can define \def\wterm{\immediate \write16 } and then:

\wterm{text}  % prints expanded text to terminal and to the log, CR added

There is \message primitive:

 \message{text} % prints expanded text to terminal and to the log, no CR added

Note that \the\inputlineno expands to the current line number of the input file.

wipet
  • 74,238