Figure inside leftbar environment generates error "Not in outer par mode"

4,583

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}
Share:
4,583

Related videos on Youtube

ptrcao
Author by

ptrcao

Updated on June 07, 2020

Comments

  • ptrcao
    ptrcao over 3 years

    ! 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:

    enter image description here

    • Joseph Wright
      Joseph Wright over 12 years
      What output are you expecting? The figure environment is a float, which seems inappropriate in a side bar.
    • ptrcao
      ptrcao over 12 years
      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
      ptrcao over 12 years
      It's being used as a fancy quotation environment if you like.
  • ptrcao
    ptrcao over 12 years
    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?
  • Stefan Kottwitz
    Stefan Kottwitz over 12 years
    @ptrcao: I added an example without figure but with caption.
  • ptrcao
    ptrcao over 12 years
    Nice - it works! Solution accepted, with thanks. :)
  • ptrcao
    ptrcao over 12 years
    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
    ptrcao over 12 years
    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?