首页 > 解决方案 > 如何使用 LaTeX 在 Jupyter Notebook 中水平包含两个图形,准备导出为 PDF?

问题描述

我想包括两个数字,如此处所示

我尝试使用Markdown 语法,但是,当导出为 PDF 时,这两个图像超出了页面的范围。Pandoc 无法将 HTML 转换为 LaTeX,反之亦然,因此在 HTML 中包含图形也不是一种选择

最后,使用Jupyter notebook 的(一些)LaTeX 环境,我能够将 LaTeX 代码包含到 Markdown 单元格中,以便它显示在笔记本本身中。但是,我现在有两个问题。这是我的代码:

\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}

这是 Jupyter Notebook 中的输出:

Jupyter Notebook 输出

只显示一张图片,另一张没有。此外,图形标题未居中。

那是另一个问题,图形标题不在图像下方居中,而是向左对齐。即使在简单的数字(不是子图)下。

所以我需要的是让这些数字在 Jupyter Notebook 以及通过 LaTeX 将笔记本转换为 PDF 之后正确显示。

有任何想法吗?谢谢!

标签: pythonjupyter-notebooklatexpandocnbconvert

解决方案


推荐阅读