Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a mathematical text I use theorem environments, for example I have defined example. In some of these environments I‘d like to inlcude a graphic:

\begin{example}
  A nice example for this foo is the following:

  \includegrapcis{foo}.

  As you can see: \dots
\end{example}

Unfortunately that does not work very well. At first I am unable to add a caption, but that is not the main problem. The main problem is that the graphic‘s bottom and the text of my environment (“Example x.y”) are aligend at their bottom, ie. parts of the grapic are above the environment.

I tried some googling, ie. used the placeins package and \FloatBarrier (and put the \includegraphics in a figure) but without any good result.

How to include such a graphic in a not ugly way?

share|improve this question
    
Could you show a screen shot of what you mean? This could be an issue with the image bounding box. –  Werner Apr 13 at 13:34
    
Please, make a minimal working example (MWE) to clarify the question. If the contents of environment example is set in vertical mode, then the image is in the middle. If it is set in horizontal mode, then the image can be moved via \raisebox, but a caption does not make any sense to me. –  Heiko Oberdiek Apr 13 at 13:48
    
@HeikoOberdiek: I understand the idea of a MWE, but since this question is answered, I do not see a reson to improve the question anymore. –  Keba Apr 13 at 15:06

1 Answer 1

up vote 3 down vote accepted

It is enough to write something before \includegraphics, e.g. mbox{}. \FloatBarriercould do nothing since you do not have a float — which would make no sense in a theorem environment. I suggest you centre your image and use the \captionof command from the caption package. Here is a code with a figure inclusion that can be referenced:

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{lipsum}
\usepackage{cleveref}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{framed}
\usepackage[framed]{ntheorem}
\theoremstyle{nonumberbreak}
\theoremheaderfont{\bfseries}
\theorembodyfont{\mdseries\upshape}
\newframedtheorem{example}{Example}

\begin{document}

\lipsum[1]
\begin{example}
\mbox{}%
\begin{center}
  \includegraphics{zoom}
  \captionof{figure}{The example figure}\label{exfig1}
\end{center}
\end{example}
As can be seen in \cref{exfig1}, …

\end{document}

enter image description here

share|improve this answer
    
Works fine, thanks :) –  Keba Apr 13 at 13:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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