TOC text alignment
Posted: Fri Mar 06, 2020 5:25 am
The text for my TOC for Parts and Chapters align well, but the author and book information are justified. My attempts to fix this via CSS have proved unsuccessful.
I'd also like to have the page numbers right aligned in the Chapters, as they are in the Parts.
And Lastly, the title of the TOC (Contents) gets put on it's own page. How can I force it to be on the same page as the TOC?
Below is a snippet of my CSS related to the TOC:
XML I'm using to generate the PDF:
I've attached the generated PDF as PNGs.
I'd also like to have the page numbers right aligned in the Chapters, as they are in the Parts.
And Lastly, the title of the TOC (Contents) gets put on it's own page. How can I force it to be on the same page as the TOC?
Below is a snippet of my CSS related to the TOC:
Code: Select all
@page toc {
@bottom-right-corner {
content: counter(page, lower-roman);
}
}
ul.toc {
page: toc;
}
ul.toc li {
list-style-type:none;
text-align: left !important;
}
ul.toc a {
link: attr(href);
text-decoration:none;
text-align: left !important;
}
ul.toc a:after{
color:black;
content: leader(" ") target-counter(attr(href), page);
link: attr(href);
}
li.book-section {
font-weight:bold;
}
li.toc-author-item
{
color: black;
text-align: left !important;
}
span.author {
font-weight:normal;
text-align: left !important;
}
span.toc-summary {
font-weight:normal;
text-align: left !important;
}
@page {
size: us-letter;
}
@page {
@bottom-left {
content: "...Books - Introduction to ...";
font-size:80%;
}
}
@page {
@bottom-right {
content: counter(page);
font-size:80%;
}
}
@page {
margin: 1in;
}
@page :left {
margin-right: 1in;
}
@page :right {
margin-left: 1in;
}
@page two-columns-page {
column-count: 2;
column-gap: 1in;
}
@page two-columns-page {
margin: 1in;
}
@page two-columns-page:left {
margin-right: 1in;
}
@page two-columns-page:right {
margin-left: 1in;
}
Code: Select all
<body>
<div class="toc">
<h1>Contents</h1>
<ul class="toc">
<li class="book-section">
<a class="ref-section" href="part-1">
<span class="toc-label" title="I">Part I.</span> This is Part I</a>
<ul class="book-section">
<li class="toc-item">
<a class="ref-chap"
id="s9781544357140-toc.i3"
href="#s9781506395449.i804">Chapter 1. This is Chapter 1</a>
<span class="author-list">
<br/>
<span class="author">Steve Kippman</span>
</span>
<br/>
<span class="toc-summary">From <i>This Book, Second Edition</i>
</span>
</li>
</ul>
</li>
<li class="book-section">
<a class="ref-section" href="part-2">
<span class="toc-label" title="II">Part II.</span> This is Part II</a>
<ul class="book-section">
<li class="toc-item">
<a class="ref-chap"
id="s9781544357140-toc.i6"
href="#s9781506362205.i2009">Chapter 2. This is Chapter 2</a>
<span class="author-list">
<br/>
<span class="author">Chris Bar</span>
<br/>
<span class="author">George C. Right</span>
</span>
<br/>
<span class="toc-summary">From <i>Another Book, Eighth Edition</i>
</span>
</li>
</ul>
</li>
<li class="book-section">
<a class="ref-section" href="part-3">
<span class="toc-label" title="III">Part III.</span> This is Part III</a>
<ul class="book-section">
<li class="toc-item">
<a class="ref-chap"
id="s9781544357140-toc.i7"
href="#s9781506362205.i2663">Chapter 3. This Chapter 3</a>
<span class="author-list">
<br/>
<span class="author">Chris Bar</span>
<br/>
<span class="author">George C. Right</span>
</span>
<br/>
<span class="toc-summary">From <i>Another Book, Eighth Edition</i>
</span>
</li>
</ul>
</li>
</ul>
</div>