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
- What point (pt) font size are \Large etc.?
- What are the various units (ex, em, in, pt, bp, dd, pc) expressed in mm?
- Globally redefining 1 pt to 1/72 in (PostScript point) and other similar changes
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}
Best Answer
\show
will stop tex (as if for an error message) and show the meaning of any command.Produces
\f@size
is the current nominal font size, inpt
(notbp
).The posted code produces the error
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
will show 1bp in mm
see
texdoc interface3
page 85