Creating an error message
If you're writing a package, say foo.sty
then
\AtBeginDocument{
\if\@ptsize1\else
\PackageError{foo}
{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}
\expandafter\@@end
\fi}
will do.
If you're using one of the standard document classes (article
, book
or report
), the macro \@ptsize
contains 1
if you're using 11pt
:
\documentclass[12pt]{article}
\makeatletter
\AtBeginDocument{%
\newcommand{\@ptsizetest}{1}% Equivalent to 11pt for a document class option.
\ifx\@ptsizetest\@ptsize\relax\else
\@latex@error
{You need to use 11pt font size}% Error message
{Add this as a document class option [11pt]}% Help text
\fi%
}
\makeatother
\begin{document}
Test document
\end{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.