Breaks

Set how elements are distributed over multiple pages and control page breaks in the DITA source.

Overview

Resource location:@import url("https://jorsek.github.io/pdfgen.github.io/styles1.1/modules/layout/breaks.css");

By default, if a topic can fit a page, it is distributed without any page breaks.

two topics on one page

By default, if a topic cannot fit a page, it is distributed on a separate page.

avoid breaking topics

If possible, some elements are distributed on a single page, without page breaks. For more information, inspect the module code.

breaks definition list

DITA Outputclass Attributes

This module enables you to set the following @outputclass attributes in the DITA source:

break_before
To force a page-break before a topic element, assign the @outpuclass="break_before" attribute to the topic element.
In the following example:
  • “Chapter A” contains “Section A”, “Section B”, and “Section C”.
  • The @outputclass="break_before" attribute is assigned to “Section B”.
outputclass break before
break_after
To force a page-break after a topic element, assign the @outpuclass="break_after" attribute to the topic element.
In the following example:
  • “Chapter A” contains “Section A”, “Section B”, and “Section C”.
  • the @outputclass="break_after" attribute is assigned to “Section B”.
outputclass break after
break_avoid
To avoid breaking an element over multiple pages, assign the @outpuclass="break_avoid" attribute to the element.
break_inside
To break an element over multiple pages, assign the @outpuclass="break_inside" attribute to the element.
break_topics
To Distribute non-chapter-level topics one-by-one over multiple pages, assign the @outpuclass="break_topics" attribute to the root map element.
Note: Assigning this attribute results in the same output as applying the Distribute non-chapter-level topics one-by-one customization.

Common Customizations

You can apply customizations by pasting the following code snippets under the @import rules.

Some customizations may also require XSLT modifications.
Distribute non-chapter-level topics one-by-one

In the following example, the “Publish a Resource” topic is distributed right after a previous topic.

breaks topic one by one
/* Break topics inside. */
article {
    break-inside: auto;
}
/* Do not break chapter-level topics. */
article:has(.topictitle1) {
    break-inside: avoid;
}
Decide which elements should be broken over multiple pages

Move selectors to the appropriate CSS rule to either break or avoid breaking elements over multiple pages, for example:

/* Break the following elements over multiple pages: */
table,
code,
.entry,
.xref,
.sysoutput,
.varname,
.filepath,
.userinput,
.stepxmp,
.stepresult,
.info,
.dd,
.result {
  break-inside: auto;
}

/* Avoid breaking the following elements over multiple pages: */
.note,
.dt,
.title,
.codeph,
.userinput,
.sysoutput,
.fig,
.abstract,
.shortdesc,
.example,
.context,
.prereq
.postreq {
  break-inside: avoid;
}
Avoid breaking definition title (<dt>) and definition description (<dd>) elements
CSS

Add the following code at the end of the CSS tab.

.dlentry {
  break-inside: avoid;
}
XSLT

In the XSLT tab, add the code under the <xsl:import> tag(s).

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

  <xsl:import href="../../../../../../../../sdk2/internal/pdf_generator/pdf_generator.xsl"/>
  
<!-- Add this code -->
  <!-- DL entry wrapper -->
  <xsl:template match="*[contains(@class, ' topic/dlentry ')]" name="topic.dlentry">
    <div class="dlentry">
      <xsl:apply-templates/>
    </div>
  </xsl:template>
<!-- End of add this code -->


</xsl:stylesheet>

For more information, see https://www.princexml.com/doc/13/paged/#page-breaks.