Drawing Tables (Part 4): Side-by-Side Figures #
Author: Erhua
Keywords: figures, side-by-side
The floating environment in LaTeX does not limit the content of the environment. Therefore, putting several figures in a float can achieve side-by-side or mixed arrangements. Generally, the minipage environment is used to achieve this.
\begin{minipage}[position][height][inner-pos]{width}
text
\end{minipage}
Side-by-Side Figures #
Example 1: Two images with the same height, captions can fit on one line, different captions are used.
\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 images with different heights, captions cannot fit on one 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: Figures or tables with their own subtitles and a common main title. How to set it up.
Using 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: Side-by-side placement of one figure and one table.
\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
锦瑟&无端&五十弦、\
\midrule
一弦&一柱&思华年、\
庄生&晓梦&迷蝴蝶、\
望帝&春深&托杜鹃、\
\bottomrule
\end{tabular}
\end{minipage}
\centering
\caption{One Figure and One Table}
\end{figure}
\end{document}
Reference: