A new float style for LaTeX: plainruled

Today, I’ve been so annoyed by LaTeX’s figures appearance that I’ve defined some tiny new style for the package float. This style simply draws a horizontal rule below and above the body of the figure.

Defining the style is very simple:

\makeatletter
\newcommand\fs@plainruled{\def\@fs@cfont{\rmfamily}\let\@fs@capt\floatc@plain%
  \def\@fs@pre{\hrule\kern2pt}%
  \def\@fs@mid{\kern2pt\hrule\vspace\abovecaptionskip\relax}%
  \def\@fs@post{}%
  \let\@fs@iftopcapt\iffalse}
\makeatother

Then you can use the style plainruled as any predefined style of the package float, e.g. you can make it the default for any figure by adding the following to the preamble of your document:

\floatstyle{plainruled}
\restylefloat{figure
}

In order to see the difference, let’s have a trivial figure in the body of your document:

\begin{figure}
  \centering
  Some interesting \\figure contents.
  \caption{Some figure caption.}
  \label{fig:f1}
\end{figure
}

Without my settings above this figure is rendered like this:

Using the style plainruled it renders like this:

This is nothing amazing, but simply useful. Therefore I wanted to keep this somewhere I and possibly others might find it for future reference.

This entry was posted in LaTeX and tagged , . Bookmark the permalink.

One Response to A new float style for LaTeX: plainruled

  1. Aaron Stump says:

    Thanks for the code snippet! That is great. To get just a line on the bottom (and not one on the top), I changed your third line to

    \def\@fs@pre{}%

    Aaron

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>