Graphics, Figures & TablesPlacing graphic and algorithm together on page

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Mr Morgan
Posts: 1
Joined: Wed Oct 14, 2015 11:10 pm

Placing graphic and algorithm together on page

Post by Mr Morgan »

If I have the following LaTeX code, is it possible to combine both graphic and algorithm so that they are fixed to a common page?

Code: Select all

\begin{figure} [H]
\centering{\includegraphics[scale=1]{Figure.png}}
\caption{Figure.}
\label{fig:Figure}
\end{figure}

\begin{algorithm}[H]
 \algsetup{indent=2em}
    \begin{adjustwidth}{1em}{} 
        \begin{algorithmic}[1]
            \STATE $Line$ $of$ $code$
        \end{algorithmic}
        \caption{Algorithm.}
        \label{alg:Algorithm}
    \end{adjustwidth}
\end{algorithm}
To give something like this:
Capture.PNG
Capture.PNG (7.06 KiB) Viewed 2045 times
Where the figure and algorithm are connected?

The package subfig is not compatible with other packages in the current project.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Placing graphic and algorithm together on page

Post by Johannes_B »

This is a crosspost to TeX.SX where you already got two solutions.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply