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}
\usepackage{picture}
and you can use\put(\bmargin,10cm)
or whatever lengths you need.