Page Layoutfloat, framed | Unwanted Effect on Headings

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
rankinjo
Posts: 4
Joined: Mon Feb 25, 2008 12:45 am

float, framed | Unwanted Effect on Headings

Post by rankinjo »

I defined a custom float environment to put a grey background behind the caption, using the framed package. Like this:

Code: Select all

% grey background custom floats with rule
\definecolor{shadecolor}{gray}{.8}
\renewcommand\fs@plaintop{\def\@fs@cfont{\bfseries}%
 \def\@fs@pre{\begin{snugshade}}%
 \def\@fs@mid{\end{snugshade}\kern3pt}%
 \def\@fs@post{\kern5pt\hrule}%
 \let\@fs@iftopcapt\iftrue}
The problem: On my Mac, this works as expected, but on my Linux Mint computer, all subsequent \section, \subsection, ... commands lose their "beforeskip" and appear immediately after the preceding paragraphs, with no vertical space. The "afterskip" is not affected. If I use the shaded environment, instead of snugshade, the proper \section spacing is restored:

Code: Select all

% grey background custom floats with rule
\definecolor{shadecolor}{gray}{.8}
\renewcommand\fs@plaintop{\def\@fs@cfont{\bfseries}%
 \def\@fs@pre{\begin{shaded}}%
 \def\@fs@mid{\end{shaded}\kern3pt}%
 \def\@fs@post{\kern5pt\hrule}%
 \let\@fs@iftopcapt\iftrue}
Any ideas why this might be happening and how to fix it?

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rankinjo
Posts: 4
Joined: Mon Feb 25, 2008 12:45 am

Re: float, framed | Unwanted Effect on Headings

Post by rankinjo »

Redefining the "snugshade" environment to use code similar to that used in the "shaded" environment definition makes the problem go away, without affecting the snugshade output appearance. It is not obvious why the package defines the two environments in different ways.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: float, framed | Unwanted Effect on Headings

Post by Stefan Kottwitz »

Hi,

thanks for telling how you solved it. I marked your post as the solution.
Btw. perhaps nobody could see a fix because there was no minimal example, which could be compiled and tested. At least I rarely have time to construct a compilable example for reproducing a situation because only a code snippet has been posted. This may be sufficient just for very obvious problems.

Stefan
LaTeX.org admin
Post Reply