我有以下代码,试图用它来显示洛书魔方的图像被转换成它的数值魔方等价物:
\begin{figure}[htbp]
\centering
\includegraphics[width=150pt]{loshu.png}
$\longrightarrow$
\begin{tabular}{|c|c|c|}
\hline
4 & 9 & 2\\
\hline
3 & 5 & 7\\
\hline
8 & 1 & 6\\
\hline
\end{tabular}
\caption{The lo-shu magic square}
\label{fig:loshu}
\end{figure}
但是,当我排版时,箭头与表格一起位于底部。我希望箭头和表格与图形的中心对齐,这样转换看起来自然。有什么想法吗?:
答案1
将图像缩小一半\height
:
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\centering
\raisebox{-.5\height}{\includegraphics[width=150pt]{example-image}}
$\longrightarrow$
\begin{tabular}{|c|c|c|}
\hline
4 & 9 & 2\\
\hline
3 & 5 & 7\\
\hline
8 & 1 & 6\\
\hline
\end{tabular}
\caption{The lo-shu magic square}
\end{figure}
\end{document}
答案2
将图像和表格放入小页面环境中:
\documentclass[11pt]{article}
\usepackage{graphicx}
\usepackage[active,floats,tightpage]{preview}
\setlength\PreviewBorder{1em}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{minipage}{0.45\hsize}
\includegraphics[width=150pt]{example-image}
\end{minipage}
$\longrightarrow$
\begin{minipage}{0.45\hsize}
\begin{tabular}{|c|c|c|}
\hline
4 & 9 & 2\\
\hline
3 & 5 & 7\\
\hline
8 & 1 & 6\\
\hline
\end{tabular}
\end{minipage}
\caption{The lo-shu magic square}
\label{fig:loshu}
\end{figure}
\end{document}