我在 overleaf 上使用 ieee 2 列格式。我有一张表格和一张图,我想将它们并排放置,就像这张图一样。
我试过这个代码,但由于错误,它对我来说不起作用表格和图形并排成两列布局,下方无空格
但是我怎样才能修改我的这段代码
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{subfig}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{makecell}%
%table
\usepackage[margin=1in]{geometry}
\usepackage{tabularx,booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{times}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
%\documentclass{IEEEtran}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
\begin{table}
\tiny \setlength\tabcolsep{3pt}
\centering
\caption{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
\begin{tabular}{@{} ll *{4}{c} @{}}
\toprule
ooooooooo& bbbbbb
&\multicolumn{2}{c}{ccccvvvvvv}
&\multicolumn{2}{c}{ccccccccc}\\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
& & \makecell{vvvvvvvvv\\ (cccc)} &\makecell{vvvvvvvvv\\ (vvvvvvv)} &\makecell {vvvvvvvvv\\ (cccc)} &\makecell {vvvvvvvvv \\ (vvvvvvvv)} \\
\midrule
vvvvvvvvvvvvvvvvv & bbbbbbbbb &fff &fffffffff &fffffffffffffff& ff \\
\addlinespace %\midrule
ffffffffffff & fffffff8 &fff &fffffffffffff & ff &fffffffffff\\
\addlinespace %\midrule
fffffffffff & ffffffffff &fff &ffffffffff & ffff &ffffffffff\\
\addlinespace %\midrule
fffffffff & fffff &fff &fffffffffffff &fff &fffffffffffff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffff &fff &ffffffffffff4 &ffffffffff& ff \\
\addlinespace %\midrule
fffffffff & fffffff &fffffff &fffffffff &ffffffffffffff& ff \\
\addlinespace %\midrule
fffffffff & ffffffff &fff &ffff &fffffffffffff& ff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffffff &8fffff &ffffffffffff &ffff& fffffffffffff\\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}
\centering
\includegraphics[width=10cm, height=5cm]{Fig.png}
\caption{(a) Avvvvvvvvv (b) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}
\end{figure}
\end{document}
答案1
看来这\captionof
现在是标准的 LaTeX,或者至少在 IEEEtran 中是这样的。对齐中心或底部很容易(在小页面中使用 [c] 或 [b]),但对齐顶部则需要\raisebox{-\height}{...}
。
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{subfig}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{makecell}%
%table
\usepackage[margin=1in]{geometry}
\usepackage{tabularx,booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{times}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
%\documentclass{IEEEtran}
%\usepackage[english]{babel}% redundant
%\usepackage[utf8]{inputenc}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
\begin{table*}% or figure*
\begin{minipage}{\columnwidth}
\tiny \setlength\tabcolsep{3pt}
\centering
\captionof{table}{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}
\begin{tabular}{@{} ll *{4}{c} @{}}
\toprule
ooooooooo& bbbbbb
&\multicolumn{2}{c}{ccccvvvvvv}
&\multicolumn{2}{c}{ccccccccc}\\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
& & \makecell{vvvvvvvvv\\ (cccc)} &\makecell{vvvvvvvvv\\ (vvvvvvv)} &\makecell {vvvvvvvvv\\ (cccc)} &\makecell {vvvvvvvvv \\ (vvvvvvvv)} \\
\midrule
vvvvvvvvvvvvvvvvv & bbbbbbbbb &fff &fffffffff &fffffffffffffff& ff \\
\addlinespace %\midrule
ffffffffffff & fffffff8 &fff &fffffffffffff & ff &fffffffffff\\
\addlinespace %\midrule
fffffffffff & ffffffffff &fff &ffffffffff & ffff &ffffffffff\\
\addlinespace %\midrule
fffffffff & fffff &fff &fffffffffffff &fff &fffffffffffff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffff &fff &ffffffffffff4 &ffffffffff& ff \\
\addlinespace %\midrule
fffffffff & fffffff &fffffff &fffffffff &ffffffffffffff& ff \\
\addlinespace %\midrule
fffffffff & ffffffff &fff &ffff &fffffffffffff& ff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffffff &8fffff &ffffffffffff &ffff& fffffffffffff\\
\bottomrule
\end{tabular}
\end{minipage}\hfill% no blank line here
\begin{minipage}{\columnwidth}
\centering
\includegraphics[width=\linewidth]{example-image}
\captionof{figure}{(a) Avvvvvvvvv (b) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb}
\end{minipage}
\end{table*}
\end{document}
答案2
subfloatrow
您可以从包中获取所需的环境floatrow
:
\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
%\usepackage{cite}
\usepackage{amsmath,amssymb}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
%\usepackage{subfig}
\usepackage[english]{babel}
\usepackage{makecell}%
%table
\usepackage[margin=1in]{geometry}
\usepackage{tabularx, booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\usepackage{times}
\makeatletter
\newcommand{\removelatexerror}{\let\@latex@error\@gobble}
\makeatother
%\documentclass{IEEEtran}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\usepackage{subcaption, floatrow}
\begin{document}
\begin{table*}
\begin{subfloatrow}[2]
\CenterFloatBoxes
\ttabbox{\caption{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}\label{tbl}}
{\tiny \setlength\tabcolsep{3pt}\centering
\begin{tabular}{@{} ll *{4}{c} @{}}
\toprule
ooooooooo& bbbbbb
&\multicolumn{2}{c}{ccccvvvvvv}
&\multicolumn{2}{c}{ccccccccc}\\
\cmidrule(lr){3-4} \cmidrule(l){5-6}
& & \makecell{vvvvvvvvv\\ (cccc)} &\makecell{vvvvvvvvv\\ (vvvvvvv)} &\makecell {vvvvvvvvv\\ (cccc)} &\makecell {vvvvvvvvv \\ (vvvvvvvv)} \\
\midrule
vvvvvvvvvvvvvvvvv & bbbbbbbbb &fff &fffffffff &fffffffffffffff& ff \\
\addlinespace %\midrule
ffffffffffff & fffffff8 &fff &fffffffffffff & ff &fffffffffff\\
\addlinespace %\midrule
fffffffffff & ffffffffff &fff &ffffffffff & ffff &ffffffffff\\
\addlinespace %\midrule
fffffffff & fffff &fff &fffffffffffff &fff &fffffffffffff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffff &fff &ffffffffffff4 &ffffffffff& ff \\
\addlinespace %\midrule
fffffffff & fffffff &fffffff &fffffffff &ffffffffffffff& ff \\
\addlinespace %\midrule
fffffffff & ffffffff &fff &ffff &fffffffffffff& ff\\
\addlinespace %\midrule
ffffffffffffffff & ffffffffff &8fffff &ffffffffffff &ffff& fffffffffffff\\
\bottomrule
\end{tabular}}
\killfloatstyle
\hskip 6em
\ffigbox [\FBwidth]{\raggedleft\includegraphics[scale=0.7]{Nightmare_Fussli}}
{ \caption{Johann-Heinrich Füssli: Nightmare}\label{fig}}
\end{subfloatrow}
\end{table*}
\end{document}