4

What is \f@size?

Why doesn't \convertto{\f@size bp}{pt} work?

Microsoft Word uses big points to measure fonts according to a comment to this answer: https://tex.stackexchange.com/a/274609/13552

I went about converting the points to big points in the most logical way I could think of, using \convertto{bp}{1pt} to convert 1pt into bp.

Code

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[margin=2cm]{geometry}
\usepackage{xparse} % For \NewDocumentCommand (LaTeX3)
\makeatletter
\NewDocumentCommand\thefontsizePoint{m}{{#1 The current font size is: \f@size pt\hfill{\string#1}}\par}
\NewDocumentCommand\thefontsizeBigPoint{m}{{#1 The current font size is: \convertto{bp}{\f@size pt} bp\hfill{\string#1}}\par}
\makeatother

\makeatletter
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1}
\makeatother

\NewDocumentCommand{\fontsizes}{m}{%
    \begingroup
    #1
    \offinterlineskip
    \setlength{\lineskip}{4pt}
    \thefontsizeBigPoint\tiny
    \thefontsizeBigPoint\scriptsize
    \thefontsizeBigPoint\footnotesize
    \thefontsizeBigPoint\small
    \thefontsizeBigPoint\normalsize
    \thefontsizeBigPoint\large
    \thefontsizeBigPoint\Large
    \thefontsizeBigPoint\LARGE
    \thefontsizeBigPoint\huge
    \thefontsizeBigPoint\Huge
    \endgroup
    \begingroup
    \offinterlineskip
    \setlength{\lineskip}{4pt}
    \thefontsizeBigPoint\tiny
    \thefontsizePoint\scriptsize
    \thefontsizePoint\footnotesize
    \thefontsizePoint\small
    \thefontsizePoint\normalsize
    \thefontsizePoint\large
    \thefontsizePoint\Large
    \thefontsizePoint\LARGE
    \thefontsizePoint\huge
    \thefontsizePoint\Huge
    \endgroup
}%

\begin{document}
\fontsizes{}
\end{document}

Related Questions

Updated Code that David Carlisle's Answer Implies

Hopefully this is correct:

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage[margin=2cm]{geometry}
\usepackage{xparse} % For \NewDocumentCommand (LaTeX3)
\setlength{\parindent}{0pt}
\makeatletter
\NewDocumentCommand\thefontsizeBigPoint{m}{{#1 Current font size: \f@size\ pt (1/72.27 in)\hfill{\string#1}}\par}
\ExplSyntaxOn
\NewDocumentCommand\thefontsizePoint{m}{{#1 Current~font~size:~\dim_to_decimal_in_unit:nn { \f@size bp }{ 1 pt }~bp~(1/72~in)\hfill{\string#1}}\par}
\ExplSyntaxOff
\makeatother
\NewDocumentCommand{\fontsizes}{m}{%
\textbf{\TeX\ Point}

(1 pt in TeX) equals 1/72.27 in (= 2540/7227 mm ≈ 0.35145980351 mm) % https://tex.stackexchange.com/questions/21758/globally-redefining-1-pt-to-1-72-in-postscript-point-and-other-similar-changes
\bigskip

    \begingroup
    #1
    \offinterlineskip
    \setlength{\lineskip}{4pt}
    \thefontsizeBigPoint\tiny
    \thefontsizeBigPoint\scriptsize
    \thefontsizeBigPoint\footnotesize
    \thefontsizeBigPoint\small
    \thefontsizeBigPoint\normalsize
    \thefontsizeBigPoint\large
    \thefontsizeBigPoint\Large
    \thefontsizeBigPoint\LARGE
    \thefontsizeBigPoint\huge
    \thefontsizeBigPoint\Huge
    \endgroup

\bigskip\textbf{PostScript Point}

(1 bp in TeX) equals 1/72 in (= 127/360 mm = 0.352(7) mm). It is commonly used unit in DTP nowadays. % https://tex.stackexchange.com/questions/21758/globally-redefining-1-pt-to-1-72-in-postscript-point-and-other-similar-changes
\bigskip

    \begingroup
    \offinterlineskip
    \setlength{\lineskip}{4pt}
    \thefontsizePoint\tiny
    \thefontsizePoint\scriptsize
    \thefontsizePoint\footnotesize
    \thefontsizePoint\small
    \thefontsizePoint\normalsize
    \thefontsizePoint\large
    \thefontsizePoint\Large
    \thefontsizePoint\LARGE
    \thefontsizePoint\huge
    \thefontsizePoint\Huge
    \endgroup
}%

\begin{document}
\thispagestyle{empty}
\fontsizes{}
\end{document}

enter image description here

  • 1
    See source2e for \f@size ;-) – user31729 Nov 2 '15 at 8:52
  • 2
    The comment that you reference doesn't say that TeX uses bp to measure fonts. – David Carlisle Nov 2 '15 at 8:54
  • 1
    @macmadness86 Microsoft word, PostScript, PDF, CSS, SVG all use the same (PostScript) definition of the "point" unit. TeX is the only one that uses the definition that TeX uses (although it is numerically closer to the traditional printers point) – David Carlisle Nov 2 '15 at 9:00
  • 1
    Since 72/72.27 = 0.99626 (approximately), if you want in Word what would be a 10pt font in TeX, just ask for 9.9626 (bp). It's just as simple as a conversion factor. Even if I were a Word user, I wouldn't bother about the difference. – egreg Nov 2 '15 at 9:04
  • 1
    @macmadness86 for that use you don't need conversion just use bp when setting up your class. – David Carlisle Nov 2 '15 at 14:30
5

\show will stop tex (as if for an error message) and show the meaning of any command.

\makeatletter
\show\f@size

Produces

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

\f@size is the current nominal font size, in pt (not bp).

The posted code produces the error

! Undefined control sequence.
\thefontsizePoint ...ent font size is: \convertto 

and you give no indication of its intended behaviour, so hard to comment on that.


Since you are using expl3 anyway you can use its functions to convert between units eg

\dim_to_decimal_in_unit:nn { 1bp } { 1mm }

will show 1bp in mm

see texdoc interface3 page 85

  • Sorry about the \convertto macro. I forgot to include it in my code. I fixed that. The expl3 way works: see updated question. Just out of curiousity, how would I do it in LaTeX2e? I suppose with \convertto. – Jonathan Komar Nov 2 '15 at 13:01
  • 1
    @macmadness86 I probably wouldn't use that macro, just multiply by 0.99626 – David Carlisle Nov 2 '15 at 13:09

Your Answer

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

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