Drawing Tables (Part Four): Placing Figures Side by Side #
Author: Er Flower
Keywords: figures, side by side
The floating environments in LaTeX do not restrict the contents of the environment. Therefore, you can place several figures in one floating body to achieve side-by-side or mixed placement. The minipage environment is generally used to achieve this.
\begin{minipage}[position][height][inner-pos]{width}
text
\end{minipage}
Placing Figures Side by Side #
Example 1: Two figures with the same height, captions can be displayed on the same line using different captions.
\documentclass[]{article}
\usepackage{ctex}
\begin{document}
\begin{figure}[htp]
\begin{minipage}{0.48\linewidth}
\centering
\includegraphics [height = 3cm]{/Users/fplee/blog/public/xiaobo.png}
\caption{ Xiaobo }
\end{minipage}
\begin{minipage}{0.48\linewidth}
\centering
\includegraphics [height = 3cm]{/Users/fplee/blog/public/yeyuqiudeng.jpg}
\caption{ Yeyuqiudeng }
\end{minipage}
\end{figure}
\end{document}
Example 2: Two figures with different heights, captions cannot be displayed on the same line using the above method.
\documentclass[]{article}
\usepackage{ctex}
\usepackage{graphics}
\begin{document}
\begin{figure}[htbp]
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics [height = 1.5cm]{/Users/fplee/blog/public/yeyuqiudeng.jpg}
\quad
\end{minipage}
\begin{minipage}{0.45\textwidth}
\centering
\includegraphics [height = 6cm]{/Users/fplee/blog/public/xiaobo.png}
\end{minipage}
\vskip 5mm
\begin{minipage}{0.45\textwidth}
\caption{Yeyuqiudeng}
\end{minipage}
\quad
\begin{minipage}{0.45\textwidth}
\caption{Xiaobo}
\end{minipage}
\end{figure}
\end{document}
Example 3: Images or tables have their own sub-captions, but share a common main caption. How to set this?
Use the caption and subcaption packages
\documentclass[]{article}
\usepackage{caption,subcaption}
\usepackage{ctex}
\begin{document}
\begin{figure}[htp]
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics [height = 3cm]{/Users/fplee/blog/public/xiaobo.png}
\subcaption{ Xiaobo }
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics [height = 3cm]{/Users/fplee/blog/public/yeyuqiudeng.jpg}
\subcaption{ Yeyuqiudeng }
\end{minipage}
\centering
\caption{Two Figures}
\end{figure}
\end{document}
Example 4: Mixing one figure and one table side by side.
\documentclass[]{article}
\usepackage{caption,subcaption}
\usepackage{booktabs}
\usepackage{ctex}
\begin{document}
\begin{figure}[htp]
\centering
\begin{minipage}{0.48\textwidth}
\centering
\includegraphics [height = 3cm]{/Users/fplee/blog/public/xiaobo.png}
\subcaption{ Xiaobo }
\end{minipage}
\begin{minipage}{0.48\textwidth}
\centering
\subcaption{ Yeyuqiudeng }
\begin{tabular}{c|c|c}
\toprule
Jinse & Wuduan & Wushi Xian, \\
\midrule
Yi Xian & Yi Zhu & Si Hua Nian, \\
Zhuangsheng & Xiao Meng & Mi Hudie, \\
Wangdi & Chunshen & Tuo Dujuan, \\
\bottomrule
\end{tabular}
\end{minipage}
\centering
\caption{One Figure and One Table}
\end{figure}
\end{document}
References: