TransWikia.com

Centre an image in two-column article while using multicols and figure*

TeX - LaTeX Asked by Srivatsan on July 25, 2021

I have 5 images in a two-column article which as of now using multicols and figure* appear like this.

begin{figure*} 
begin{multicols}{2}
    includegraphics[width=linewidth]{0.001.eps}par 
    includegraphics[width=linewidth]{0.005.eps}par 
    end{multicols}
begin{multicols}{2}
    includegraphics[width=linewidth]{0.010.eps}par
    includegraphics[width=linewidth]{0.030.eps}par
end{multicols}
begin{multicols}{2}
    includegraphics[width=linewidth]{0.050.eps}par 
end{multicols}
caption{Here is the caption}
label{here is the label}
end{figure*}

enter image description here

However I would like to center the last image. How do I achieve it?

3 Answers

I have managed to solve it using the tabular environment!

begin{figure*}
centering
  begin{tabular}{@{}cc@{}}
    includegraphics[width=0.49linewidth]{0.001.eps} &
    includegraphics[width=0.49linewidth]{0.005.eps}   
    includegraphics[width=0.49linewidth]{0.010.eps} &
    includegraphics[width=0.49linewidth]{0.030.eps}   
    multicolumn{2}{c}{includegraphics[width=0.49linewidth]{0.050.eps}}
  end{tabular}
  caption{Here is the caption}
end{figure*}

Here by using multicolumn{2}{c}{includegraphics[width=0.49linewidth] the last figure get's centered!

Correct answer by Srivatsan on July 25, 2021

The lazy way could be to use just hspaces; something like

documentclass[12pt,a4paper,twocolumn]{scrartcl}
usepackage{graphicx}

begin{document}
begin{figure*}centering
includegraphics[width=0.48linewidth]{example-image-a}
hspace{.005linewidth} 
includegraphics[width=0.48linewidth]{example-image-b}
[.5baselineskip]
includegraphics[width=0.48linewidth]{example-image-a}
hspace{.005linewidth} 
includegraphics[width=0.48linewidth]{example-image-b}
[.5baselineskip]
includegraphics[width=0.48linewidth]{example-image-a}
caption{5 Images.}
end{figure*}
end{document}

which yields something like hspace approach

Note that here, the linebreaks are extended by half a baseline to introduce space between the images.

I would favour, however, a solution with subcaption which also allows for referencing subfigures (i.e. Fig. 1(a) and such) using

documentclass[12pt,a4paper,twocolumn]{scrartcl}
usepackage{graphicx,subcaption}

begin{document}
begin{figure*}centering
    begin{subfigure}{.49linewidth}
      includegraphics[width=0.98linewidth]{example-image-a}
        caption{First.}
    end{subfigure}
    begin{subfigure}{.49linewidth}
     includegraphics[width=0.98linewidth]{example-image-b}
        caption{Second.}
    end{subfigure}
    begin{subfigure}{.49linewidth}
     includegraphics[width=0.98linewidth]{example-image-a}
        caption{Third.}
    end{subfigure}
    begin{subfigure}{.49linewidth}
     includegraphics[width=0.98linewidth]{example-image-b}
        caption{Fourth.}
    end{subfigure}
    begin{subfigure}{.49linewidth}
     includegraphics[width=0.98linewidth]{example-image-a}
        caption{Fifth.}
    end{subfigure}
caption{5 Images.}
end{figure*}
end{document}

Which yields Subcaption approach Note that this needs relative sizes internally, i.e. linewidth in the subfigure refers to the width of the subfigure itself. This can further be styled by using the options from subcaption (sublabel style spacing and so on). And maybe you want to use centering also inside the subfigures - I'll leave the code as it is, because it directly generates the corresponding image.

Answered by Ronny on July 25, 2021

This code can be used for subfigure with three plots

begin{figure*} centering %%% not center subfigure[Figure A]{label{fig:a}includegraphics[width=0.4linewidth]{images/congestion_less.pdf}} subfigure[Figure B]{label{fig:b}includegraphics[width=0.4linewidth]{images/congestion_medium.pdf}} parmedskip subfigure[Figure B]{label{fig:b}includegraphics[width=0.4linewidth]{images/congestion_high.pdf}} caption{my caption} end{figure*}enter image description here

Answered by Vishaka Basnayake on July 25, 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