LaTeX 中圖和表如何並排?

圖和圖並排可用minipage,那麼圖和表如何並排呢?


documentclass{article}
usepackage{graphicx}
usepackage{caption}

egin{document}

egin{figure}
egin{minipage}[b]{.5linewidth}
centering
includegraphics[w=3cm]{example-image-1x1.pdf}
caption{Image}
end{minipage}%
egin{minipage}[b]{.5linewidth}
centering
egin{tabular}{|c|c|}
hline
aa bb \ hline
cc dd \ hline
end{tabular}
captionof{table}{Table}
end{minipage}
end{figure}

end{document}


倒是不難,但是,跟我學:

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX LaTeX

documentclass{article}

usepackage{graphicx}
usepackage{float}

ewfloat{figtab}{htb}{fgtb}
makeatletter

ewcommandfigcaption{def@captype{figure}caption}

ewcommand abcaption{def@captype{table}caption}
makeatother

egin{document}
egin{figtab}
egin{minipage}[b]{0.45linewidth}
centering
includegraphics[width = linewidth]{example-image}
figcaption{Example Image}
end{minipage}quad
egin{minipage}[b]{0.45linewidth}
centering
abcaption{Example Tabular}
egin{tabular}{cc}
Hello world
end{tabular}
end{minipage}
end{figtab}
end{document}


借用 @劉海洋 的例子。floatrow 可以讓圖和表居中對齊,在這裡是大材小用了。

documentclass{article}
usepackage{graphicx}
usepackage{floatrow}

floatsetup{heightadjust=all, floatrowsep=columnsep}

ewfloatcommand{figurebox}{figure}[
ocapbeside][dimexpr( extwidth-columnsep)/2
elax]

ewfloatcommand{tablebox}{table}[
ocapbeside][dimexpr( extwidth-columnsep)/2
elax]

egin{document}

egin{figure}[htbp]
egin{floatrow}[2]
figurebox{caption{Image}}{%
includegraphics[w=3cm]{example-image-1x1.pdf}}%
ablebox{caption{Table}}{%
egin{tabular}{|c|c|}
hline
aa bb \ hline
cc dd \ hline
end{tabular}}
end{floatrow}
end{figure}

end{document}


很多時候,或是為了便於理解,或是為了加強對比,需要一行兩列並排顯示圖片或者表格,可以使用 minipage 進行實現

  • 圖片+公式

egin{figure}[H]
egin{minipage}{0.48linewidth}
centerline{includegraphics[w=4.0cm]{yaw.png}}
end{minipage}
hfill
egin{minipage}{.48linewidth}
egin{displaymath} %label{zrot}
{R(z,psi)} = left[ {egin{array}{*{20}{c}}
{cos psi }{sin psi }0\
{ - sin psi }{cos psi }0\
001
end{array}}
ight]
end{displaymath}
end{minipage}
caption{偏航角轉動示意圖}
label{zrotate}
end{figure}

  • 表格並列

egin{table}[H]
egin{minipage}{0.48linewidth}
centering
caption{ 偏航角$psi$的真值表 }
egin{tabular}{c|c|c}
hline
$r_{22}$ $r_{12}$ $psi$ \
hline
multirow{1}{1.5cm}{$ o 0 $} multirow{1}{1.5cm}{$+$} multirow{1}{2cm}{90deg} \
hline
$ o 0$ $-$ $ -$90deg \
hline
$-$ $+$ $ psi_m + 180$deg \
hline
$-$ $-$ $ psi_m - 180$deg \
hline
end{tabular}
end{minipage}egin{minipage}{0.48linewidth}
centering
caption{ 橫滾角$phi$的真值表 }
egin{tabular}{c|c|c}
hline
$phi_m$ $r_{33}$ $phi$ \
hline
multirow{1}{1.5cm}{$+$} multirow{2}{1.5cm}{ $+$ } multirow{2}{2cm}{ $phi_m$} \
cline{1-1}
$-$ \
hline
$+$ $-$ $ phi_m - 180$deg \
hline
$-$ $-$ $ phi_m + 180$deg \
hline
end{tabular}
end{minipage}
end{table}

&> 上一位回答者提了一個 floatrow,看上去很不錯的樣子。有機會得試試,就是官網說明:This package was created as extension of the float package. The floatrow package
borrows core code from the float and rotfloat packages, so you must not load these
packages

我用了float啊


推薦閱讀:

怎麼把填空題的答案隱藏起來?
關於 LaTeX 有什麼推薦的說明教程、指南一類的資料?
有什麼比較好的 LaTeX 模板值得學習?
為什麼 LaTeX 中要用 igl, igr 等命令來處理定界符,而儘可能避免 left 和
ight?

hyperref 與 unicode-math 衝突如何解決?

TAG:LaTeX | TeX | LaTeX排版與設計 |