I can not get standalone to work with figures; I get the error Not in outer par mode.

(The figure is in the included file.)


Update 2011/12/21

I now release standalone v1.0 which turns floats to non-floating environments automatically by default. Now you can use figure as normal inside standalone files. See the float option in the manual.

Original answer:

No, floats like figure and table environments are not supported with the standalone class or by the internally used preview package. The whole file is rendered as one box and there is not place where it could float to.

Just remove the environment and include your images or pictures as normal. Place the figure environment including the \caption in the main file and \input the standalone file there:

% inside the main file
   \caption{The caption text}\label{fig:abc}%

If you want to have the caption inside the standalone for any reason load the caption or capt-of package and use \captionof{figure}{<caption text>}. You can put the whole thing in a center environment. However centering might not work properly in a standalone because of the cropping.

   % your image or picture code
   \captionof{figure}{The caption text}\label{fig:abc}
| improve this answer | |
  • Is it possible to have standalone fit tight to the figure environment? That is, this demo: pastebin.com/327qEtf7 produces the image on the left, but the full page width of whitespace to the right of it. I want the output to be tight to the image. – David Doria Oct 31 '12 at 16:49
  • @DavidDoria: Like mentioned the figure environment should not be in the standalone file, but be part of the main document. Your code seems to great a paragraph which is then \linewidth wide. This causes the white space on the right. – Martin Scharrer Oct 31 '12 at 21:41
  • Even when I create a separate file with just the contents of the float environment: pastebin.com/H7BGE9fm a full page is output. My final goal is actually to crop the full figure of a subfig: tex.stackexchange.com/questions/79877/… - it seems to almost work like that, but the subfig subcaption letters are misaligned - can you comment on that as well? Thanks! – David Doria Oct 31 '12 at 23:03
  • @DavidDoria: Don't add empty lines after the content. They create a parapgraph break. See tex.stackexchange.com/q/34590/2975 for an explanation. Note that the 'crop' option doesn't have this issue. – Martin Scharrer Oct 31 '12 at 23:26
  • Sorry if I'm being crazy, but this: pastebin.com/0tKvPkGk is still producing a full page? – David Doria Nov 1 '12 at 0:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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