Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Hi looking to understand this a little better. Why does adjustbox not resize the text in the following example so that it fits the dimensions I think I'm specifying. e.g a 4in x 4in box. Am I doing something wrong and how do I fix it?

\documentclass{article}
\usepackage{lipsum} 
\usepackage{adjustbox}
\begin{document}
\begin{adjustbox}{frame,max height=4in,max width=4in}
\parbox{4in}{
\lipsum[1-3]}    
\end{adjustbox}
\end{document}
share|improve this question
1  
As @IanThompson mentioned, you're specifying max height, which is different from max totalheight, since your \parbox has depth (included in totalheight but not in height). –  Werner Aug 31 '12 at 16:08

1 Answer 1

up vote 9 down vote accepted

Boxes in TeX have both height and depth. We can enquire about the dimensions of the box in question as follows.

\documentclass[10pt]{article}
\usepackage{adjustbox}
\usepackage{lipsum}
\begin{document}
\newsavebox\Abox
\savebox\Abox{\parbox{4in}{\lipsum[1-3]}}
\newlength\mydp
\newlength\myhg
\settodepth\mydp{\usebox{\Abox}}
\settoheight\myhg{\usebox{\Abox}}
\showthe\mydp
\showthe\myhg
\end{document}

In this way, we obtain a height of 204.97221pt and a depth of 209.97223pt. Since 1in=72.27pt, this means that the height and depth of the box are approximately 2.84in and 2.91in, respectively. Consequently, setting max height=4in has no effect. According to page 5 of the adjustbox package manual, totalheight is height plus depth, so if you want the actual height of the box on the page to be restricted to 4in you should use totalheight in place of height. To make the width of the box remain the same (so the aspect ratio of the box changes), you need to set width and totalheight.

\documentclass[10pt]{article}
\usepackage{adjustbox}
\usepackage{lipsum}
\begin{document}
\adjustbox{width=4in,totalheight=4in}{\parbox{4in}{\lipsum[1-3]}}
\end{document}
share|improve this answer
    
\setlength{\mydp}{\dp\Abox} is much more efficient (although not officially documented in LaTeX). –  egreg Aug 31 '12 at 13:08
    
Hi @Ian. Tried that and it doesn't seem to work. Rather than a 4x4 box with text inside I get a longish rectangle. its 4" long but quite a lot narrower. –  Tahnoon Pasha Aug 31 '12 at 15:21
    
@TahnoonPasha --- What you want is not clear from the question; maybe you could edit it to clarify. In my answer, the box is scaled so that it fits within your settings for maximum width and height, while keeping the aspect ratio. If you want a 4in by 4in box you can use scale (see section 4.4 of the package manual). –  Ian Thompson Aug 31 '12 at 15:27
    
Thanks @Ian I've adjusted my question. My understanding of the scale key-value was that it was limited to an <h-factor> and <v-factor>, I'm not sure how I'd use it to specify a fixed size box. –  Tahnoon Pasha Aug 31 '12 at 15:36
    
@TahnoonPasha --- I have edited my answer. –  Ian Thompson Aug 31 '12 at 18:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.