1

I am new to VTEX. How can i solve this??

\documentclass{article}
\begin{document}
\the\hsize
\end{document}

Output: 345.0 pt

but i have to write a macro to calculate hsize in mm example: \printdimen[mm]\hsize and if i take hsize 6.5in then what will be output in mm?

  • 1
    Related: http://tex.stackexchange.com/questions/22701/is-there-a-command-to-convert-cm-to-bp and http://tex.stackexchange.com/questions/8260/what-are-the-various-units-ex-em-in-pt-bp-dd-pc-expressed-in-mm/8337#8337 – Steven B. Segletes Apr 21 '15 at 14:16
  • 1
    You already received an answer to this question: http://tex.stackexchange.com/a/239660/8528 – jon Apr 21 '15 at 14:48
  • 1
    You've already asked two questions in this area, and have answers on the previous one that cover this (http://tex.stackexchange.com/questions/239647/how-can-i-print-a-length-in-centimeters-in-vtex). Closure as a dupe of your existing question is likely unless you can make a case for this one being distinct. – Joseph Wright Apr 21 '15 at 15:13

2 Answers2

5

Like this?

\documentclass{article}
\usepackage{printlen}
\begin{document}
\uselengthunit{mm}\printlength{\hsize}
\end{document}
daleif
  • 54,450
1
% arara: pdflatex

\documentclass[a4paper]{article}
\usepackage{xparse}
\usepackage{siunitx}
\usepackage{pgf}
\usepackage{mathtools}
\makeatletter
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1}
\makeatother
\newcommand*{\getlength}[3]{%
    \pgfmathsetmacro#1{#3*#2}
}
\DeclareDocumentCommand\printdimen { o m }{%
    \getlength{\tmp}{\convertto{#1}{1pt}}{#2}\SI{\tmp}{#1}
}


\begin{document}  
\begin{align*}  
    \text{\the\hsize} &\equiv \printdimen[mm]\hsize \\
                      &\equiv \printdimen[cm]\hsize \\
                      &\equiv \printdimen[ex]\hsize \\                    
                      &\equiv \printdimen[em]\hsize \\      
                      &\equiv \printdimen[bp]\hsize \\
                      &\equiv \printdimen[dd]\hsize \\                    
                      &\equiv \printdimen[pc]\hsize \\  
                      &\equiv \printdimen[in]\hsize                                    
\end{align*}
\end{document}

enter image description here

LaRiFaRi
  • 43,807