0

In short: How can I add the optional parameters [htbp] to all float environments?

Ideally, I don't want to define a custom new environment, but add these options "with a hack" like \g@addto@macro\@floatboxreset{...}, maybe in the preamble or in a custom package (with \makeatletter and \makeatother).

MWE:

% Instead of this
\documentclass{article}
\usepackage{mwe}

\begin{document}

\begin{figure}[htbp] \centering \includegraphics[width=\textwidth]{example-image} \caption{A dummy image.} \end{figure}

\end{document}

% Have this
\documentclass{article}
\usepackage{mwe}

\makeatletter
% !!Some command that adds `[htbp]`
% to all float environments
\makeatother

\begin{document}

% Note that `[htbp]` is missing, since it is
% automatically implied.
\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{example-image}
    \caption{A dummy image.}
\end{figure}

\end{document}

1 Answers1

3

The document class should define (maybe inheriting it from another loaded class)

\fps@figure
\fps@table

to contain the default position specifiers.

You can add, before \begin{document},

\makeatletter
\renewcommand{\fps@figure}{htbp}
\renewcommand{\fps@table}{htbp}
\makeatother

and after this typing

\begin{figure}

would be the same as typing

\begin{figure}[htbp]

(the same for table). You can still override the default by saying, for instance

\begin{figure}[!hp]

or whatever particular choice you need.

egreg
  • 1,121,712