すべてのテーブルで [hbt] と \centering を繰り返さないようにする

すべてのテーブルで [hbt] と \centering を繰り返さないようにする

私が書いている文書では、おなじみの[hbt]私のフローティングテーブルのためのオプション、そして私は中心テーブルを作成するたびにこれを繰り返さないようにしたいのですが、新しい環境を開始するたびにこれらの 2 つのオプションが使用されるようにする何かをプリアンブルに追加するのは簡単だと思いますかtable?

\documentclass{article}
\begin{document}
\begin{table}[hbt]
\centering
\begin{tabular}{*3{l}}
1 & 2 & 3\\
a & b & c\\
\end{tabular}
\end{table}
\end{document}

答え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}

関連情報