![避免對每個表重複 [hbt] 和 \centering](https://rvso.com/image/287060/%E9%81%BF%E5%85%8D%E5%B0%8D%E6%AF%8F%E5%80%8B%E8%A1%A8%E9%87%8D%E8%A4%87%20%5Bhbt%5D%20%E5%92%8C%20%5Ccentering.png)
答案1
預設圖形位置可以設定為
\makeatletter
\renewcommand\fps@figure{htbp}
\makeatletter
p
(不包含在預設值中幾乎總是一個壞主意)
為了居中,您可以將其添加到\@floatboxreset
\makeatletter
\def \@floatboxreset {%
\reset@font
\normalsize
\@setminipage
\centering%<<<<<<<<<<<<<<<<<<<
}
\makeatletter
答案2
這float
包裹提供一個介面來指定特定浮動的浮動位置
\floatplacement{<type>}{<spec>}
此\floatplacement
指令重置一類浮點數的預設放置說明符。所以,人們可以使用
\floatplacement{table}{hbt}
來實現你所追求的目標。
答案3
嘗試
\documentclass{article}
\newenvironment{mytable}
{\begin{table}[hbt]
\centering}
{\end{table}}
\begin{document}
\begin{mytable}
\begin{tabular}{*3{l}}
1 & 2 & 3\\
a & b & c\\
\end{tabular}
\end{mytable}
\end{document}
\end{document}
答案4
結合維爾納的回答這裡有鎖步的回答到如何自動將影像居中?,我們可以這樣做:
\documentclass{article}
\usepackage{floatrow} % this automatically centers all floats
\floatplacement{table}{hbtp} % all tables are given the [hbtp] option
\begin{document}
\begin{table}
\begin{tabular}{*3{l}}
1 & 2 & 3\\
a & b & c\\
\end{tabular}
\end{table}
\end{document}