forcing vertical size of savebox to equal page height

Is there a better way of generating a \savebox whose dimensions are equal to the paper dimensions than sticking in a \strut of length equal to the page height (width is an argument to the \savebox itself).

• A strut is certainly not necessary, but unless we know quite what you want to use the whole page for, it'll be hard to give you a good answer. Answers will range from setting the height of the box directly to using TikZ to create a node that covers the entire page. – A.Ellett Apr 26 '15 at 3:10
• a savebox is horizontal box so the height is the content height. You can try \sbox\sb{\parbox[t][\paperheight]{\paperwidth}{some text}} – touhami Apr 26 '15 at 7:15
• Yes, perhaps a parbox is easier. @A.Ellett: I just want a savebox of the given dimensions that I can then fill with whatever I want. – JPi Apr 26 '15 at 11:41

Using a combination of lrboxes and minipages, you can save your content to a box. Then once saved, you can resize the box. Keep in mind, while the dimensions of the box are changed, the typesetting remains the same.

\documentclass{article}
%% open the dimensions of the page a bit
\usepackage[margin=0.75in]{geometry}
\newsavebox\aebox
%% set fbox parameters to facilitate seeing how dimensions are changed.
\setlength\fboxsep{-0.4pt}
\setlength\fboxrule{0.4pt}
\pagestyle{empty}
\begin{document}

\begin{lrbox}\aebox
\begin{minipage}[t]{3in}
This is just an example of a box of certain dimensions that can later be
reassigned.
\end{minipage}
\end{lrbox}

Hello
\fbox{\usebox\aebox}
\ht\aebox\dimexpr\baselineskip*2\relax
\dp\aebox\dimexpr\textheight-\baselineskip*2\relax
\fbox{\usebox\aebox}

\end{document}


Of course, the above doesn't quite do what you want. You could take @HarishKumar 's approach and set the geometry of the page so that the margins are all 0pt. In that case, in the above example, if you set

\usepackage[margin=0pt]{geometry}


you'll get

But what if you don't want to set the margins to 0pt?

Assuming that the margins are set to 0.5in you could try something like

\raisebox{\dimexpr0.5in+\baselineskip+<some dimension>\relax}[0pt][0pt]{\fbox{\usebox\aebox}}


But then it's difficult (as least for me), to figure out how exactly to set <some dimension> so that your box is properly placed.

In that case, you might want to load tikz (which is also optionally called when loading the tcolorbox package). This is what you could do:

\documentclass{article}
%% open the dimensions of the page a bit
\usepackage[margin=0.5in]{geometry}
\newsavebox\aebox
%% set fbox parameters to facilitate seeing how dimensions are changed.
\setlength\fboxsep{-0.4pt}
\setlength\fboxrule{0.4pt}

\pagestyle{empty}

\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

\begin{lrbox}\aebox
\begin{minipage}[t]{3in}
This is just an example of a box of certain dimensions that can later be
reassigned.
\end{minipage}
\end{lrbox}

\hspace*{3.5in} Hello \fbox{\usebox\aebox}

%% setting the dimensions of the box
\ht\aebox\dimexpr\baselineskip\relax
\dp\aebox\dimexpr\paperheight-\baselineskip\relax
\begin{tikzpicture}[remember picture,overlay]
\node[inner sep=0pt,anchor=north west,fill=orange!20] at ($(current page.north west)+(0.5in,0)$) {\fbox{\usebox\aebox}};
\end{tikzpicture}

\end{document}


To get

You can use tcolorbox that offers height key.

\documentclass{article}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}
\usepackage[a4paper,top=0cm,bottom=0cm]{geometry}  %% just for demo
\begin{document}
\begin{tcolorbox}[width=0.5\textwidth,height=\paperheight]
\lipsum[1-2]
\end{tcolorbox}
\end{document}