Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put figure between items on enumerate list?

I've a enumerate list and some items have figures. I write this:

\begin{enumerate}
    \item Estado da arte: 
    \item Levantar os requisitos
    \item Com o microcontrolador
\ref{figurametodo3}.    
    \begin{figure}[h!]
        \begin{center}
            \includegraphics[scale=0.6]{./dados/figuras/metodo_3}
            \caption{Sistema para leitura da identificação de uma Tag} 
            \label{figurametodo3}
        \end{center}
    \end{figure}


    \item Estudar

    \begin{figure}[h]
    \begin{center}
        \includegraphics[scale=0.4]{./dados/figuras/metodo_4}
        \caption{Comunicação entre o microcontrolador e o celular} 
        \label{figurametodo4}
    \end{center}
\end{figure}

    \item Desenvolver 

    \begin{figure}[h]
    \begin{center}
        \includegraphics[scale=0.6]{./dados/figuras/metodo_final}
        \caption{Comunicação entre celulares e servidor} 
        \label{figura22}
    \end{center}
\end{figure}

\end{enumerate}

But it aligns all figures below the list, outside of place that I want. I want that my figures stay just below that your item. Inside of the list.

like image 981
Augusto Avatar asked Jun 22 '18 19:06

Augusto


People also ask

How do you insert a picture into LaTeX?

Including images in your LaTeX document requires adding: \usepackage{graphicx} to the beginning/preamble of your document. \includegraphics{ } command tells LaTeX to insert the image. To upload an image, click the upload button, and upload your image file.

Why we use enumerate in LaTeX?

The enumerate-environment is used to create numbered lists. If you like to change the appearance of the enumerator, the simplest way to change is to use the enumerate-package, giving you the possibility to optionally choose an enumerator. \begin {enumerate}[I] %for capital roman numbers.


2 Answers

This is covered in the following FAQs:

  • How to influence the position of float environments like figure and table in LaTeX?
  • Keeping tables/figures close to where they are mentioned
  • Force LaTeX image to appear in the section in which it's declared

Here's one option using the float package and it's [H]ERE float specifier:

enter image description here

\documentclass{article}

\usepackage{float,graphicx}

\begin{document}

\begin{enumerate}
  \item Item 1
  \item Item 2
  \item Item 3

  \begin{figure}[H]
    \centering
    \includegraphics[width = .5\linewidth]{example-image-a}
    \caption{A figure caption}
  \end{figure}

  \item Item 4

  \begin{figure}[H]
    \centering
    \includegraphics[width = .5\linewidth]{example-image-b}
    \caption{B figure caption}
  \end{figure}

  \item Item 5
  \item Item 6
\end{enumerate}

\end{document}
like image 52
Werner Avatar answered Sep 27 '22 17:09

Werner


Use minipage environment to insert the image:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}
\begin{document}
\begin{enumerate}
  \item Estado da arte:
  \item Levantar os requisitos
  \item
    \begin{minipage}[t]{\linewidth}
      Com o microcontrolador \newline                                
      \includegraphics[scale=0.6]{./dados/figuras/metodo_3}
      \captionof{figure}{Sistema para leitura da identificação de    uma Tag}
    \end{minipage}

\end{enumerate}
\end{document}

You should not use figure, if you don't want a float.

The LaTeX Wikibook explains:

Floats are containers for things in a document that cannot be broken over a page. LaTeX by default recognizes "table" and "figure" floats, [...]. Floats are there to deal with the problem of the object that won't fit on the present page, and to help when you really don't want the object here just now.

To provide a caption outside of figures one needs to use package caption, which provides the captionof command.

There is also a capt-of package if you are just interested in using the command \captionof.

like image 27
rkta Avatar answered Sep 27 '22 18:09

rkta