# How to typeout dimensions in mm?

\typeout{***This vertical space will be \the\textheight}


prints

***This vertical space will be 153.64488pt

Is it possible to print \the\textheight in mm?

• – Werner
Sep 21 '15 at 19:40

## 2 Answers

With some help from How to print a length accurately and with user-controlled rounding?, here is a way:

\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
% https://tex.stackexchange.com/a/123283/5764
\DeclareExpandableDocumentCommand { \printlengthas } { m m }
{ \dim_to_decimal_in_unit:nn {#1} { 1 #2 } #2 }
\ExplSyntaxOff
\begin{document}

\newlength{\advertwidth}
\setlength{\advertwidth}{2.5in}
\printlengthas{\advertwidth}{in}
\printlengthas{\advertwidth}{mm}

\typeout{The length \string\advertwidth\space is \printlengthas{\advertwidth}{mm}.}
\end{document}


The .log includes

The length \advertwidth is 63.50034mm.


Wouldn't this be much easier?

\documentclass{article}
\usepackage{lengthconvert}
\begin{document}
\Convert[unit = mm]{\textheight}
\end{document}


EDIT: Oh, I see, this is not a typeout ...

• \textheight = 1564.90157mm = 156.490157cm !! Possibly there is inconsistency between recent l3 packages and lengthconvert.sty. Oct 2 '15 at 13:44
• @AkiraKakuto I didn't even look at what the number said. This is worth a new question, I think. Oct 3 '15 at 9:37
• New question opened at tex.stackexchange.com/questions/270857/… Oct 3 '15 at 9:46