8

We usually point out explicitly or not normalfont size in \documentclass[11pt]{article} etc. 11pt may be absent here explicitly. Which variable contains this 11 or 10, 12pt?. I need get it in a tex-file for some \if... constructions

1
  • Recently I asked a similar question, but regarding current color instead of font size. tex.stackexchange.com/questions/146096/…, I expected that some variable would hold that information, but the answer was more complicated than just that. – alfC Nov 27 '13 at 10:28
8

You are looking for \@ptsize. It is defined by the standard document classes as 0 for the 10pt class option, as 1 for the 11pt option and as 2 for the 12pt option.

\documentclass[12pt]{article}

\makeatletter
\newcommand*{\showfontsize}{Fontsize: 1\@ptsize\,pt}
\makeatother

\begin{document}

\showfontsize

\end{document}

Here's the relevant definition in the class files:

\if@compatibility
\renewcommand\@ptsize{0}
\else
\DeclareOption{10pt}{\renewcommand\@ptsize{0}}
\fi
\DeclareOption{11pt}{\renewcommand\@ptsize{1}}
\DeclareOption{12pt}{\renewcommand\@ptsize{2}}

\@ptsize is also defined by the KOMA-Script classes (scrartcl, scrreprt, scrbook).

As pointed out by egreg: The memoir class "has \@memptsize that expands to the “real” thing (10, 11, and so on); the AMS classes have \@mainsize for the same thing. The extsizes package instead redefines \@ptsize to contain the full number."

5
  • 4
    You could note that memoir has \@memptsize that expands to the “real” thing (10, 11, and so on); the AMS classes have \@mainsize for the same thing. The extsizes package instead redefines \@ptsize to contain the full number. – egreg Nov 10 '13 at 14:01
  • After \normalsize, examine \f@size. This is a macro holding the normalfont size, without the pt. But be aware that, for historical reasons, the 11pt option sets the \f@size to 10.95 in most classes. – Dan Nov 11 '13 at 5:59
  • It seems to me that \@ptsize is not a constant in the latex-word. There are packages which change it. This is a tex-barbarism however! What purpose the latex has been created for? This is a principal point why i dislike to use packages. If one wants to be well make everything yourself – user40791 Nov 12 '13 at 12:38
  • @maximav quite right. and if you're good enough (and also a good communicator) you attract followers. and the followers do the same as you did. and so ad infinitum... – wasteofspace Nov 27 '13 at 12:15
  • as @egreg points out, the ams classes do have \@mainsize but they also have \@ptsize applied "in the usual manner". the reason for \@mainsize is that amsart also supports options [8pt] and [9pt] (not actually advertised, but created mainly for internal use), and in that context, \@ptsize=9 doesn't make any sense. (but the original use of \@ptsize is retained for historical reasons and the "appearance of compatibility". many basic latex decisions don't "scale" or adapt easily, so workarounds are necessary. please don't blame publishers for doing that.) – barbara beeton Nov 27 '13 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy