TransWikia.com

How can I place the subfigures vertically?

TeX - LaTeX Asked by chico0913 on January 21, 2021

I am trying to place two subfigures vertically. The code I am using is:

begin{figure*}[htp]
  centering
 includegraphics[width=15.0cm, height=4.6cm,keepaspectratio]{Figure2.png}
 caption{Caption1}label{fig2a}
 includegraphics[width=15.0cm,height=4.6cm,keepaspectratio]{Figure2.png}
 caption{caption2}label{fig2b}
caption{caption3}label{fig2}
end{figure*}

Which places figure like below:
enter image description here

But I want LaTex to treat each of the two figures as subfigures, so for example, I want to have subcaptions for each figure like ‘a) model 1’ and ‘b) model 2’. So I don’t get the captions ‘Figure2’ and ‘Figure3’ underneath each figure. How can I do this? Thank you,

Note: I need to use figure* instead of figure because my LaTeX template is 2-columned for texts. The template can be accessed at https://www.overleaf.com/latex/templates/instructions-for-naacl-hlt-2019-proceedings/xyyfwfkswhth

One Answer

Try t use subfigure defined in the subcaption package:

documentclass[twocolumn]{article} 
usepackage[demo]{graphicx}
usepackage{caption}
usepackage{subcaption}  % <----

begin{document}
begin{figure*}
  centering
  setkeys{Gin}{width=15.0cm, height=4.6cm,keepaspectratio}
begin{subfigure}{15cm}  % <----
 includegraphics{Figure2.png}
 caption{Model 1}
 label{fig1a}
end{subfigure}

begin{subfigure}{15cm}  % <----
 includegraphics{Figure2.png}
 caption{Model 2}
 label{fig1b}
end{subfigure}
%
caption{Models}
label{fig2}
end{figure*}
end{document}

which gives

enter image description here

Correct answer by Zarko on January 21, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP