Is there a way to create my own error message that is given if the main font size isn't set to 11pt and then the compilation of the document begin stopped?


I'm trying to write a package, and I use:

\documentclass{scrreprt}%or scrbook or scrartcl

  • 1
    Isn't it easier to just set the font size, since you want to stop the compilation if it is something else? Sep 26, 2012 at 21:17

2 Answers 2


If you're writing a package, say foo.sty then

      {Illegal font size option detected.\MessageBreak
       This is a fatal error, I'll stop the run}
      {You have specified a point size different from\MessageBreak
       the unique size this package supports, which is 11pt.\MessageBreak
       Correct your input file}

will do.

  • if could help, I have updated my question. Another thing, I haven't understand why I need to ensure that the 11pt option is correctly passed to the main class. And exactly where I must put that code. Thanks.
    – Aurelius
    Sep 26, 2012 at 22:01
  • @FormlessCloud The code should be in your package. I've removed the references to a class.
    – egreg
    Sep 26, 2012 at 22:10
  • Sure, but I was referring to the deleted code: \LoadClassWithOptions...
    – Aurelius
    Sep 26, 2012 at 22:14
  • @FormlessCloud Since you're not writing a class, that code means nothing.
    – egreg
    Sep 26, 2012 at 22:18
  • Ok thanks, it was only to know something more.
    – Aurelius
    Sep 26, 2012 at 22:28

If you're using one of the standard document classes (article, book or report), the macro \@ptsize contains 1 if you're using 11pt:

  \newcommand{\@ptsizetest}{1}% Equivalent to 11pt for a document class option.
      {You need to use 11pt font size}% Error message
      {Add this as a document class option [11pt]}% Help text
Test document

This creates the error

LaTeX Error: You need to use 11pt font size.

If you're using other packages that define the font size, some more work is required.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .