
페이지 크기와 관련된 크기의 상자를 그리려고 합니다. 상자의 높이와 너비를 \length
용어로 계산할 수 있습니다(길이 단위 포함, 예: 55.5pt). 그러나 환경에서 상자를 그리려고 할 때 picture
크기 용어는 숫자일 뿐입니다(예: 55.5). 단위가 있는 길이를 일반 숫자로 어떻게 변환합니까? 다음은 내가 하려고 하는 일의 예이지만 인수 의 매크로 와 같은 매크로 \textwidth
에서는 실패합니다 .\framebox
\put
% 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}
답변1
다음(LaTeX2e 2020-10-01) 릴리스에서는 사진 환경에서 길이를 사용할 수 있지만 지금은 추가 하고 필요한 길이를 \usepackage{picture}
사용할 수 있습니다 .\put(\bmargin,10cm)