![将表格放在图形旁边(将表格垂直居中对齐)](https://linux22.com/image/275544/%E5%B0%86%E8%A1%A8%E6%A0%BC%E6%94%BE%E5%9C%A8%E5%9B%BE%E5%BD%A2%E6%97%81%E8%BE%B9%EF%BC%88%E5%B0%86%E8%A1%A8%E6%A0%BC%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%E5%AF%B9%E9%BD%90%EF%BC%89.png)
我想在文档中并排放置表格和图形。我使用以下代码实现了此目的
\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
...
查看文档!