[Tex/LaTex] geometry package doesn’t change textheight

geometry

When I compile this MWE, I get a box that takes up about 80% of a vertical page. Since I have specified max height=0.4\textheight in adjustbox, I'd expect a box half the size… is geometry not changing \textheight?

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage{adjustbox}
\usepackage{boxedminipage}

\begin{document}
\begin{adjustbox}{max width=\textwidth,max height=0.4\textheight,keepaspectratio}
\begin{boxedminipage}{70cm}
\ \vspace{70cm}\ 
\end{boxedminipage}
\end{adjustbox}
\end{document}

Best Answer

\textheight is changing as you can verify by adding the verbose option to geometry and looking in the log file. The problem is the adjustbox command. Changing max height to max totalheight gives the desired behaviour.

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage{adjustbox}
\usepackage{boxedminipage}

\begin{document}
\begin{adjustbox}{max width=\textwidth,max totalheight=0.4\textheight,keepaspectratio}
\begin{boxedminipage}{70cm}
\ \vspace{70cm}\ 
\end{boxedminipage}
\end{adjustbox}
\end{document}

If you do the following

\newsavebox{\test}

\settoheight{\test}{\begin{boxedminipage}{70cm}
  \ \vspace{70cm}\ 
\end{boxedminipage}}
\showthe\\test

\sbox{\test}{\begin{boxedminipage}{70cm}
  \ \vspace{70cm}\ 
\end{boxedminipage}}
\showthe\ht{\test}

then the log file will show that your boxed minipage has height 1001.74644pt and depth 996.74644pt so its total height is about twice its height. (The values are close to being such that the box is vertially centered with respect to the middle of the current row.)

boxedminipage is just like minipage, so you can give it positioning arguments: a \begin{boxedminipage}[b] results in a box with zero depth and full height; \begin{boxedminipage}[t] results in a box with height 0.4pt and (nearly) full depth (the 0.4pt comes from the frame). So instead of using totalheight, you could use

\begin{adjustbox}{max width=\textwidth,max height=0.4\textheight,keepaspectratio}
  \begin{boxedminipage}[b]{70cm}
    \ \vspace{70cm}\
  \end{boxedminipage}
\end{adjustbox}