Discussion:
"! LaTeX Error: Not in outer par mode." and the exam class
(too old to reply)
H.S.
2006-02-10 06:17:59 UTC
Permalink
Hi,

I am using the exam class to make solutions and question papers. I have
noticed that if I include any graphic using \includegraphics command
within the 'solution' environment, Latex gives the error:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
! LaTeX Error: Not in outer par mode.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...

l.6 \begin{figure}[htb]

?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5

Here is a minimal example:

%%%%%%%%%%%%%%%%% example starts %%%%%%%%%%%%%%%%%%%%%%%%%%5
\documentclass[11pt,answers]{exam}
\usepackage{graphicx}

\usepackage{float}

\begin{document}


\begin{questions}

\question Question statement here.
\begin{solution}
Solution here and the figure below:

\begin{figure}[htb]
\begin{center}
\input{j-8_51-phasordia.pstex_t}
\caption{\label{fig:j8.51:phasordia} Schematic drawing show here.}
\end{center}
\end{figure}

\end{solution}
\end{questions}
\end{document}
%%%%%%%%%%%%%%%%%% example ends %%%%%%%%%%%%%%%%%%%%%%

Any suggestions how to include figures within the solutions env?
Currently I am just including them outside the environment but there are
situations where I must include the figures only in the solutions env.

thanks,
->HS
--
Please remove the underscores ( the '_' symbols), if any, from my email
address to obtain the correct one. Apologies, but the fudging is to
reduce spam.
Ulrike Fischer
2006-02-10 09:30:36 UTC
Permalink
Post by H.S.
Hi,
I am using the exam class to make solutions and question papers. I have
noticed that if I include any graphic using \includegraphics command
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
! LaTeX Error: Not in outer par mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \begin{figure}[htb]
As the error message shows clearly the problem is not that you use
\includegraphics, but that you use \begin{figure}. Floats can't be use
inside environments and boxes.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ouparmd

If you really want the graphic to float, put the figure environment
outside the solution. If you only want "here" a graphic, consider to
delete the figure environment. You can get a caption e.g. by using the
caption package.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=captsty
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats
--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.
H.S.
2006-02-10 14:34:01 UTC
Permalink
Post by Ulrike Fischer
Post by H.S.
Hi,
I am using the exam class to make solutions and question papers. I have
noticed that if I include any graphic using \includegraphics command
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
! LaTeX Error: Not in outer par mode.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \begin{figure}[htb]
As the error message shows clearly the problem is not that you use
\includegraphics, but that you use \begin{figure}. Floats can't be use
inside environments and boxes.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=ouparmd
Thank you so much for pointing out the exact problem. It has been a
while seen I saw these kind of problems and looking at \begin{figure}
figure assumed my including graphics was the problem.
Post by Ulrike Fischer
If you really want the graphic to float, put the figure environment
outside the solution. If you only want "here" a graphic, consider to
delete the figure environment. You can get a caption e.g. by using the
caption package.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=captsty
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats
I will try these.

Thanks
->HS
--
Please remove the underscores ( the '_' symbols), if any, from my email
address to obtain the correct one. Apologies, but the fudging is to
reduce spam.
H.S.
2006-02-10 14:56:50 UTC
Permalink
Post by Ulrike Fischer
If you really want the graphic to float, put the figure environment
outside the solution. If you only want "here" a graphic, consider to
delete the figure environment. You can get a caption e.g. by using the
caption package.
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=captsty
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=floats
Worked perfectly:

Put in the preamble:
\usepackage{ccaption} %needed to put figures outside of float env
\newfixedcaption{\solfigcaption}{figure}


and put where the figure is needed within the sol env:
\begin{center}
\input{j-8_40-phasordia.pstex_t}
\solfigcaption{\label{fig:j8.40:phasordia} Caption text here.}
\end{center}


thanks a ton,
->HS
--
Please remove the underscores ( the '_' symbols), if any, from my email
address to obtain the correct one. Apologies, but the fudging is to
reduce spam.
Ulrike Fischer
2006-02-10 15:14:44 UTC
Permalink
Post by H.S.
\usepackage{ccaption} %needed to put figures outside of float env
\newfixedcaption{\solfigcaption}{figure}
\begin{center}
\input{j-8_40-phasordia.pstex_t}
\solfigcaption{\label{fig:j8.40:phasordia} Caption text here.}
\end{center}
You should perhaps put the figure and the caption in a minipage to
prevent a pagebreak between the two.
--
Ulrike Fischer
e-mail: zusätzlich meinen Vornamen vor dem @ einfügen.
e-mail: add my first name between the news and the @.
H.S.
2006-02-10 15:26:50 UTC
Permalink
Post by Ulrike Fischer
Post by H.S.
\usepackage{ccaption} %needed to put figures outside of float env
\newfixedcaption{\solfigcaption}{figure}
\begin{center}
\input{j-8_40-phasordia.pstex_t}
\solfigcaption{\label{fig:j8.40:phasordia} Caption text here.}
\end{center}
You should perhaps put the figure and the caption in a minipage to
prevent a pagebreak between the two.
So, this seems to work (had to add the spacing after minipage env):
\begin{minipage}[t]{\linewidth}
\begin{center}
\input{j-8_51-phasordia.pstex_t}
\solfigcaption{\label{fig:j8.51:phasordia} Circuit diagram in phasor
domain for Prob. 8.51. The components' values are the same as given in
the text book.}
\end{center}
\end{minipage}
\vspace{1ex}

The vertical space separates the minipage and the following text. Is
there a variable that gives the exact spacing that is put between a
figure environment and the following text?

thanks,
->HS
--
Please remove the underscores ( the '_' symbols), if any, from my email
address to obtain the correct one. Apologies, but the fudging is to
reduce spam.
t***@yahoo.com
2006-02-10 18:20:32 UTC
Permalink
Post by H.S.
Hi,
I am using the exam class to make solutions and question papers. I have
noticed that if I include any graphic using \includegraphics command
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
! LaTeX Error: Not in outer par mode.
This and many other things are answered in

ftp://ctan.tug.org/tex-archive/info/epslatex/english/epslatex.pdf

You also should be using \centering in the figure environment
instead of \begin{center}....\end{center}

Tony

Loading...