我从以下位置复制了 floatrow 代码这并且无法使其与两列布局兼容。
\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{array}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{textcomp}
\usepackage{stfloats}
\usepackage{url}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{cite}
\hyphenation{op-tical net-works semi-conduc-tor IEEE-Xplore}
% updated with editoria
\usepackage{parskip}
\usepackage{mathtools}
\usepackage{floatrow}
\usepackage[demo]{graphicx}
\documentclass{article}
\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{figure}
\begin{floatrow}
\ffigbox{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}
\capbtabbox{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}
}{%
\caption{A table}%
}
\end{floatrow}
\end{figure}
\end{document}
我怎样才能解决这个问题?
答案1
有很多方法可以修复此问题。我建议您按如下方式重新排列代码:
\documentclass[journal]{IEEEtran}
\usepackage{floatrow}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{array}
\usepackage{textcomp}
\usepackage{stfloats}
\usepackage{url}
\usepackage{verbatim}
\usepackage{cite}
\hyphenation{op-tical net-works semi-conduc-tor IEEE-Xplore}
% updated with editoria
\usepackage{parskip}
\usepackage{mathtools}
\usepackage{blindtext}
\begin{document}
\blindtext
\begin{figure}
\begin{floatrow}
\ffigbox{%
\rule{3cm}{3cm}%
}{%
\caption{A figure}%
}
\capbtabbox{%
\begin{tabular}{cc} \hline
Author & Title \\ \hline
Knuth & The \TeX book \\
Lamport & \LaTeX \\ \hline
\end{tabular}
}{%
\caption{A table}%
}
\end{floatrow}
\end{figure}
\end{document}
现在这样可以了吗?您还可以使用它\subfig
来并排制作图形和表格。
更新
这是另一种使用方法minipage
。
梅威瑟:
\documentclass[journal]{IEEEtran}
\usepackage{amsmath,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{array}
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\usepackage{textcomp}
\usepackage{stfloats}
\usepackage{url}
\usepackage{verbatim}
\usepackage{graphicx}
\usepackage{cite}
\hyphenation{op-tical net-works semi-conduc-tor IEEE-Xplore}
% updated with editoria
\usepackage{parskip}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{float}
\usepackage{caption}
\begin{document}
\begin{figure}
\centering
\rule{2.8cm}{2cm}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\begin{figure}[!h]
%\centering
\begin{minipage}{.5\linewidth}
\centering
\rule{2.8cm}{2cm}
\captionof{figure}{Figure}
\label{fig:my_label}
\end{minipage}%
\hfill
\begin{minipage}{.5\linewidth}
\captionof{table}{Table}
\label{tab:table1}
\begin{tabular}{ c c c }
\toprule
Name & Age & Height\\ \midrule
John & 29 & 180 \\\midrule
Baker & 35 & 170 \\\midrule
Allen & 60 & 175 \\\bottomrule
\end{tabular}
\end{minipage}
\end{figure}
\begin{table}[!h]
\caption{Caption}
\label{tab:my_label}
\centering
\begin{tabular}{ | c|c |}
x & y \\
\end{tabular}
\end{table}
\end{document}
您的代码中出现了几个问题。使用时请小心不要使用大量包文件。
谢谢。