TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I place a # symbol inside of a \PackageWarning inside of a macro definition? I tried:

\PackageWarning{package}{# or \# or \string# or \hash}

but either ## or unknown (for \hash) or Illegal parameter number in definition of \reserved@a resulted.

share|improve this question
up vote 13 down vote accepted

Actually \string# is the way to go, however you seem to use \PackageWarning as part of a macro definition so you have to double it: \string##. The macro definition of \reserved@a might happen internally in a macro you are using. Some if-macros from the LaTeX core for example store both clauses in such temporary macros.

You could also define a macro for this character which then can be used in all \PackageWarnings and other messages independent if they are in a macro definition or not.


Then use \hashchar in the message. If you want a space behind it you need to use \space explicitly.

share|improve this answer
\edef\hashchar{\string#} – egreg Oct 19 '11 at 12:39
@egreg: Indeed! Sometimes I think to complicated, even if the simply solution is right before my nose :-) – Martin Scharrer Oct 19 '11 at 12:49
@egreg: Works and has got the advantage to be usable inside and outside of another macro. +1 for this. – Stephen Oct 19 '11 at 12:59
As a side note, for LaTeX3, weve gone for letting \#` be that single hash character within messages. Same with a couple of standard special characters. – Bruno Le Floch Oct 19 '11 at 21:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.