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?

Colas
  • 6,772
  • 4
  • 46
  • 96

2 Answers2

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.
Werner
  • 603,163
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 ...

Sverre
  • 20,729
  • 1
    \textheight = 1564.90157mm = 156.490157cm !! Possibly there is inconsistency between recent l3 packages and lengthconvert.sty. – Akira Kakuto Oct 02 '15 at 13:44
  • @AkiraKakuto I didn't even look at what the number said. This is worth a new question, I think. – Sverre Oct 03 '15 at 09:37
  • New question opened at http://tex.stackexchange.com/questions/270857/converting-lengths-with-lengthconvert-and-l3fp – Sverre Oct 03 '15 at 09:46