Drawing Tables (Part Four): 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, placing several figures or tables in a float can achieve side-by-side or mixed arrangement. The minipage
environment is generally used to achieve this function.
\begin{minipage}[position][height][inner-pos]{width}
text
\end{minipage}
Side-by-Side Figures #
Example 1: Two figures with the same height, captions can be displayed on 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 figures with different heights, captions cannot be displayed on 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: If the image or table has its own subcaption, how to set a common caption
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 a Figure with a 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 & Wushixian, \\
\midrule
Yixian & Yizhu & Sihuanian, \\
Zhuangsheng & Xiaomeng & Mihudie, \\
Wangdi & Chunshen & Tuodujuan, \\
\bottomrule
\end{tabular}
\end{minipage}
\centering
\caption{One Figure and One Table}
\end{figure}
\end{document}
Reference: