1

I am trying to insert pictures side by side. I used the minipage method after having no luck with the subfigure method. Here's my code,

\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}

But the Output I get has no alignment of the images. I tried to use "scale" as well as the "width=, height=" commands, but I'm not doing something right. Can someone tell me what's wrong or tell me what to do in the subfigure method?

enter image description here

3
  • you used [b] so as your post shows they are aligned on the last line of the captions. Commented May 3, 2021 at 18:48
  • What happens if you replace \hspace{2cm} with \hspace{\fill}?
    – Mico
    Commented May 3, 2021 at 18:49
  • Consider accepting the provided answer sine it seems to have solved the problem according to your comment, Commented Dec 10, 2021 at 3:38

1 Answer 1

2

Use \begin{minipage}[t]

enter image description here

\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}

Using subfigures the captions will be different (of course)

Adding \usepackage{subcaption}

c

with this code

\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}
1
  • Thank you for your answer! I tried this way, but my figures were further misplaced, but I hadn't known about the placement thing here. I learnt it from your answer, so I got it to work with [c].
    – SM32
    Commented May 4, 2021 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .