我尝试在 Latex 中对齐表格和图形,但没有得到想要的结果。我遵循了以下答案:表格和图形并排显示,并带有独立标题
这是我使用的代码
\documentclass{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{standalone}
\usepackage{pgf}
\usepackage[font=small,labelfont=bf]{caption}
% Table float box with bottom caption, box width adjusted to content
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\begin{document}
\begin{minipage}{\textwidth}
\begin{minipage}[b]{0.49\textwidth}
\vspace{0pt}
\centering
\rule{6.4cm}{3.6cm}
\end{minipage}
\hfill
\begin{minipage}[b]{0.49\textwidth}
\vspace{0pt}
\centering
\begin{tabular}{cc}\hline
Table head & Table head \\ \hline
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\ \hline
\end{tabular}
\end{minipage}
\end{minipage}
\end{document}
答案1
您的代码包含多个不需要的minipage
环境。删除“包装器”,并对[t]
剩余minipage
环境和tabular
环境使用定位说明符。
\documentclass{article}
\usepackage[english]{babel}
\usepackage[font=small,labelfont=bf]{caption}
\begin{document}
\noindent
\begin{minipage}[t]{6.4cm}
\vspace{0sp}
\rule{\textwidth}{3.6cm}
\end{minipage}
\hfill
\begin{tabular}[t]{@{}cc@{}}
\hline
Table head & Table head \\
\hline
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
Some values & Some values \\
\hline
\end{tabular}
\end{document}