以双列样式嵌入两个并排的图形。(不跨越整个页面,只占第二列)

以双列样式嵌入两个并排的图形。(不跨越整个页面,只占第二列)

我有一个典型的 2 列日记模板。我想在第二列插入两个并排的图表。我该怎么做?

我现在的代码是这样的,但是图片从来没有出现过。[图片路径没问题。不是那个问题]

我编辑了我的文件,希望您能直接重现我的问题。要重现,请figure在当前目录下创建一个目录,并将两个图像文件放在fig_1a.png那里fig_1b.png。谢谢!!1

- -更新 - -

我收到了这个警告。

Package multicol Warning: Floats and marginpars not allowed inside `multicols' 
environment!.

这似乎表明这里不支持浮点数。

\documentclass[twoside]{article}
\renewcommand{\thesubsection}{\Alph{subsection} ) }
% ------
% Multiple figures 
\usepackage{subcaption}
\usepackage{graphicx}
\DeclareGraphicsExtensions{.png,.jpg}
\graphicspath{{./figure/}}

% \graphicspath{/home/xushunyi/infocom/figure/}
% \newcommand{\figureroot}{/home/xushunyi/infocom/figure/}
% ------
% Fonts and typesetting settings
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05} % Palatino needs more space between lines
\usepackage{microtype}


% ------
% Page layout
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt, left=2cm, right=2cm]{geometry}
\usepackage[font=it]{caption}
\usepackage{paralist}
\usepackage{multicol}

% ------
% Lettrines
\usepackage{lettrine}


% ------
% Abstract
\usepackage{abstract}
    \renewcommand{\abstractnamefont}{\normalfont\bfseries}
    \renewcommand{\abstracttextfont}{\normalfont\small\itshape}


% ------
% Titling (section/subsection)
\usepackage{titlesec}
\renewcommand\thesection{\Roman{section}}
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{}


% ------
% Header/footer
\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \fancyhead[C]{Journal paper template $\bullet$ April 2012 $\bullet$ Vol. XXI, No. 1}
    \fancyfoot[RO,LE]{\thepage}


% ------
% Clickable URLs (optional)
\usepackage{hyperref}

% ------
% Maketitle metadata
\title{\vspace{-15mm}%
    \fontsize{24pt}{10pt}\selectfont
    \textbf{Long Titles Look More Impressive Than Short Ones}
    }   
\author{%
    \large
    \textsc{Jonathan S. Doe}\thanks{Template by \href{http://www.howtotex.com}{howtoTeX.com}} \\[2mm]
    \normalsize University of Technology, Delft \\
    \normalsize \href{mailto:[email protected]}{[email protected]}
    \vspace{-5mm}
    }
\date{}



%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle
\thispagestyle{fancy}

\begin{abstract}
\noindent I am abstract

\end{abstract}


\begin{multicols}{2}

hendrerit aliquet porttitor.

\section{Introduction}
This is intro
\begin{compactitem}
\item
ccccccccccccccccccccinformed decision
\item 
bbbbbbbbbbbbbbbbnetwork. 
\item 
aaaaaaaaaaaa
\end{compactitem}

\begin{itemize}
\item werwerwerwerwerwer
\item sdgfsdfswerwrwerwer
\item gsdgsgsdgsdgdgsgsdgsdg
\item ...
\end{itemize}

Two figures standing side by side spanning the second columns should appear here. But I see nothing!!!! 



\begin{figure}[!h]
\centering
\begin{subfigure}[h]{0.45\columnwidth}
  \centering
  \includegraphics[width=.4\columnwidth]{fig_1a}
  \caption{1a}
  \label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}[h]{0.45\columnwidth}
  \centering
  \includegraphics[width=.4\columnwidth]{fig_1b}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig1}
\end{figure}

what do you think is the reason?

\section{Algorithm Design}

\section{Evalutation}

\section{Conclusion}

\end{multicols}

\end{document}

答案1

由于multicols不允许浮动环境(这解释了为什么你看不到任何图形),此提案定义了一个名为 的新环境。如你所见,浮动属性被抑制,它会锚定在你想要的位置。此环境也已在包中的命令figurehere上进行了测试。删除中的选项以显示正确的图像subcaptionboxsubcaption[demo]graphicx

在此处输入图片描述

代码

\documentclass[twoside]{article}
\renewcommand{\thesubsection}{\Alph{subsection} ) }
% ------
% Multiple figures 
\usepackage{subcaption}
\usepackage[demo]{graphicx}
\DeclareGraphicsExtensions{.png,.jpg}
\graphicspath{{./figure/}}

% \graphicspath{/home/xushunyi/infocom/figure/}
% \newcommand{\figureroot}{/home/xushunyi/infocom/figure/}
% ------
% Fonts and typesetting settings
\usepackage[sc]{mathpazo}
\usepackage[T1]{fontenc}
\linespread{1.05} % Palatino needs more space between lines
\usepackage{microtype}


% ------
% Page layout
\usepackage[hmarginratio=1:1,top=32mm,columnsep=20pt, left=2cm, right=2cm]{geometry}
\usepackage[font=it]{caption}
\usepackage{paralist}
\usepackage{multicol}

% ------
% Lettrines
\usepackage{lettrine}


% ------
% Abstract
\usepackage{abstract}
    \renewcommand{\abstractnamefont}{\normalfont\bfseries}
    \renewcommand{\abstracttextfont}{\normalfont\small\itshape}


% ------
% Titling (section/subsection)
\usepackage{titlesec}
\renewcommand\thesection{\Roman{section}}
\titleformat{\section}[block]{\large\scshape\centering}{\thesection.}{1em}{}


% ------
% Header/footer
\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhead{}
    \fancyfoot{}
    \fancyhead[C]{Journal paper template $\bullet$ April 2012 $\bullet$ Vol. XXI, No. 1}
    \fancyfoot[RO,LE]{\thepage}


% ------
% Clickable URLs (optional)
\usepackage{hyperref}

% ------
% Maketitle metadata
\title{\vspace{-15mm}%
    \fontsize{24pt}{10pt}\selectfont
    \textbf{Long Titles Look More Impressive Than Short Ones}
    }   
\author{%
    \large
    \textsc{Jonathan S. Doe}\thanks{Template by \href{http://www.howtotex.com}{howtoTeX.com}} \\[2mm]
    \normalsize University of Technology, Delft \\
    \normalsize \href{mailto:[email protected]}{[email protected]}
    \vspace{-5mm}
    }
\date{}

\makeatletter
\newenvironment{figurehere}
{\def\@captype{figure}}
{}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\maketitle
\thispagestyle{fancy}

\begin{abstract}
\noindent I am abstract

\end{abstract}


\begin{multicols}{2}

hendrerit aliquet porttitor.

\section{Introduction}
This is intro
\begin{compactitem}
\item
ccccccccccccccccccccinformed decision
\item 
bbbbbbbbbbbbbbbbnetwork. 
\item 
aaaaaaaaaaaa
\end{compactitem}

\begin{itemize}
\item werwerwerwerwerwer
\item sdgfsdfswerwrwerwer
\item gsdgsgsdgsdgdgsgsdgsdg
\item ...
\end{itemize}

Two figures standing side by side spanning the second columns should appear here. But I see nothing!!!! 

\begin{figurehere}
\centering
\begin{subfigure}[h]{0.45\columnwidth}
  \centering
  \includegraphics[width=.4\columnwidth]{fig_1aa}
  \caption{1a}
  \label{fig:sfig1}
\end{subfigure}%
\begin{subfigure}[h]{0.45\columnwidth}
  \centering
  \includegraphics[width=.4\columnwidth]{fig_1bb}
  \caption{1b}
  \label{fig:sfig2}
\end{subfigure}
\caption{plots of....}
\label{fig:fig1}
\end{figurehere}
\columnbreak
what do you think is the reason?
%
\begin{figurehere}
\centering
\subcaptionbox{2a}
{\includegraphics[width=0.45\columnwidth]{fig2a}}
  \label{fig:sfig2a}
%
\subcaptionbox{1b}
{\includegraphics[width=0.45\columnwidth]{fig2b}}
  \label{fig:sfig2b}
\caption{plots of....}
\label{fig:fig2}
\end{figurehere}

\section{Algorithm Design}

\section{Evalutation}

\section{Conclusion}

\end{multicols}

\end{document}

相关内容