TOC text alignment
Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
-
- Posts: 5
- Joined: Sat Mar 02, 2019 3:57 am
TOC text alignment
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>
page-1.png
page-2.png
You do not have the required permissions to view the files attached to this post.
-
- Posts: 667
- Joined: Wed Oct 16, 2019 3:47 pm
Re: TOC text alignment
Post by julien_lacour »
Hello,
To fix the first two point update the following selector:
The leader makes sense in a justified context, this is why the whole content was justified.
If you isolate the link in a block, the author and book information will be left aligned automatically (default behavior).
So you can also remove the text-align: left !important properties.
For the "Contents" title in TOC you need to update the ul.toc selector:
You also need to define another named page (if you did not) after your TOC to set back the default behavior:
Finally, your content needs a small update to make the CSS work:
Based on your remarks I opened an issue on our side to update our documentation and make it clearer.
Regards,
Julien
To fix the first two point update the following selector:
Code: Select all
ul.toc a {
display: block;
link: attr(href);
text-decoration:none;
}
If you isolate the link in a block, the author and book information will be left aligned automatically (default behavior).
So you can also remove the text-align: left !important properties.
For the "Contents" title in TOC you need to update the ul.toc selector:
Code: Select all
.toc {
page: toc;
}
Code: Select all
@page content {
/* Currently inherit from the default page.*/
}
.content {
page: content;
}
Code: Select all
<body>
<div>
<h1 class="toc">Contents</h1><!-- Update the class -->
<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/> is not necessary -->
<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/> is not necessary -->
<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/> is not necessary -->
<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>
<div class="content"><!-- Get back to default page -->
...
</div>
</body>
Regards,
Julien
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service