# Figure inside leftbar environment generates error “Not in outer par mode”

! LaTeX Error: Not in outer par mode.

I seek a solution to be able to make this figure inside leftbar environment work:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{framed}

\begin{document}

\begin{leftbar}

\begin{figure}[h!]
\caption{Mean data points enclosed by shapes are contained within the same group, within 95\% confidence.}
\includegraphics[scale=0.7]{"../Data Analysis Files/InteractionPlotforTransLog10(X+1)Count"}
\end{figure}

\end{leftbar}

\end{document}


@Stefan Kottwitz, your solution is otherwise perfect, but it does introduce this problem of cropping at the end of pages:

-
What output are you expecting? The figure environment is a float, which seems inappropriate in a side bar. –  Joseph Wright Jun 5 '11 at 17:54
I use the bar to distinguish certain sections of text as responses, while the rest of the text unaccompanied by the leftbar are questions. It's an article with a Q&A format, each time an answer is offered the leftbar is inserted. –  ptrcao Jun 5 '11 at 18:15
It's being used as a fancy quotation environment if you like. –  ptrcao Jun 5 '11 at 18:16

Use leftbar inside the figure environment. By changin the nesting you still can let it float. If you don't need floating, you don't need a figure environment: captions can be done then using the caption package (or capt-of).

\begin{figure}[h!]
\begin{leftbar}
\caption{Mean data points enclosed by shapes are contained within the same group, within 95\% confidence.}
\includegraphics[scale=0.7]{"../Data Analysis Files/InteractionPlotforTransLog10(X+1)Count"}
\end{leftbar}
\end{figure}


A solution without figure, so you can put this and everything else into an outer leftbar environment:

\usepackage{caption}
...
\begin{leftbar}
\begin{minipage}{\columnwidth}
\captionof{figure}{Mean data points enclosed by shapes are contained within the same group, within 95\% confidence.}
\includegraphics[scale=0.7]{"../Data Analysis Files/InteractionPlotforTransLog10(X+1)Count"}
\end{minipage}

-
Sorry, I should've made it clearer there are other text, figures and tables contained within leftbar as well - I omitted them because this was a minimal example. So that doesn't appear to be an option for me... Any other ideas Stef, or others? –  ptrcao Jun 5 '11 at 18:05
@ptrcao: I added an example without figure but with caption. –  Stefan Kottwitz Jun 5 '11 at 18:13
Nice - it works! Solution accepted, with thanks. :) –  ptrcao Jun 5 '11 at 18:20
It was important to create a minipage environment - which you recognised - because otherwise the caption and graphic don't stay together as a coherent unit, so nicely constructed Stef :) –  ptrcao Jun 5 '11 at 18:21
or anyone else reading this - Can you please have a look at the unwanted cropping depicted in my OP (applies to Stefan's solution immediately preceding) and suggest, if you know a way to control this issue? –  ptrcao Jun 6 '11 at 11:20