latexoverleafsubfigure

put figures side-by-side does not work in overleaf version of TSP journals


I am using the overleaf template of TSP.cls journal. I need to put 4 figures side-by-side. I used the following code, it works with other overleaf templates but does not work with TSP.cls template.

can anyone help?

\documentclass[12pt,fleqn]{tsp}
\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{caption}
\usepackage{subcaption}


\begin{figure*}[t!]
\centering
\begin{subfigure}{0.2\linewidth}
\includegraphics[width=\linewidth,height = 4cm]{a.png}
\captionsetup{justification=centering}
\caption{}
\label{}
\end{subfigure}
\begin{subfigure}{0.2\linewidth}
\includegraphics[ width=\linewidth,height = 4cm ]{a.png}
\captionsetup{justification=centering}
\caption{}
\label{}
\end{subfigure}
\begin{subfigure}{0.2\linewidth}
\includegraphics[width=\linewidth, height =4cm ]{a.png}
\captionsetup{justification=centering}
\caption{}
\label{}
\end{subfigure}
\begin{subfigure}{0.2\linewidth}
\includegraphics[ width=\linewidth, height = 4cm ]{a.png}
\captionsetup{justification=centering}
\caption{}
\label{}
\end{subfigure}
\caption{}
\label{box_plots}
\end{figure*}


\end{document}

Solution

  • The tsp class loads the subfigure package. Use the syntax from this package instead of trying to combine this with the subcaption package.

    \documentclass[12pt,fleqn]{tsp}
    \usepackage{adjustbox}
    
    \begin{document}
    
    \begin{figure*}[t!]
    \centering 
    \subfigure[First.\label{bar}]{\includegraphics[width=.2\linewidth]{example-image-duck}}
    \subfigure[Second.\label{foo}]{\includegraphics[width=.2\linewidth]{example-image-duck}}
    \caption{caption}
    \label{box_plots}
    \end{figure*}
    
    \end{document}
    

    enter image description here