我想在文档中并排放置表格和图形。我使用以下代码实现了此目的
\documentclass[a4paper,10pt]{article}
\usepackage{floatrow}
\usepackage{color}
\newfloatcommand{capbtabbox}{table}[][\FBwidth]
\begin{document}
\begin{figure}
\begin{floatrow}
\ffigbox[\FBwidth]%
{\includegraphics*[width=0.45\textwidth]{LiverPhantom.png}}
{\caption{Liver Phantom}%
\label{fig:Zoom}%
}
\capbtabbox{%
\begin{tabular}{|c|cc|cc|cc|} \hline
\textbf{Head} & \multicolumn{6}{c|}{\textbf{Pixel Width}} \\ \hline
& \multicolumn{2}{c|}{\textbf{Picker}} & \multicolumn{2}{c|}{\textbf{Blue}} & \multicolumn{2}{c|}{\textbf{Red}} \\
& X & Y & X & Y & X & Y \\ \hline
\textbf{H1} & 79.9 & 80.0 & 87.3 & 87.5 & 87.7 & 87.1 \\
\textbf{H2} & 79.4 & 79.3 & 87.5 & 87.1 & 87.3 & 87.2 \\
\textbf{H3} & 80.2 & 80.4 & - & - & - & -\\ \hline
\textbf{Mean} & \multicolumn{2}{c|}{\textbf{\color{red}79.9}} & \multicolumn{4}{c|}{\textbf{\color{red}87.3}} \\ \hline
\end{tabular}
}{
\caption{Phantom pixel width}
\label{fig:ZoomTBl}
}
\end{floatrow}
\end{figure}
\end{document}
但是,图形和表格的底部边界具有相同的 y 坐标。是否可以将表格相对于图形垂直居中对齐?
答案1
尽管 Herbert 解决了这个问题,但值得注意的是,还有两个经典的minipage
和caption
包,一个简单的替代方案:
\documentclass[a4paper,10pt]{article}
\usepackage{graphicx}
\usepackage[margin=2.54cm]{geometry}
\usepackage{mwe} % for demo figure
\usepackage{lipsum} % for dummmy text
\usepackage{caption}
\usepackage{color}
\begin{document}
\lipsum[1-4]
\begin{figure}
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=\textwidth]{example-image-a.pdf}
\captionof{figure}{Liver Phantom}
\end{minipage}\hfill
\begin{minipage}{.55\textwidth}
\centering
\begin{tabular}{|c|cc|cc|cc|} \hline
\textbf{Head} & \multicolumn{6}{c|}{\textbf{Pixel Width}} \\ \hline
& \multicolumn{2}{c|}{\textbf{Picker}} & \multicolumn{2}{c|}{\textbf{Blue}} & \multicolumn{2}{c|}{\textbf{Red}} \\
& X & Y & X & Y & X & Y \\ \hline
\textbf{H1} & 79.9 & 80.0 & 87.3 & 87.5 & 87.7 & 87.1 \\
\textbf{H2} & 79.4 & 79.3 & 87.5 & 87.1 & 87.3 & 87.2 \\
\textbf{H3} & 80.2 & 80.4 & - & - & - & -\\ \hline
\textbf{Mean} & \multicolumn{2}{c|}{\textbf{\color{red}79.9}} & \multicolumn{4}{c|}{\textbf{\color{red}87.3}} \\ \hline
\end{tabular}%
\captionof{table}{Phantom pixel width}
\end{minipage}
\end{figure}
\end{document}
答案2
...
\begin{floatrow}\CenterFloatBoxes
...
查看文档!