Document ClassesHow to define a new float style?

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
c0nny
Posts: 10
Joined: Sat Jun 28, 2008 12:28 pm

How to define a new float style?

Post by c0nny »

Hi,

I have a question on defining an own float style (not sure if this is the right place to post it, I'm new here). I want to have a ruled float but with two rules only instead of three (without the upper rule).
I tried to add the following to my preamble but I'm getting errors (Missing \begin{document}. \newcommand\fs@m and Undefined control sequence. ...f\@fs@cfont{\bfseries}\let\@fs@capt\floatc)

this is the definition:

\newcommand\fs@myruled{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@ruled
\def\@fs@post{\kern2pt\hrule\relax}%
\def\@fs@mid{\kern2pt\hrule\kern2pt}%
\let\@fs@iftopcapt\iftrue}

How do I have to do it, is the definition simply in the wrong place?

Thanks for any help
Conny

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to define a new float style?

Post by localghost »

Do not take this detour. Try one of the packages float, floatrow or trivfloat. With the help of these packages defining new floats is much easier.


Best regards and welcome to the board
Thorsten¹
c0nny
Posts: 10
Joined: Sat Jun 28, 2008 12:28 pm

Re: How to define a new float style?

Post by c0nny »

Thanks,

the floatrow package actually lets me do what I want.

In case somebody wants to know:

\includepackage{floatrow}

\DeclareFloatStyle{MyRuled}{
capposition=top,
midcode=rule,
postcode=lowrule,
heightadjust=all}

\newfloat{sentences}{th}{los}[chapter]
\floatname{sentences}{Example sentences}
\floatsetup[sentences]{style=MyRuled}

\usepackage[hang,small,bf,nooneline]{caption}

Just one more question:
if I define a new rule \DeclareFloatVCode{grayrule}{{\color{gray}\rule\hsize{1pt}}} and use it instead of the regular rule, the caption moves upwards. Why is that and how can I avoid it?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to define a new float style?

Post by localghost »

c0nny wrote:[…] if I define a new rule \DeclareFloatVCode{grayrule}{{\color{gray}\rule\hsize{1pt}}} and use it instead of the regular rule, the caption moves upwards. Why is that and how can I avoid it?
Since I never worked with floatrow, I can't figure out what's going wrong. A minimal working example (MWE) would make working out a solution much easier.
Post Reply