Table Drawing (Part Four) - Side by Side Figures

Table Drawing (Part Four): Side by Side Figures #

Author: Erhua

Keywords: figures, side by side

The floating environment in LaTeX does not restrict the content within the environment. Therefore, placing several figures within a floating body can achieve side by side or mixed arrangement. The functionality can generally be achieved using the minipage environment.

\begin{minipage}[position][height][inner-pos]{width}
text
\end{minipage}

Side by Side Figures #

Example 1: Two images with the same height, captions displayed in one 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 images with different heights, captions cannot be displayed in one line using the above method, using different captions.

\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 with their own subtitles, shared title, how to set 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: Combining one image 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
Jinse&Wuduan&Wushi Xian,\\
\midrule
Yi Xian&Yi Zhu& Si Hua Nian,\\
Zhuang Sheng&Xiao Meng&Mi Hu Die,\\
Wang Di&Chun Shen&Tuo Du Juan,\\
\bottomrule
\end{tabular}
\end{minipage}
\centering
\caption{One Figure and One Table}
\end{figure}
\end{document}

References: