并排放置两个带标题的图像并在 Latex 中控制它们的高度
Put two images with captions side by side and control their height in Latex
我想在 latex/beamer 演示文稿中对齐两张图片。
它们没有相同的 width/height 比例,我想控制整体高度。
如果我不需要字幕,下面的方法就可以了:
\includegraphics[height=0.35\textheight]{im1.png}
\hfill
\includegraphics[height=0.35\textheight]{im2.png}
这里注意,我不需要输入图片宽度,我也不想输入。
但是一旦我需要添加标题,我就会使用两个 figure
环境将图形放在两行中。
解决方案是将两个 figure
环境插入到 minipages 中,但我必须计算两个 minipages 的宽度以符合我想要的平均高度。
是否可以避免计算小页面的宽度?
您可以将图片放在表格中。
您可以添加小标题,它们会适应您的列的宽度。
唯一的问题是当您的标题跨越多行时。在这种情况下,columntype 必须是 p
,但在不知道其宽度的情况下无法将列类型定义或更改为段落。
一种解决方案是使用表格。它与 tabular*
基本相同,需要 table 的总宽度。但列将调整为其单元格的较大自然宽度,并根据列说明符格式化为段落:居中 (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}
居中和对齐还远非完美,但这可能是一个起点。
要获得 beamer 格式的真实字幕,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}
在 Beamer 中,我尝试了 \column 和 \minipage environmnet 来并排放置数字。但是没有正常工作并且存在对齐问题。最后,以下解决方案通过使用 \usepackage{subfigure}.
\begin{figure}
\centering
\mbox{\subfigure{\includegraphics[width=5.5cm, height=4.8cm]{suppopicture3}}\quad
\subfigure{\includegraphics[width=3.0cm, height=4.5cm]{Figure 3_HR-TEM_result} }}
\caption{Text pertaining to both graphs ...} \label{fig12}
\end{figure}
参考:- https://www.johndcook.com/blog/2009/01/14/how-to-display-side-by-side-figurs-in-latex/
我想在 latex/beamer 演示文稿中对齐两张图片。 它们没有相同的 width/height 比例,我想控制整体高度。
如果我不需要字幕,下面的方法就可以了:
\includegraphics[height=0.35\textheight]{im1.png}
\hfill
\includegraphics[height=0.35\textheight]{im2.png}
这里注意,我不需要输入图片宽度,我也不想输入。
但是一旦我需要添加标题,我就会使用两个 figure
环境将图形放在两行中。
解决方案是将两个 figure
环境插入到 minipages 中,但我必须计算两个 minipages 的宽度以符合我想要的平均高度。
是否可以避免计算小页面的宽度?
您可以将图片放在表格中。
您可以添加小标题,它们会适应您的列的宽度。
唯一的问题是当您的标题跨越多行时。在这种情况下,columntype 必须是 p
,但在不知道其宽度的情况下无法将列类型定义或更改为段落。
一种解决方案是使用表格。它与 tabular*
基本相同,需要 table 的总宽度。但列将调整为其单元格的较大自然宽度,并根据列说明符格式化为段落:居中 (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}
居中和对齐还远非完美,但这可能是一个起点。
要获得 beamer 格式的真实字幕,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}
在 Beamer 中,我尝试了 \column 和 \minipage environmnet 来并排放置数字。但是没有正常工作并且存在对齐问题。最后,以下解决方案通过使用 \usepackage{subfigure}.
\begin{figure}
\centering
\mbox{\subfigure{\includegraphics[width=5.5cm, height=4.8cm]{suppopicture3}}\quad
\subfigure{\includegraphics[width=3.0cm, height=4.5cm]{Figure 3_HR-TEM_result} }}
\caption{Text pertaining to both graphs ...} \label{fig12}
\end{figure}
参考:- https://www.johndcook.com/blog/2009/01/14/how-to-display-side-by-side-figurs-in-latex/