Page breaking between heading levels

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
navoff
Sr. Propeller Head
Posts: 201
Joined: Mon Oct 06, 2008 7:26 am
Contact:

Page breaking between heading levels

Post by navoff »

I have a topic that starts out with two heading levels and then a table. For some reason, my PDF output is causing there to be a page break between the two heading levels and leaving the text of the <h2> heading all by itself at the top of page one and the text of the <h4> heading and the table not starting until page 2. Here is the structure of the topic file:

<body>
<h2>Heading 2 text</h2>
<h4 class="notoc">Heading 4 text</h4>
<table>
...
</table>
</body>

The table has short, one line rows (lots of them) and flows over two pages.

The print css for the heading levels is:

h2
{
font-size: 18.0pt;
page-break-after: avoid;
}

h4.notoc
{
font-size: 12.0pt;
page-break-before: avoid;
}

This hasn't helped. If I leave it as a regular paragraph, it flows just fine. If I change it into a heading level (any heading level), it bumps it to the next page. If I create a paragraph style with all the same settings as the h4.notoc style, it flows fine. So, what gives?
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know that will run and hide from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
carolynmwallace
Sr. Propeller Head
Posts: 168
Joined: Thu Jan 31, 2008 12:21 pm
Location: Durham, NC

Re: Page breaking between heading levels

Post by carolynmwallace »

navoff wrote: This hasn't helped. If I leave it as a regular paragraph, it flows just fine. If I change it into a heading level (any heading level), it bumps it to the next page. If I create a paragraph style with all the same settings as the h4.notoc style, it flows fine. So, what gives?
Sorry for the stupid question, but are you sure your paragraph style has all the same settings as the h4.notoc style? Headings and paragraphs have different defaults, and often the defaults don't show up in your stylesheet (for example, the margin, padding, or line-height values might be different).

For some reason, Flare can't honor BOTH heading page-break-after: avoid requests. There's something just a bit different in the paragraph style that helps it get around the deadlock.
navoff
Sr. Propeller Head
Posts: 201
Joined: Mon Oct 06, 2008 7:26 am
Contact:

Re: Page breaking between heading levels

Post by navoff »

carolynmwallace wrote:
navoff wrote: This hasn't helped. If I leave it as a regular paragraph, it flows just fine. If I change it into a heading level (any heading level), it bumps it to the next page. If I create a paragraph style with all the same settings as the h4.notoc style, it flows fine. So, what gives?
Sorry for the stupid question, but are you sure your paragraph style has all the same settings as the h4.notoc style? Headings and paragraphs have different defaults, and often the defaults don't show up in your stylesheet (for example, the margin, padding, or line-height values might be different).
As it turns out, the p.h4 style inherited the margin-top property of 12pt (from the print settings for the p tag) whereas the h4.notoc style inherited the default margin-top property of 1.12em. Now, technically, 1.12em is only slightly bigger than 12pt (if the font size is set to 12pt and 1em is the height of an element's font). It certainly isn't so huge that it should force everything to another page. However, changing the margin-top setting for the h4.notoc style from the default of 1.12em to 12pt seems to have done the trick. There must be something about the em unit type that when generating PDF output, it thinks it needs more space on the page than it really does.
carolynmwallace wrote: For some reason, Flare can't honor BOTH heading page-break-after: avoid requests. There's something just a bit different in the paragraph style that helps it get around the deadlock.
I only added the "page-break-before: avoid" to the h4.notoc style after I first saw that it was skipping to the next page. I just never bothered to change it back when it failed to solve the problem.
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know that will run and hide from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
navoff
Sr. Propeller Head
Posts: 201
Joined: Mon Oct 06, 2008 7:26 am
Contact:

Re: Page breaking between heading levels

Post by navoff »

navoff wrote:As it turns out, the p.h4 style inherited the margin-top property of 12pt (from the print settings for the p tag) whereas the h4.notoc style inherited the default margin-top property of 1.12em. Now, technically, 1.12em is only slightly bigger than 12pt (if the font size is set to 12pt and 1em is the height of an element's font). It certainly isn't so huge that it should force everything to another page. However, changing the margin-top setting for the h4.notoc style from the default of 1.12em to 12pt seems to have done the trick. There must be something about the em unit type that when generating PDF output, it thinks it needs more space on the page than it really does.
It appears I spoke, er, wrote too soon. Initially, in the Flare interface when I changed the style of the text from my p.h4 to the "new and imroved" styling for the h4.notoc class, it appeared to scoot back to the first page. However, when I did a print preview it, once again, was shifted to the second page. After closing the file and reopening it in the Flare interface, it also appeared on the second page. After setting the text back to my p.h4 style, it was back on the first page. Just to be on the safe side, I even removed the "page-break-before: avoid" setting from the h4.toc style (since the h2 style defaults to "page-break-after: avoid"). But no joy. I'm not sure where the h2 is inheriting it's page-break-after setting because there's nothing I see in the stylesheet in the project that sets it. The only page-break-after settings are for classes I added. <sigh>
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know that will run and hide from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
navoff
Sr. Propeller Head
Posts: 201
Joined: Mon Oct 06, 2008 7:26 am
Contact:

Re: Page breaking between heading levels

Post by navoff »

You know, the whacky thing is that when I changed the h4.notoc class to use 12pt instead of the default 1.12em for the margin-top, it also affected the other h4.notoc occurrences in the file. Before, they were all scooting the the next page (though they were closer to the bottom of the page than the first one). Now, only the first occurrence skips to the next page, the rest flow as if they were styled with my p.h4 class. Go figure.....
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know that will run and hide from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
LTinker68
Master Propellus Maximus
Posts: 7247
Joined: Thu Feb 16, 2006 9:38 pm

Re: Page breaking between heading levels

Post by LTinker68 »

Just as a rule of thumb, your "default" medium should use values like px, ems, or % for font size and px for positioning (margin and padding size). The "print" medium should use pt for font size and pt or inches for positioning.

For your h2/h4 problem... You could try using a complex selector that specifies that if a h4 tag immediately follows an h2 tag, then set the page-break-after to avoid on the h4 tag. That should keep both of those tags with the table. So it would look something like:

Code: Select all

h2 + h4,
h2 + h4.notoc
{
    page-break-after:avoid;
}
BTW, if the table is too long, then the whole thing will move to the next page, even if you have page-break-after set to avoid on the preceding tag. I haven't played around with tables enough in print output (none of mine were that long) to figure out which table-related tag needs to have a page-break-inside set to allow or whatever the option is.
Image

Lisa
Eagles may soar, but weasels aren't sucked into jet engines.
Warning! Loose nut behind the keyboard.
navoff
Sr. Propeller Head
Posts: 201
Joined: Mon Oct 06, 2008 7:26 am
Contact:

Re: Page breaking between heading levels

Post by navoff »

LTinker68 wrote:Just as a rule of thumb, your "default" medium should use values like px, ems, or % for font size and px for positioning (margin and padding size). The "print" medium should use pt for font size and pt or inches for positioning.
That's why the h4.toc style had ems for the margin-top since that was already part of the default medium. I just never changed that for the print output. Whenever I do make changes for print, I always use absolute units. I use relative sizes for non-print or the default medium. I went searching around the program folders for Flare to see if I could find where the default settings that don't show up in the project's local css file are set. I found this file:

C:\Program Files\MadCap Softwae\MadCap Flare V4\Flare.app\Resources\Schemas\xhtml.css

It had the following settings which leads me to believe that this is where those default settings are coming from (since it seems to match up with what shows up in the Stylesheet Editor but aren't in the local .css file).

Code: Select all

h4, p,
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu            { margin: 1.12em 0 }

  h1            { page-break-before: always; page-break-inside: avoid; }
  
  h1, h2, h3,
  h4, h5, h6    { page-break-after: avoid; column-break-after: avoid; page-break-inside: avoid; }
LTinker68 wrote:For your h2/h4 problem... You could try using a complex selector that specifies that if a h4 tag immediately follows an h2 tag, then set the page-break-after to avoid on the h4 tag. That should keep both of those tags with the table. So it would look something like:

Code: Select all

h2 + h4,
h2 + h4.notoc
{
    page-break-after:avoid;
}
Unfortunately that didn't seem to solve the problem either. It behaved exactly the same as before.
LTinker68 wrote:BTW, if the table is too long, then the whole thing will move to the next page, even if you have page-break-after set to avoid on the preceding tag. I haven't played around with tables enough in print output (none of mine were that long) to figure out which table-related tag needs to have a page-break-inside set to allow or whatever the option is.
Actually, I've had more problems with tables breaking inside of rows than the entire thing shifting to another page. I was finally able to stop that behavior by adding a "page-break-inside: avoid" to the td styles in table stylesheet (which I did in my text editor). I chose to add it to the table stylesheet rather than the general one so that, if I were to have a table with some really big table cells, that I could use an alternate table stylesheet that would allow breaking inside the cell rather than have a page with some huge area of white space at the bottom of a page because the table cell was too big to fit in the alloted area. Most of the time the table cells are small enough that going to the next page is fine. Without the page-break-inside property setting, I was running into a lot of times where there would be text in multiple cells that spanned pages making it difficult to read (you had to keep flipping the pages back and forth to follow what was written-blech).

The h4.notoc style doesn't appear to be affecting the flow of the other tables (not since changing the print margin-top setting to pts vs ems). It only seems to happen when the h4 immediately follows the h2.
JRP
"How many slime-trailing, sleepless, slimy, slobbering things do you know that will run and hide from your Eveready?"
--Maureen Birnbaum, Barbarian Swordsperson
Post Reply