TransWikia.com

How to make Three figures in one horizontal Line in Latex?

TeX - LaTeX Asked on May 15, 2021

I am trying to make these three figures in one horizontal line using overleaf latex but it is not giving me the desired results, here is the example code

begin{figure*}[!t]
  centering
  subfigure[]{includegraphics[width=3.2in]{fig4a.png}}
  subfigure[]{includegraphics[width=3.2in]{fig4b.png}}
  subfigure[]{includegraphics[width=3.2in]{fig4c.png}}
  caption{desired caption}
  label{fig_4}
end{figure*}

Example output, here each box is the example of image
enter image description here

Desired output
enter image description here

Where do I go wrong?, Please I need your assistant

2 Answers

As far as I see, if the width of your figures exceeds the maximum width of your document so if you change the width values in subfigure[]{includegraphics[width=3.2in]{fig4a.png}}. Then the figures can stay together side by side.

Correct answer by Ali Ss on May 15, 2021

Your code sniped :

  • It seems that your images are to wide that can be fit in one line. As a cure define their width as fraction of the text width (since all have the same width, you can use keys Gin (See MWE below)
  • In code you use subfigure[]{...}, which are defined by deprecated package subfigure.
  • Since your in code fragment aren't present subcaptions, there is no reason to use subfigure or packages by which it is replaced (subfig or even better is to use subcaptions).
  • Please, in future questions always provide MWE (Minimal Working Example, a small but complete document, which compilation reproduce your problem).

An example of MWE can serve:

documentclass[twocolumn]{article}
usepackage{graphicx}

%---------------- show page layout. don't use in a real document!
usepackage{showframe}
renewcommandShowFrameLinethickness{0.15pt}
renewcommand*ShowFrameColor{color{red}}
%---------------------------------------------------------------%

begin{document}
    begin{figure*}
centering
setkeys{Gin}{width=0.32linewidth}
includegraphics{example-image-duck}%{fig4a.png}}  % we haven't your images ...
hfill
includegraphics{example-image-duck}%{fig4b.png}}
hfill
includegraphics{example-image-duck}%{fig4c.png}}
    caption{desired caption}
label{fig_4}
    end{figure*}
end{document}

enter image description here

(red lines indicate text borders in your document)

Answered by Zarko on May 15, 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