5

I want to include two figures as shown here.

I tried to use the Markdown syntax, however, when exporting to PDF, the two images go out of bounds of the page. Pandoc can't convert HTML to LaTeX and vice versa, so including the figures in HTML also isn't an option.

Finally, using (some) LaTeX environments for Jupyter notebook I was able to include LaTeX code into Markdown cells so that it shows in the notebook itself. I have two issues now however. This is my code:

\begin{figure}[ht]
\begin{subfigure}{.5\textwidth}
  \centering
  % include first image
  \includegraphics[width=.8\linewidth]{attachments/alpha-games.jpg}  
  \caption{AlphaZero games}
  \label{fig:games}
\end{subfigure}
\begin{subfigure}{.5\textwidth}
  \centering
  % include second image
  \includegraphics[width=.8\linewidth]{attachments/fb-robots.jpg}  
  \caption{Robots}
  \label{fig:robots}
\end{subfigure}
\caption{Uses of Reinforcement learning in real life.}
\label{fig:fig1}
\end{figure}

This is the output in Jupyter Notebook:

Jupyter Notebook output

Only one image is showing, the other is not. Also, the figure caption is not centered.

That's the other issue, the figure captions are not centered under the image, but aligned to the left. Even under simple figures (not subfigures).

So what I need is for the figures to show correctly in both Jupyter Notebook and also after converting the notebook to PDF via LaTeX.

Any ideas? Thank you!

Pehy
  • 129
  • 7
  • Is it acceptable to show the figures using IPython's `display` function or does it have to be Markdown/LaTeX in the notebook? – butterwagon Sep 25 '20 at 19:45
  • Hello @butterwagon, it has had to be Markdown/LaTeX. I want to make the notebook into an academic paper basically. I've switched to Jupyter Book however, in which the captions show up correctly. – Pehy Oct 10 '20 at 22:15

0 Answers0