Forum How do I...?

flowing definition list <dl> lists for TOC

jbzech
Hi,

I am using Prince 7.1 on a single HTML file that is output from DocBook XSL stylesheets. The DB stylesheets output my table of contents as nested dl, dd, and dt tags. But for some reason, Prince keeps breaking pages in an odd way.

I think it is trying to keep the lists together. I just want it to flow across the pages and stop trying to keep these lists together, but "page-break-inside:auto" doesn't seem to be doing it.

Is there a way to get my dl, dt, and dd lists to flow and page break normally?

Here is sample HTML & CSS:

HTML:

<!DOCTYPE html SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>TOC</title>
    </head>
    <body>
        <div class="toc"><h2 class="toc">Contents</h2><dl>
                <dt><div class="toc_line"><span class="preface"><a href="#Preface"
                            >Preface</a></span></div></dt>
                <dt><div class="toc_line"><span class="part"><a href="#d0e179"
                    >Part</a></span></div></dt>
                <dd><dl>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                    </dl></dd>
                <dt><div class="toc_line"><span class="part"><a href="#d0e179"
                    >Part</a></span></div></dt>
                <dd><dl>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                    </dl></dd>
                <dt><div class="toc_line"><span class="part"><a href="#d0e179"
                    >Part</a></span></div></dt>
                <dd><dl>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                        <dt><div class="toc_line"><span class="chapter"><a href="#chapter"
                                            >Chapter<br /><span class="tocauthor"
                                            >Author T. Come</span></a></span></div></dt>
                    </dl></dd>
            </dl></div></body>
</html>


And my CSS for this part:

/* table of contents */

div.toc {
    page-break-before:right;
    page-break-inside:auto;
    page:toc;
    prince-page-group: start;
}

@page toc :first {
    margin-left:1in;
    @top-right {content: normal;}
}

@page toc :right {
    margin-left:1in;
    @top-right {
        content: "Contents \A0  \A0  \A0  \A0  \A0 \A0" counter(page, lower-roman);
        font-family: GaramondPro, "Times New Roman", Verdana, Arial;
        font-size:10pt;}
}

@page toc :left {
    margin-right:1in;
    @top-left {
        content: counter(page, lower-roman) " \A0  \A0  \A0  \A0  \A0 \A0 Contents" ;
        font-family: GaramondPro, "Times New Roman", Verdana, Arial;
        font-size:10pt;}
}

@page toc :blank {
    @top-left {content:normal;}
    @top-right {content: normal;}
    @bottom-center {content: normal;}
}



div.toc a {
    text-decoration: none;
    font-weight:normal;
    color: black;
}

div.toc span.tocauthor {
    font-weight:normal;
    font-style:italic;
}

dl {
    page-break-inside:auto;
    display:list-item;
}

div.toc_line {
    margin-bottom: .3em;
}


div.toc a::after {
    content: leader('.') target-counter(attr(href), page);
}

div.toc span.preface a::after {
  content: leader('.') target-counter(attr(href), page, lower-roman);
}
jbzech
As a followup. It will flow/break pages normally if I make all my <dt> tags "display:inline;". But that makes controlling the appearance of my TOC a nightmare (one that I'm still having).

Thanks again if you are able to help.
mikeday
This rule should fix it:
dt { page-break-after: auto }

We might need to change the default style sheets so that they don't try to be too clever unless you explicitly ask for it. :)
jbzech
Thank you, Mike. It appears to have worked. For some reason, I tried a dozen more complicated things, and never though to do "page-break-AFTER" on the <dt>. In retrospect, that makes total sense. Thank you for your help.