我正在尝试并排插入图片。在使用 subfigure 方法失败后,我使用了 minipage 方法。这是我的代码,
\begin{figure}[h]
\centering
\begin{minipage}[b]{.4\textwidth}
\vspace{0pt}
\includegraphics[scale=.5]{undamped_input_filter}
\caption{\small{Bode plots of \textcolor{red}{undamped filter},\textcolor{blue}
{converter input impedance}}}
\label{fig:bodefilteru}
\end{minipage}
\hspace{2cm}
\begin{minipage}[b]{.45\textwidth}
\centering
\vspace{0pt}
\includegraphics[width=4cm, height=3cm]{undamped_input_filter_ckt}
\caption{\small{LC filter circuit}}
\label{fig:LCfilter}
\end{minipage}
\end{figure}
但是我得到的输出没有对齐图像。我尝试使用“scale”以及“width=, height=”命令,但做得不对。有人能告诉我哪里出了问题或者告诉我在 subfigure 方法中该怎么做吗?
答案1
使用\begin{minipage}[t]
\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{xcolor}
\begin{document}
\begin{figure}[h]
\centering
\begin{minipage}[t]{.4\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption{\small Bode plots of \textcolor{red}{undamped filter}, \textcolor{blue}{converter input impedance}}
\label{fig:bodefilteru}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\textwidth}
\centering
\includegraphics[width=4cm, height=3cm]{example-image-a}
\caption{\small LC filter circuit}
\label{fig:LCfilter}
\end{minipage}
\end{figure}
\end{document}
使用子图时标题会有所不同(当然)
添加\usepackage{subcaption}
使用此代码
\begin{figure}
\centering
\begin{subfigure}[t]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\caption{\small Bode plots of \textcolor{red}{undamped filter}, \textcolor{blue}{converter input impedance}}
\label{fig:bodefilteru}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=4cm, height=3cm]{example-image-a}
\caption{\small LC filter circuit}
\label{fig:LCfilter}
\end{subfigure}
\caption{\small Two filters}
\end{figure}