Theses, Books, Title pages ⇒ Using images inside Theorems
-
- Posts: 679
- Joined: Tue Mar 03, 2015 4:01 pm
Using images inside Theorems
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
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Using images inside Theorems
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
-
- Posts: 679
- Joined: Tue Mar 03, 2015 4:01 pm
Re: Using images inside Theorems
PS: How do I mark this as closed...?
Re: Using images inside Theorems

I usually leave these open so others can come along later and ask further questions on the same topic or add further solutions.
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Using images inside Theorems
\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. Ithas 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}