Como colocar algoritmo com figura na mesma linha?

Como colocar algoritmo com figura na mesma linha?

Eu tenho um código de algoritmo e uma figura e estou tentando colocá-los juntos na mesma linha. Aí está o código:

\centering
\caption{Auto-entrenamiento}
\label{alg_self}
\begin{algorithmic}
\State $m_0 \gets entrenar\_modelo(\mathcal{D}_{l})$
\Repeat
    \State $m \gets entrenar\_modelo(\mathcal{D}_{l})$
    \For {$x \in \mathcal{D}_{u}$}
        \If {max $m(x) > \tau$}
            \State $\mathcal{D}_{l} \gets \mathcal{D}_{l} \cup \{(x, p(x))\}$
        \EndIf
    \EndFor
\Until {las predicciones no sean confiables}
\end{algorithmic}
\end{algorithm}

\begin{figure}[htp]
    \centering
    \includegraphics[scale=0.35]{imagenes/ssl_self2.png} 
    \vspace{0.1cm} 
    \caption{Método semi-supervisado de auto-entrenamiento}
    \label{fig:ssl_self}
\end{figure}

Responder1

Um hack horrível para persuadir algorithma desenhar linhas mais curtas.

\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{graphicx}

\begin{document}

\begin{figure}

\begin{minipage}{0.45\textwidth}
\begin{algorithm}[H]
\hsize=\textwidth % <--------- THE HACK!
\caption{Auto-entrenamiento}
\label{alg_self}
\begin{algorithmic}
\State $m_0 \gets \textit{entrenar\_modelo}(\mathcal{D}_{l})$
\Repeat
    \State $m \gets \textit{entrenar\_modelo}(\mathcal{D}_{l})$
    \For {$x \in \mathcal{D}_{u}$}
        \If {max $m(x) > \tau$}
            \State $\mathcal{D}_{l} \gets \mathcal{D}_{l} \cup \{(x, p(x))\}$
        \EndIf
    \EndFor
\Until {las predicciones no sean confiables}
\end{algorithmic}
\end{algorithm}
\end{minipage}\hfill
\begin{minipage}{0.45\textwidth}
    \centering
    \includegraphics[scale=0.35]{example-image}
    \vspace{0.1cm} 
    \caption{Método semi-supervisado de auto-entrenamiento}
    \label{fig:ssl_self}
\end{minipage}
\end{figure}

\end{document}

Use \textitse quiser palavras em itálico dentro de matemática.

insira a descrição da imagem aqui

informação relacionada