我想将两个图形和一个算法并排放在一个双列文档中,并且图形和算法应该跨越两列。
我调查过之前被问到的问题,例如如何将算法和图形并列在一起?和如何在双栏文档中并排放置两个图表不要回答我的问题。
以下是 MWE,其中包含我使用的图形和算法模板。如果您尝试运行代码,请重命名eps
您获得的任何图形,xx.esp
并将yy.eps
其与以下文档放在同一目录中。
\documentclass[conference]{IEEEtran}
\usepackage[ruled]{algorithm}
\usepackage{algpseudocode}
%\usepackage{subfigure}
\usepackage{graphicx}
\usepackage{times}
\usepackage{amssymb}
\usepackage{url}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{wrapfig}
\begin{document}
\title{xxx}
\maketitle
\begin{figure*}[!t]
\centering
\begin{minipage}[htp]{0.32\textwidth}
\centering
\includegraphics[width=1\textwidth]{xx.eps}
\vspace{-0.4cm}%
\caption{THis is figure xx}\label{fig:xx}
\end{minipage}
\begin{minipage}[htp]{0.32\textwidth}
\centering
\includegraphics[width=1\textwidth]{yy.eps}
\vspace{-0.4cm}%
\caption{This is figure yy.}\label{fig:yy}
\end{minipage}
\vspace{-0.6cm}%
\end{figure*}
\vspace{-0.2cm}%
\alglanguage{pseudocode}
\begin{algorithm}[h]
\small
\caption{\small Insert item into Hash Table (with mCBF and aCBF)}
\label{Algorithm:insert_mCBF_aCBF}
\begin{algorithmic}[1]
\Procedure{$\mathbf{InsertItem}$}{item $x$}
\For {$i = 1 \to k$}
\State $mCBF.C_{f_i(x)\%N}$ ++
\EndFor
\State $C_{min} = MAX\_VALUE$
%\Comment{Get minimum value of $k$ counters in mCBF}
\For {$i = 1 \to k$}
\If {$C_{min} > mCBF.C_{f_i(x)\%N}$}
\State $C_{min} \gets mCBF.C_{f_i(x)\%N}$
\State $j \gets f_i(x)\%N$
\State $m \gets i$
\EndIf
\EndFor
%\State $C_{min} = min\{mCBF.C_{f_1(x)\%N},\cdot\cdot\cdot,mCBF.C_{f_k(x)\%N}\}$
%\State $i = \textbf{SubscriptOf}(C_{min})$
\State $B_j = B_j \cup x$
\Comment \emph{Insert $x$ into $B_j$}
\For {$i = 1 \to k$}
\State $aCBF_m.C_{f_i(x)\%\textbf{LengthOf}(aCBF_m)}$ ++
\EndFor
\EndProcedure
\Statex
\end{algorithmic}
\vspace{-0.4cm}%
\end{algorithm}
\end{document}
我知道星号 (*) 是为了让数字跨越两列,但里面minipage
不允许我添加algorithm
。此外,即使允许minipage
,也会处于会冲突的环境algorithm
中。请帮忙。figure
编辑:我上传了一张图片,显示了我想要的样子。这两个图和算法在同一行,但跨越两列。
答案1
有一种可能性是:
\documentclass[conference]{IEEEtran}
\usepackage[ruled]{algorithm}
\usepackage{algpseudocode}
%\usepackage{subfigure}
\usepackage[demo]{graphicx}
\usepackage{times}
\usepackage{amssymb}
\usepackage{url}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{wrapfig}
\newcounter{tmp}
\begin{document}
\title{xxx}
\maketitle
\begin{figure*}
\centering
\begin{minipage}[t]{0.32\textwidth}
\centering
\raisebox{-\height}{\includegraphics[width=1\textwidth]{xx.eps}}
\vspace{-0.4cm}%
\caption{THis is figure xx}\label{fig:xx}
\end{minipage}\hfill
\begin{minipage}[t]{0.32\textwidth}
\centering
\raisebox{-\height}{\includegraphics[width=1\textwidth]{yy.eps}}
\vspace{-0.4cm}%
\caption{This is figure yy.}\label{fig:yy}
\end{minipage}\hfill
\begin{minipage}[t]{0.32\textwidth}
\alglanguage{pseudocode}
\renewcommand\figurename{Algorithm}
\setcounter{tmp}{\value{figure}}
\setcounter{figure}{\value{algorithm}}
\small
\caption{\small Insert item into Hash Table (with mCBF and aCBF)}
\label{Algorithm:insert_mCBF_aCBF}
\begin{algorithmic}[1]
\Procedure{$\mathbf{InsertItem}$}{item $x$}
\For {$i = 1 \to k$}
\State $mCBF.C_{f_i(x)\%N}$ ++
\EndFor
\State $C_{min} = MAX\_VALUE$
%\Comment{Get minimum value of $k$ counters in mCBF}
\For {$i = 1 \to k$}
\If {$C_{min} > mCBF.C_{f_i(x)\%N}$}
\State $C_{min} \gets mCBF.C_{f_i(x)\%N}$
\State $j \gets f_i(x)\%N$
\State $m \gets i$
\EndIf
\EndFor
%\State $C_{min} = min\{mCBF.C_{f_1(x)\%N},\cdot\cdot\cdot,mCBF.C_{f_k(x)\%N}\}$
%\State $i = \textbf{SubscriptOf}(C_{min})$
\State $B_j = B_j \cup x$
\Comment \emph{Insert $x$ into $B_j$}
\For {$i = 1 \to k$}
\State $aCBF_m.C_{f_i(x)\%\textbf{LengthOf}(aCBF_m)}$ ++
\EndFor
\EndProcedure
\Statex
\end{algorithmic}
\end{minipage}
\setcounter{figure}{\value{tmp}}
\end{figure*}
\end{document}
选项demo
只是graphicx
用黑色矩形替换实际图形;不是在实际文档中使用该选项。