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.

I can't get a caption to show up in the following MWE.

I've put caption at the end of the key list, and in the actual example the BLAH BLAH BLAH is replaced with an \input{table.tex} variant, but the problem persists in this simple version. \caption outside the environment just gives me a caption outside float environment error.

Any thoughts appreciated

\documentclass[10pt,landscape]{article}
\usepackage[left=0.5in,right=0.5in,top=0.5in,bottom=0.5in]{geometry}
\usepackage{adjustbox}
%\usepackage{caption}
\usepackage{booktabs}

\begin{document}

\renewcommand{\arraystretch}{1.5}

\begin{adjustbox}{width=\textwidth,totalheight=\textheight,keepaspectratio,caption={blah blah}}
BLAH BLAH BLAH
\end{adjustbox}


\end{document}
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

The caption key only sets the caption text. It will only be used if you also use a figure, float or nofloat key. The package manual states this:

caption=<caption text>
caption=[<short caption>]{<long caption>}

Defines a caption which will be used by a following figure, float or nofloat key. The position of the caption defaults to top for a table (non-)float and bottom for every other type.

If you don't want to turn the content into a float, use nofloat. Please note that you need to setup the caption type yourself using an appropriate package. This is not done for you by adjustbox. Also, there is no support for an unnumbered caption, e.g. just some title text etc., therefore using an existing float/caption type is mandatory.


Unfortunately the mentioned keys don't work directly with the width, height or totalheight keys because they don't force the execution of the outstanding resizing operations. Because of this the environment will try to resize the whole (non-)float environment which causes an error. I will fix this in the next version of adjustbox. In the meantime simply use a rotate=0 to force the resizing operation.


Here a minimal example where the adjusted content is taken as a table:

\documentclass{article}
\usepackage{adjustbox}

\begin{document}

\begin{adjustbox}{width=\textwidth,totalheight=\textheight,keepaspectratio,rotate=0,caption={blah blah},float=table}
BLAH BLAH BLAH
\end{adjustbox}

\end{document}
share|improve this answer
    
thanks @MartinScharrer the rotate=0 was what I was looking for. Appreciate your help. Really useful package too btw. Thank you. –  Tahnoon Pasha Jan 30 '13 at 4:15
    
@TahnoonPasha: I'm glad that I could help. I already fixed the issue in the code repository, so the next release will not require the rotate=0 workaround. –  Martin Scharrer Jan 30 '13 at 7:26
add comment

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.