TeX - LaTeX Asked on April 23, 2021
I use cas-dc class of Elsevier in Overleaf. I want to put a figure with some subfigures in two-column paper and my code is as follows:
documentclass[a4paper,fleqn,twocolumn]{cas-dc}
usepackage{natbib}
usepackage{adjustbox}
usepackage{appendix,booktabs}
usepackage{lipsum}
usepackage{mathtools, cuted}
usepackage{autobreak}
usepackage[utf8]{inputenc}
usepackage{nccmath}
usepackage{lipsum}
usepackage{flushend}
usepackage{amsmath}
usepackage{afterpage}
usepackage{url}
usepackage{amsfonts,amsmath,amssymb,amstext,amsthm,xspace,pdfsync,enumerate,graphicx}
usepackage{float}
usepackage{algpseudocode}
usepackage{siunitx}
usepackage[ruled]{algorithm}
usepackage[font=footnotesize,labelfont=bf]{caption}
usepackage[font=footnotesize,labelfont=bf]{subcaption}
allowdisplaybreaks
PassOptionsToPackage{noend}{algpseudocode}% comment out if want end's to show
usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
errorcontextlinesmaxdimen
begin{document}
lipsum[11]
begin{figure*}
begin{subfigure}{.5textwidth}
centering
includegraphics[width=7cm,height=6cm]{10.png}
caption{ 10 }
label{10}
end{subfigure}
begin{subfigure}{.5textwidth}
centering
includegraphics[width=7cm,height=6cm]{100.png}
caption{ 100 }
label{100}
end{subfigure}
begin{subfigure}{.5textwidth}
centering
includegraphics[width=7cm,height=6cm]{500.png}
caption{500}
label{500}
end{subfigure}
begin{subfigure}{.5textwidth}
centering
includegraphics[width=7cm,height=6cm]{1000.png}
caption{1000}
label{1000}
end{subfigure}
begin{subfigure}{.5textwidth}
centering
includegraphics[width=7cm,height=6cm]{5000.png}
caption{5000}
label{5000}
end{subfigure}
caption{Comparison }
label{Comparison }
end{figure*}
end{document}
But all figures have been shown in one column and two of them and also the caption have been shown out of the page (under the footnote) such that I cannot see them.
When I use elsarticle class instead of cas-dc:
documentclass[a4paper,fleqn]{elsarticle}
it works correctly and all sub figures are in two column.
How can I fix the problem with cas-dc class?
The document class cas-dc
include some packages (for example graphicx
) and also redefine them. It also require that some package had to be loaded in preamble, for example packages related to bibliography.
After rearranging your figure
code, I obtain the following result:
MWE:
documentclass[demo,
a4paper,fleqn]
{cas-dc} % this give one column document
% regardless that it is declared
% as two columns document
usepackage{subcaption}
usepackage{natbib} % cas-cd require that this or similar bib package is loaded
usepackage{lipsum} %
begin{document}
lipsum[11]
begin{figure}
centering
setkeys{Gin}{width=linewidth,height=6cm} %set image parameters
begin{subfigure}{6cm}
includegraphics{10.png}
caption{ 10 }
label{10}
end{subfigure}
hfil
begin{subfigure}{6cm}
includegraphics{100.png}
caption{ 100 }
label{100}
end{subfigure}
medskip
begin{subfigure}{6cm}
includegraphics{500.png}
caption{500}
label{500}
end{subfigure}
hfill
begin{subfigure}{6cm}
includegraphics{1000.png}
caption{1000}
label{1000}
end{subfigure}
medskip
begin{subfigure}{6cm}
includegraphics{5000.png}
caption{5000}
label{5000}
end{subfigure}
%
caption{Comparison }
label{Comparison }
end{figure}
end{document}
Edit: In the case that you like to have two column document, than you need to add option ˙twocolumn` int document class options:
documentclass[demo,
a4paper,fleqn,
twocolumn]{cas-dc}% now the document has two columns
and than for figures over two column use instead figure
float figure*
, as you use in the your document example. With this changes the result is
Edit (2)
For unknown reason cas-dc
doesn't produce two columns document without option twocolumn
(tested with my local installation of MikTeX and with Overleaf service). Anyway, the second example has two columns and images are spread over two columns of text regardless how it is obtained.
Addendum: In your document preamble are some packages duplicated and in a wrong order. So I try to clean-up and reorganize so that it has a more consistent pattern. At this I wonder, are you really need all these packages?
See, if the following preamble works for you:
documentclass[demo,
a4paper,fleqn,
twocolumn]{cas-dc}
%usepackage[utf8]{inputenc} at new LaTeX version it is default
usepackage{natbib}
%math
usepackage{nccmath, mathtools} % nccmath had to be first, than mathtools
allowdisplaybreaks
usepackage{amssymb,amsthm,xspace}
usepackage{autobreak} % not recommended
% tables, units
usepackage{booktabs}
usepackage{siunitx}
% lists
usepackage{enumerate}
% miscellaneous
usepackage{appendix}
usepackage{flushend}
usepackage{afterpage}
usepackage{cuted, float}
usepackage{adjustbox}
usepackage[font=footnotesize,labelfont=bf]{subcaption}
% algorithms
usepackage{algpseudocode}
PassOptionsToPackage{noend}{algpseudocode}% comment out if want end's to show
usepackage[ruled]{algorithm}
usepackage{url}
errorcontextlinesmaxdimen
usepackage{lipsum} % for dummy text, not needed in real document
Correct answer by Zarko on April 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP