使用“floatrow”时图形错位

使用“floatrow”时图形错位

我想将表格放在同一行的图形旁边,为此我使用了该floatrow包。但是,我无法将两者对齐。这是正在发生的事情:

在此处输入图片描述

我用来生成这个代码的代码是:

\documentclass[10pt]{scrartcl}
%=======================================================================
%I am listing all packages defined in my main
\usepackage[utf8]{inputenc}
\usepackage{comment}
\usepackage[margin=3cm]{geometry}
\usepackage[titles]{tocloft}
\usepackage[parfill]{parskip}
\usepackage[hidelinks]{hyperref}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{floatrow}
\usepackage{amsmath,amssymb,amsthm,multirow,algorithm,algorithmic,amsfonts}
\numberwithin{equation}{section}
\usepackage{gensymb}
\usepackage[square,numbers,comma,sort&compress]{natbib}
\usepackage[titletoc]{appendix}
\usepackage[final]{pdfpages}
\usepackage{afterpage}
\usepackage{multicol}
\usepackage{enumitem}
\usepackage{color}
\usepackage{textcomp}
\usepackage{pdfpages}
\usepackage{tabularx}
\usepackage{lscape}
\usepackage{listings}
\usepackage{diagbox}
\usepackage{colortbl}
%======================================================================
\pagestyle{plain}
%======================================================================
\newfloatcommand{\capbtabbox}{table}[][\FBwidth]
\newcommand{\HRule}{\rule{\linewidth}{0.04cm}}
\renewcommand{\abstractname}{{\Large Summary}}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\setlength{\parskip}{12pt plus8pt minus6pt}
\setlength{\itemsep}{-5pt}
\newlength{\wideitemsep}
\setlength{\wideitemsep}{.5\itemsep}
\addtolength{\wideitemsep}{-7pt}
\let\olditem\item
\renewcommand{\item}{\setlength{\itemsep}{\wideitemsep}\olditem}
\numberwithin{equation}{section}
%========================================================================
\newenvironment{drawing}
%========================================================================
\begin{document}
%ACTUAL CODE TO PRODUCE FIGURES
%========================================================================
\begin{figure}[H]
\begin{floatrow}
\ffigbox{%
  \includegraphics[width=0.45\textwidth]{figures/dummy.jpg}%
}{%
  \caption{A figure}%
}
\capbtabbox{%
\begin{tabular}{|l|l|l|l|l}
\cline{1-4}
Number & Entry 1 & Entry 2 & Entry 3 &  \\ \cline{1-4}
Number & Entry 4 & Entry 5 & Entry 6 &  \\ \cline{1-4}
Number & Entry 7 & Entry 8 & Entry 9 &  \\ \cline{1-4}
Number} & Entry 10 & Entry 11 & Entry 12 &  \\ \cline{1-4}
\end{tabular}
}{%
  \caption{A table}%
}
\end{floatrow}
\end{figure}

我已经尝试了几个小时来对齐这两个图及其标题,但没有成功。我正在使用 ShareLaTeX。

答案1

请注意,由于 ,您的代码无法编译Number}。您可能正在寻找类似这样的内容:

\documentclass{article}
\usepackage{graphicx,floatrow,booktabs}

\begin{document}
\begin{figure}[tbp]
  \CenterFloatBoxes
  \begin{floatrow}
    \ffigbox{\includegraphics[width=0.45\textwidth]{example-image-1x1}}{%
      \caption{A Figure}%
      \label{fig:a}%
    }
    \killfloatstyle
    \ttabbox[\FBwidth]{%
      \begin{tabular}{llll}
        \toprule
        Head   & Head    & Head    & Head      \\ \midrule
        Number & Entry 1 & Entry 2 & Entry 3   \\ 
        Number & Entry 4 & Entry 5 & Entry 6   \\ 
        Number & Entry 7 & Entry 8 & Entry 9   \\ 
        Number & Entry 10 & Entry 11 & Entry 12   \\
        \bottomrule
      \end{tabular}%
    }{%
      \caption{A table}%
      \label{tab:a}%
    }
  \end{floatrow}
\end{figure}
\end{document}

在此处输入图片描述

代码取自文档,请检查第 2.3.1 节混合行。

相关内容