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 ;-) –  Nov 02 '15 at 08:52
  • Running your example xelatex complains about \convertto itself. Where is \convertto from? –  Nov 02 '15 at 08:54
  • 2
    The comment that you reference doesn't say that TeX uses bp to measure fonts. – David Carlisle Nov 02 '15 at 08:54
  • @DavidCarlisle Excuse me, my mistake. I had it backwards. Leave it to Microsoft Word to be the weird one and use "big points". – Jonathan Komar Nov 02 '15 at 08:56
  • 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 02 '15 at 09: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 02 '15 at 09:04
  • @ChristianHupfer I fixed the code to include \convertto. It is from http://tex.stackexchange.com/questions/8260/what-are-the-various-units-ex-em-in-pt-bp-dd-pc-expressed-in-mm – Jonathan Komar Nov 02 '15 at 10:09
  • @egreg — do you mean especially if you were a Word user, you wouldn't bother about the difference? :) – Will Robertson Nov 02 '15 at 11:48
  • @WillRobertson In Italian grammar we have “periodo ipotetico dell'irrealtà” for describing a case of conditional clause like this one. ;-) What I meant is that the difference is about 0.4% and the control I can get with a word processor is much worse with respect to TeX. So, why bother? Yes, I know: a secretary might look in the PDF file and see 9.96 points, and argue that the font is not at ten point. The objection of course is that it is at ten typographer's points and the rules didn't specify which point to use. – egreg Nov 02 '15 at 12:36
  • @egreg I am more concerned with the fact that my font sizes may be not in agreement with corporate design (which deals with fonts and sizes). As you noted before, the difference is minimal and perhaps unnoticeable, therefore irrelevant. Still, it is nice to have the ability to provide quick visual inspection for those unbelievers. My eye does not see the difference, actually. One of the things I love about LaTeX is its precision. :) – Jonathan Komar Nov 02 '15 at 14:27
  • 1
    @macmadness86 for that use you don't need conversion just use bp when setting up your class. – David Carlisle Nov 02 '15 at 14:30
  • a more insidious cause of "inequality" is not printing out a pdf file "actual size" instead of "fit to page". – barbara beeton Nov 02 '15 at 16:42
  • @barbarabeeton So true Barbara. This was really important when I created a perfectly-sized PDF for a Canon Type J Tray for DVD labels such that I did not need to use any special (annoying) software http://tex.stackexchange.com/a/223851/13552 – Jonathan Komar Nov 03 '15 at 07:27

1 Answers1

7

\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

David Carlisle
  • 757,742
  • 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 02 '15 at 13:01
  • 1
    @macmadness86 I probably wouldn't use that macro, just multiply by 0.99626 – David Carlisle Nov 02 '15 at 13:09