Document Classes ⇒ How to define a new float style?
How to define a new float style?
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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to define a new float style?
Best regards and welcome to the board
Thorsten¹
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Re: How to define a new float style?
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?
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
How to define a new float style?
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.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?
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10