3
\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?

1

2 Answers 2

3

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

enter image description here

\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.
1

Wouldn't this be much easier?

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

enter image description here

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .