Hi!
First of all, congratulations and thanks to the creator of this template. It is awesome!!
And here goes my question... Is it possible to include images inside the Theorem environment (or definition, or exercise...)? When I simply put the image inside it the regular way (ie, \begin{figure} \include{graphics}...) I always get the same error: "Lost float"
Many thanks in advance!! Any help will be much appreciated.
Cheers
the_blue_note
Theses, Books, Title pages ⇒ Using images inside Theorems
NEW: TikZ book now 40% off at Amazon.com for a short time.
Using images inside Theorems
Hi,
Putting a float inside a float gives an error as you have said in your post, which means you can't use the
Cheers,
Vel
Putting a float inside a float gives an error as you have said in your post, which means you can't use the
figure
environment within the theorem
environment. Luckily, there is a workaround you can use which is to refrain from using the figure
environment and print the caption using the caption
package. To do this, you will need to include the caption
package in the preamble with \usepackage{caption}
and then to include a figure within a theorem, use the following example:Code: Select all
\begin{theorem}[Name of the theorem]
~\\[12pt]
\includegraphics[scale=0.5]{placeholder}
\captionof{figure}{Caption for image}
In $E=\mathbb{R}^n$ all norms are equivalent. It has the properties:
\begin{align}
& \big| ||\mathbf{x}|| - ||\mathbf{y}|| \big|\leq || \mathbf{x}- \mathbf{y}||\\
& ||\sum_{i=1}^n\mathbf{x}_i||\leq \sum_{i=1}^n||\mathbf{x}_i||\quad\text{where $n$ is a finite integer}
\end{align}
\end{theorem}
Vel
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com
-
- Posts: 679
- Joined: Tue Mar 03, 2015 4:01 pm
Re: Using images inside Theorems
Thank you, thank you, thank you!! =)
PS: How do I mark this as closed...?
PS: How do I mark this as closed...?
Re: Using images inside Theorems
You're welcome 
I usually leave these open so others can come along later and ask further questions on the same topic or add further solutions.

I usually leave these open so others can come along later and ask further questions on the same topic or add further solutions.
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Using images inside Theorems
Instead of putting a
The math could use a lot of polishing using packages like physics and semantic markup as well.
\newline
, i suggest to use a proper paragraph break, maybe even along with a center environment.
Code: Select all
\documentclass{book}
\usepackage{caption}
\usepackage{mathtools}
\usepackage{mwe}
\usepackage{amssymb}
\usepackage{physics}
\newtheorem{theorem}{Theorem}
\begin{document}
\begin{theorem}[Name of the theorem]~
\begin{center}
\includegraphics[width=.6\linewidth]{example-image-a}
\captionof{figure}{Caption for image}
\end{center}
In $E=\mathbb{R}^n$ all norms are equivalent. It
has the properties:
\begin{align}
& \big| ||\mathbf{x}|| - ||\mathbf{y}||
\big|\leq || \mathbf{x}- \mathbf{y}||\\
& ||\sum_{i=1}^n\mathbf{x}_i||\leq
\sum_{i=1}^n||\mathbf{x}_i||\quad\text{where
$n$ is a finite integer}
\end{align}
\end{theorem}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.