将两张带有标题的图像并排放置并在 Latex 中控制它们的高度

Joh*_*Bzh 5 latex beamer

我想在乳胶/投影仪演示文稿中对齐两个图像。它们没有相同的宽度/高度比,我想控制整体高度。

如果我不需要字幕,则以下内容可以正常工作:

\includegraphics[height=0.35\textheight]{im1.png}
\hfill
\includegraphics[height=0.35\textheight]{im2.png}

Run Code Online (Sandbox Code Playgroud)

这里注意,我不需要输入图像宽度,我也不想输入。

但一旦我需要添加标题,就使用两个figure环境将数字放在两行上。解决方案是将两个figure环境插入到小型页面中,但随后我必须根据我想要的平均高度计算两个小型页面的宽度。

是否可以避免计算迷你页的宽度?

Ala*_*got 6

您可以将图像放入表格中。

您可以添加小标题,它们将适应您的列的宽度。
唯一的问题是当你的标题跨越多行时。在这种情况下,columntype 必须是p,但在不知道其宽度的情况下无法将列类型定义或更改为段落。

一种解决方案是使用表格。它与tabular*表格的总宽度基本相同并且需要表格的总宽度。但列将调整为单元格的较大自然宽度,并根据列说明符将其格式化为段落:居中 (C)、左锯齿状 (L)、右 (R) 或对齐 (J)。

这是一个说明这两种方法的示例。

\documentclass[array]{article}

\usepackage{graphicx}
\usepackage{tabulary}

\begin{document}
\begin{tabular}{cc}
  \includegraphics[height=0.25\textheight]{mushr1}
  &
  \includegraphics[height=0.25\textheight]{mushr2}
   \\                                                     
   Mushroom 1&Mushroom 2
 \end{tabular}

\begin{tabulary}{\linewidth}{CC}
  \includegraphics[height=0.25\textheight]{mushr1}
  &
  \includegraphics[height=0.25\textheight]{mushr2}
   \\                                                     
   Look how beautiful are these mushrooms!&
   Some others beautiful mushrooms. But these ones are very dangerous. Never eat them!
 \end{tabulary}
\end{document}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

居中和理由远非完美,但这可能是一个起点。


sam*_*ter 5

要获得投影仪格式的真实字幕,该varwidth软件包可以帮助:

\documentclass{beamer}
\usepackage{varwidth}

\begin{document}

\begin{frame}
    \begin{varwidth}{\textwidth}
        \begin{figure}
            \includegraphics[height=0.45\textheight]{example-image-duck}
            \caption{text}
        \end{figure}
    \end{varwidth}
    \hfill
    \begin{varwidth}{\textwidth}
        \begin{figure}
            \includegraphics[height=0.45\textheight]{example-image-golden-upright}
            \caption{text}
        \end{figure}
    \end{varwidth}
\end{frame} 

\end{document}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述