# How to get the number of a length without the unit?

I am trying to draw a box whose dimensions are related to the size of the page. I can calculate the height and width of the box in \length terms (which include the length unit; e.g., 55.5pt). However when trying to draw the box in the picture environment size terms are just numbers (e.g., 55.5). How do I convert a length with unit into a plain number? Below is an example of what I am trying to do, but failing with macros like \textwidth in the \framebox macro in the \put argument.

% borderprob.tex  SE 559677
\documentclass{memoir}
\usepackage{lipsum}

\newlength{\bmargin}
\setlength{\bmargin}{2cm}

\newlength{\bwidth} \setlength{\bwidth}{\paperwidth}
\addtolength{\bwidth}{-\bmargin}
\newlength{\bheight} \setlength{\bheight}{\paperheight}
\addtolength{\bheight}{-\bmargin}

\newcommand{\borderbox}{\put(0,0){\framebox(\textwidth,-\textheight)}{}}
%\renewcommand{\borderbox}{\put(0,0){BORDERBOX}}
%\renewcommand{\borderbox}{\put(0,0){\framebox(20,30)}{}}
%\renewcommand{\borderbox}{\put(0,0){\framebox({\bwidth},{\bheight})}{}}
%\renewcommand{\borderbox}{\put(0,0){\framebox(20,\bheight)}{}}
%\renewcommand{\borderbox}{\put(0,0){\framebox(\bwidth,30)}{}}
%\renewcommand{\borderbox}{\put(0,0){\framebox(20,30)}{}}

\begin{document}

% length values
\verb!\bmargin = ! \the\bmargin

\verb!\paperwidth = ! \the\paperwidth{}
\verb!\bwidth = ! \the\bwidth

\verb!\paperheight = ! \the\paperheight{}
\verb!\bheight = ! \the\bheight

% draw a box
\begin{picture}(0,0) \borderbox \end{picture}

\lipsum

\lipsum

\end{document}

• in the next release you will be able to use lengths in the picture environment, but now add \usepackage{picture} and you can use \put(\bmargin,10cm) or whatever lengths you need. Aug 25 '20 at 19:05
• @DavidCarlisle Your comment worked for me. Thank you. Please consider making it an answer. Aug 26 '20 at 17:14

## 1 Answer

In the next (LaTeX2e 2020-10-01) release you will be able to use lengths in the picture environment, but for now add \usepackage{picture} and you can use \put(\bmargin,10cm) or whatever lengths you need.