[Tex/LaTex] Can’t place figures side by side

ieeeconfsubfloatstikz-pgf

I'm trying to place two TiKz pictures side by side in a two-column document (IEEEtrans style). I've looked at various solutions, but each one that claims to place figures side by side only manages to place the plots one above the other:

enter image description here

Currently I'm trying to use the subfigure environment:

\documentclass[letterpaper, 10 pt, conference]{ieeeconf} 

\IEEEoverridecommandlockouts                           
\overrideIEEEmargins 


\usepackage{graphicx} 
\usepackage{amssymb}
\usepackage{algorithm}
\usepackage{algorithmic}
\newcommand{\tsc}[1]{\textsuperscript{#1}}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{subcaption} 
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\usepgfplotslibrary{groupplots}

\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}

\pgfplotsset{
tick label style={font=\tiny}, %axis numbers font size
label style={font=\small}, %axis labels font size
legend style={font=\tiny}
}


\begin{figure}
    \centering
    \begin{subfigure}[t]{0.48\textwidth}
        \centering
        %\input{figs/roc_curve.tikz}
        \resizebox{0.5\linewidth}{!}{\input{figs/roc.tikz}}  
        \caption{Caption A}
        \label{fig:A}
    \end{subfigure}
    \begin{subfigure}[b]{0.48\textwidth}
        \centering
        %\input{figs/roc_curve.tikz}
        \resizebox{0.5\linewidth}{!}{\input{figs/roc.tikz}}  
        \caption{Caption B}
        \label{fig:B}
    \end{subfigure}    
    \caption{ROC curve of failure detection;}
    \label{fig:roc_curve}
\end{figure}

(...)

\end{document}

What exactly is forcing the plots to become only vertically aligned?

Best Answer

You have to use \linewidth or \columnwidth instead of \textwidth in

\begin{subfigure}[b]{0.48\textwidth}

in both places. \textwidth is the width of entire text including both columns. For details on \linewidth and \textwidth please refer to this answer.

\documentclass[letterpaper,10 pt,conference]{ieeeconf}

\usepackage{graphicx,subcaption}

\begin{document}
\begin{figure}
    \centering
    \begin{subfigure}[b]{0.48\linewidth}        %% or \columnwidth
        \centering
        \includegraphics[width=\linewidth]{example-image-a}
        \caption{Caption A}
        \label{fig:A}
    \end{subfigure}
    \begin{subfigure}[b]{0.48\linewidth}        %% or \columnwidth
        \centering
        \includegraphics[width=\linewidth]{example-image-b}
        \caption{Caption B}
        \label{fig:B}
    \end{subfigure}
    \caption{ROC curve of failure detection;}
    \label{fig:roc_curve}
\end{figure}

(...)

\end{document}

enter image description here

I have used [b] for both the subfigures to align them properly.