4

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}
Mohan
  • 15,906
  • Just a guess: doesn't keepaspectratio overwrite the height setting? – cgnieder Dec 05 '12 at 12:16
  • @Mohan not sure what you trying to achieve your boxedminipage is 70cm? – yannisl Dec 05 '12 at 12:21
  • @Yiannis Lazarides: I just needed something that was much bigger than the page, to make sure that the adjustbox would shrink it. I couldn't find a cleaner way of drawing a huge square, so I just used boxedminipage. – Mohan Dec 05 '12 at 12:22
  • 1
    {\fboxsep=-\fboxrule\framebox[70cm]{\rule{0pt}{70cm}}} – egreg Dec 05 '12 at 12:25
  • @egreg: thanks! I would say that's worth turning into a question + answer --- I did search, and couldn't find anything that didn't require tikz, which seems like overkill. – Mohan Dec 05 '12 at 12:30
  • 1
    \newcommand{\bigsquare}[1]{{\fboxsep=-\fboxrule\sbox0{}\wd0=#1\ht0=#1\relax\fbox{\box0}}} and then \bigsquare{70cm} is even faster. – egreg Dec 05 '12 at 13:04
  • @egreg: would it be all right if I ask a question about this so that you can turn bigsquare into an answer? – Mohan Dec 05 '12 at 13:52

1 Answers1

6

\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}
Andrew Swann
  • 95,762
  • THank you. What's the difference between height and totalheight? (I've looked at the documentation, but the only difference I can see is that totalheight is overridden by textheight.) – Mohan Dec 05 '12 at 12:27
  • 1
    @Mohan A minipage (and boxedminipage too) has not only a height, but also a depth: it extends below the baseline (almost) as much it extends above it. You so occupied 80% of the available height just because of this. – egreg Dec 05 '12 at 12:30