Preface

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
santhudev123
Posts: 5
Joined: Thu Apr 11, 2019 1:57 pm

Preface

Post by santhudev123 » Fri Apr 19, 2019 12:59 pm

Hello,

I am working on oxygen XML 21.0 for the current project, I am customizing a new plugin for PDF output. how to add headers and footers for the preface and roman page numbers for the same in TOC through CSS.

Thanks and Regards,
Santhosh M

Costin
Posts: 603
Joined: Mon Dec 05, 2011 6:04 pm

Re: Preface

Post by Costin » Mon Apr 22, 2019 11:24 am

Hello,

You could do this through your own CSS customization. You should make sure you use the right selectors with the @page at-rule to add content to the specific pages you need to modify (i.e front-page, for the cover, table-of-contents, for the TOC, etc).
There is no dedicated named-page available for the preface (as long as you refer to the preface in a Bookmap specialization) and, because of that, by default the preface page is considered a matter-page (together with any other pages that appear in front of chapters).

However, there is a way to match the preface:
- set an outputclass="preface" attribute on your "preface" reference in the DITA Map, then, in your customization CSS set a named-page for it, then apply your own header customization. For example:

Code: Select all

@page preface{
    @top-center{
   background-image: url("your_Image.jpg");
    }
    @bottom-center {
    content: "Some text content for the footer zone";
    }
}

*[outputclass~="preface"]{
    page: preface !important;
}
To better understand how customizing specific parts of the output could be done, see:
- https://www.oxygenxml.com/doc/versions/ ... e_css.html
- https://www.oxygenxml.com/doc/versions/ ... oters.html

As for the TOC, you could also use your own CSS rules to style it.
To make an idea of the selectors you could use for that, see: https://www.oxygenxml.com/doc/versions/ ... tents.html

Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support

santhudev123
Posts: 5
Joined: Thu Apr 11, 2019 1:57 pm

Re: Preface

Post by santhudev123 » Mon Apr 22, 2019 2:15 pm

Hello Costin,

Thanks for that, i have created the Headers and Footers for Preface using outputclass="preface". But i didn't got the answer for roman page numbering.

One more query, how to get page numbering in footer for chapters as "Page 1 / 20" in place of "Page 1"

I tried with this: content: "Chap." string(number) " - " "Page" " " counter(page) " " "/" " " counter(pages)
but no result.

Regards,
Santhosh M

Costin
Posts: 603
Joined: Mon Dec 05, 2011 6:04 pm

Re: Preface

Post by Costin » Mon Apr 22, 2019 5:34 pm

Hi Santosh,

Regarding the TOC, I thought you refer to the page numbers specific for the topic references in the TOC list.
That's why I suggested:
As for the TOC, you could also use your own CSS rules to style it.
To make an idea of the selectors you could use for that, see: https://www.oxygenxml.com/doc/versions/ ... tents.html
However, as I now understand that you referred to the page number of the TOC page itself, that one should already have roman page numbering by default. However, the headers are filtered for the very first page of the TOC, from the default CSS.

Page numbers are added by headers and the default bundled CSS controlling headers and footers is "p-pages-and-headers.css", as specified in the Headers and Footers section from the User-Guide.

So you could take a look in that CSS and, based on the rules inside it, you could write your own CSS rules, in a separate customization CSS file of your own, that would override the default ones at transformation time.

More exactly, if you need the page number to be displayed also for the first page of the Table Of Contents, in your customization CSS, you should have:

Code: Select all

@page table-of-contents:first:left {
	    @top-left {
	        content: string(toc-header) " | " counter(page, lower-roman);
	    }
	}
	@page table-of-contents:first:right {
	     @top-right {
	         content: string(toc-header) " | " counter(page, lower-roman);
	     }
	}
In case you need to change lower-latin numerals used for numbering of the other (content) pages to lower-roman, you could also use in your CSS

Code: Select all

	@page :left {
        @top-left {
            content: string(maptitle) string(parttitle) string(chaptertitle) string(sectiontitle) " | " counter(page, lower-roman);
        }
    }

    @page :right{
        @top-right {
            content: string(maptitle) string(parttitle) string(chaptertitle) string(sectiontitle) " | " counter(page, lower-roman);
        }
    }
Starting from the default CSS, you could write your own rules to customize the page headers and footers, the numbering, and so on.
There is no predefined counter for pages (for the total number of pages).
More information on numbering and the default CSS files that control numbering and contain the counters is also available in the User-Guide.
Costin Sandoi
oXygen XML Editor and Author Support

santhudev123
Posts: 5
Joined: Thu Apr 11, 2019 1:57 pm

Re: Preface

Post by santhudev123 » Tue Apr 23, 2019 3:30 pm

Hi again,

Thanks for your support, I started working on new manual where i found below issues:

1. How to reset the page numbers(Footer) at each sub-chapters.
Note: I have used the below rule in CSS to reset the page numbers at chapter level and i have achieved it accordingly, But now the project requirement is to reset the page numbers(Footer) at each sub-chapters.

*[class ~= "topic/topic"][is-chapter]:not([is-part]) {
counter-reset: page 1 section1 !important;
}

2. Similarly i am able to get the sub-chapter name in the header as "1.1 - Structure", but project requirement is like "Structure" without sub-chapter number and hyphen(-).

In my customized CSS, I have given as below:

*[class ~= "map/map"] *[class ~= "topic/topic"][is-section]:not([is-part]) > *[class ~= "topic/title"] {
string-set: sectiontitle content(), sectiontitle "" !important;
}
*[class ~= "map/map"] *[class ~= "topic/topic"][is-section] {
string-set: number counter(section)!important;
}

3. One more query, we have different manual identification number allocated for each sub-chapters which falls @bottom-center of the footer. how to achieve this?.

Thanks in advance,

Regards,
Santhosh M

Dan
Posts: 416
Joined: Mon Feb 03, 2003 10:56 am

Re: Preface

Post by Dan » Wed Apr 24, 2019 11:21 am

Hello,

Please read the topic:
https://www.oxygenxml.com/doc/versions/ ... e_css.html
In this way you can find out how to develop your CSS rules.

1. For example, to match a topic child of a chapter, you can expand your selector:

Code: Select all

*[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"]{
counter-reset: page 1 !important;
}
I am not sure about resetting the section1 counter here, or if the section2 counter should be reset also. You should try and test.

2. There is no attribute "is-section" in the merged XML file, so your rules are not matching anything. Please see the "p-numbering-deep.css" for the definition of the sectiontitle string set:

Code: Select all

*[class ~= "map/map"][p|numbering='deep'] *[class ~= "topic/topic"][is-chapter]:not([is-part]) > *[class ~= "topic/topic"] > *[class ~= "topic/title"] {
string-set: sectiontitle " | " counter(chapter) "." counter(section1) " - " content();
}
You can simply copy the selector to your customization and remove this part:

Code: Select all

counter(chapter) "." counter(section1) " - "
3. Define a string set on the element that contains the manual identification number, then use it in the @bottom-center. There are examples here: https://www.oxygenxml.com/doc/versions/ ... aid-title6

Many regards,
Dan

Post Reply