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}
Best Answer
The
caption
key only sets the caption text. It will only be used if you also use afigure
,float
ornofloat
key. The package manual states this: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 byadjustbox
. 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
ortotalheight
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 ofadjustbox
. In the meantime simply use arotate=0
to force the resizing operation.Here a minimal example where the adjusted content is taken as a
table
: