[Tex/LaTex] Get current font size as length

fontsizelengths

I understand from THIS question that the current font size can be determined.

But how can I convert this to a length value?

\documentclass[10pt,a4paper]{article}
\newlength{\mytextsize}

   %This part fails.... 
   \makeatletter
      \setlength{\mytextsize}{\f@size pt}
   \makeatother

\begin{document}
    %do something.        
\end{document}

In other words, I want to use the 10pt declared in the \documentclass{...} elsewhere.

Best Answer

What you have is the right answer:

\documentclass[10pt,a4paper]{article}
\newlength{\mytextsize}

   %This part fails....  (no it doesn't:-)
   \makeatletter
\show\f@size
      \setlength{\mytextsize}{\f@size pt}
   \makeatother

\showthe\mytextsize
\begin{document}
    %do something.        
\end{document}

which produces a log of:

> \f@size=macro:
->10.
l.6 \show\f@size

? 
> 10.0pt.
l.10 \showthe\mytextsize

Showing your length has been set to 10pt.

However note that this saves the default text size not the name of the class option. For 10pt they happen to be the same but for 11pt option the default font size is 10.95pt.