Is there a way to have chapter titles in headers for PDF?

This forum is for all Flare issues related to PDF, eBook, Microsoft Word, Adobe FrameMaker, XPS, and XHTML book targets.
Post Reply
AnnaK
Propeller Head
Posts: 12
Joined: Mon Oct 17, 2011 6:14 am

Is there a way to have chapter titles in headers for PDF?

Post by AnnaK »

Hi! I am looking for a way to place chapter names to the headers for PDF outputs. I use different page layouts for odd and even pages in my document. I want the Odd pages to have chapter name in the right-head corner.

I found an example in Flare help saying that you can do so by using Page layouts. But I couldn't find the information about HOW to do it. Will be grateful for any ideas!
Nita Beck
Senior Propellus Maximus
Posts: 3667
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Is there a way to have chapter titles in headers for PDF?

Post by Nita Beck »

Welcome! I see you're new around here.

Yes, this is easy to do, by inserting a variable, in particular the Level1 variable from the built-in Heading variable set. Assuming that you're using H1 (or an H1 variant) for your chapter headings, this variable will pick up the chapter title. (Caveat: I know this works for PDF output; can't say if it works for Word output.)
Heading_Variables.png
BTW, if you want to position things left-aligned, right-aligned within the same header or footer, you will need to use tables. That way, you can left-align whatever is in the left column and right-align whatever is in the right column. If you want something in the middle, then use a 3-column table and center-align whatever is in the middle column.

I hope this gives you enough to achieve your goal.
You do not have the required permissions to view the files attached to this post.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
AnnaK
Propeller Head
Posts: 12
Joined: Mon Oct 17, 2011 6:14 am

Re: Is there a way to have chapter titles in headers for PDF?

Post by AnnaK »

Thanks for a quick reply, Nita! I had no idea about what heading variable set is for! I looked at it closer but seems iy doesn't solve my problem. The thing is that I have a first chapter page and it has the chapter name on it all the following pages must have the same chapter name in the heading.

Right now I have a system variable in the right-head corner with the number of chapter in it. What I want have is a chapter number and then its title applied to all the pages withing this chapter. The format is:

Chatper 2: Mary's trip, where 'Mary's trip' is a name of the chapter. So if this chapter has 5 pages, all of them should have the same header.

I am not even sure if there is a way to implement this.
AnnaK
Propeller Head
Posts: 12
Joined: Mon Oct 17, 2011 6:14 am

Re: Is there a way to have chapter titles in headers for PDF?

Post by AnnaK »

I think I found a solution. I used Title variable in the system variable set and provided the same title in the topic properties to all the topics in the same chapter. Thanks for the hint, Nita! I didn't know where to search.
Nita Beck
Senior Propellus Maximus
Posts: 3667
Joined: Thu Feb 02, 2006 9:57 am
Location: Pittsford, NY

Re: Is there a way to have chapter titles in headers for PDF?

Post by Nita Beck »

Yes, it's possible to implement this!

You might be making this a little too hard... I really do think that the Level1 heading variable can give you exactly what you're looking for, provided you set up a few other things.

Let me tell you how I do this.

First, I've got a style called h1.Chapter in which is defined an auto-number to control the "Chapter x. " part of a chapter's title. In the CSS (in the internal text editor), it looks like below. (There are other attributes, too, but they are not relevant to your question, so I've stripped them out for this example.) TIP: If you're using a medium for your PDF styles (as many prefer, rather than a separate stylesheet, which I prefer), make sure you're editing the style for that medium, not the default.

Code: Select all

h1.Chapter
{
	mc-auto-number-format: 'Chapter {chapnum}. ';
}
I then apply that h1.Chapter style to the headings of the topics that I want to start the different chapters with.

Next, in the TOC, I make sure that each of those topics is associated with a top-level book. I set each one's TOC properties to start a new chapter. The first chapter is set to start at 1, while the others are set to continue from previous (so 2, 3, 4, etc.).

Next, in the PDF target, I do set "Use TOC depth for heading levels" (on the Advanced tab of the Target Editor). This ensures a number of things, one of which is that only those top-level books will be h1s (heading level 1) in the generated PDF. (For what it's worth, I only ever use h1s [and h1 variants, such as h1.Chapter] and h2s for topic headings. I let Flare apply the appropriate h styles to topic headings when it generates the PDF, depending on where those topics reside in the TOC. That frees up from having to worry about reapplying heading styles if I decide to move stuff around on a TOC.)

Finally, in my headers where I want the chapter numbers and titles to show up, I use the Level1 variable from the Headings variable set. That does, indeed, yield "Chapter x: Mary's Trip" (or whatever), just what you're looking for.
Nita
Image
RETIRED, but still fond of all the Flare friends I've made. See you around now and then!
AnnaK
Propeller Head
Posts: 12
Joined: Mon Oct 17, 2011 6:14 am

Re: Is there a way to have chapter titles in headers for PDF?

Post by AnnaK »

Thanks a lot, Nita! I tried this out and it is working! You right! This approach is more correct I would say.
armplinker
Propeller Head
Posts: 21
Joined: Fri Oct 05, 2012 7:41 am
Location: Bedford MA

Re: Is there a way to have chapter titles in headers for PDF

Post by armplinker »

I may be missing something here , but what I want to do is embed the name of the chapter in the footer dynamically when chapters change like:

INTRODUCTION | 1 (right page)

1 | INTRODUCTION (left page)


CHAPTERNAMEWHATEVER | 1 (right page of CHAPTERNAMEWHATEVER )
2| CHAPTERNAMEWHATEVER (left page of CHAPTERNAMEWHATEVER )

etc.

I do not want

CHAPTER 1 - 1 - that is straightforward but no name is actually in this.

So CHAPTERNAMEWHATEVER needs to be computable. While it is generally true in my document that H1 is the chapter name, that is not always the case. So is there some way to create a variable that is always set to the chapter name within a chapter and resets for the next chapter?
Well, further fumbling reveals that these heading variables mentioned by others apply until the heading changes. So, an h6 heading, which I would NEVER use in a document, may serve as a source for the name of the particular chapter until changed. Let's try it:

1) Add an h6 to your wery first topic at the very bottom of the page (before the </body> tag). This example shows it added to the TOC page. It exists, and can be used as a heading variable as seen below.

<?xml version="1.0" encoding="utf-8"?>
<html xml:lang="en-us" xmlns:MadCap="http://www.madcapsoftware.com/Schemas/MadCap.xsd" MadCap:conditions="TM.PrintOnly">
<head><title>List of Figures</title>
</head>
<body>
<h1 class="front_matter"><MadCap:variable name="Heading.Level6" />
</h1>
<MadCap:listOfProxy style="mc-list-of-tag: p;mc-list-of-class: Figure-Caption;mc-list-of-paragraph-class: TOCLists;" />
<h6 class="nosize">List of Figures</h6>
</body>
</html>


2) BUT it is certainly hideous to look at :cry:, so add some css to make it have nosize and be transparent displayed on a transparent background. It's there, but awfully difficult to see by humans.


h6.nosize
{
line-height: 0;
font-size: 0px;
background-color: transparent;
color: transparent;
}



and hey presto! :D The text in the hiddent h6 magically wanders over into the h1 and displays!

Caution: put the h6 last on the page as shown above, or Flare will maddeningly assume it needs some space no matter what you do and shove the h1 title down enough to screw up your layout. :evil:

What would be WAY better is to be able to just do this more obviously in a declarative fashion. Too many workarounds :roll: - why not just create a system variable call CHAPTERNAME (SECTIONNAME) (BOOKNAME) etc. and set it for the (CHAPTER) (SECTION) (BOOK) ...?

HTH
armplinker
Propeller Head
Posts: 21
Joined: Fri Oct 05, 2012 7:41 am
Location: Bedford MA

Re: Is there a way to have chapter titles in headers for PDF

Post by armplinker »

Well, this is all well and good as far as it goes, but, it turns out that any heading styles which have mc-heading-level: 0, which basically identifies an entry that should not go into the TOC, will not be able to be used in a footer (or header too I guess) because with no heading level, they are not automatically considered variables as such. So nothing comes out int he footer for any h1 etc. that has numbering disabled.
The only way pages with an unnumbered h1 can have the same text in the footer is to hard-wire the text into the footer, which basically defeats the purpose of this.

However, it does work when h1 is numbered, which is partially gratifying.

Is there a workaround?

So an enhancement might be to have a declarative text string variable which can be set by chapter or section or whatever which can then be referenced in a page layout. This would reduce the number of page layouts required to accomplish this dramatically. In order to accomplish our agreed fix I now have 4 :oops: essentially identical page layouts doing the same thing with only the chapter name string differing between chapters (of course), which just seems excessive and prone to error/inconsistencies.

TOC
List of Figures
List of Equations
Welcome
Fiona
Sr. Propeller Head
Posts: 117
Joined: Tue Jan 27, 2015 7:44 am
Location: U.K.

Re: Is there a way to have chapter titles in headers for PDF

Post by Fiona »

Resurrecting rather an old topic, but I have a follow-up question.

Nina's response from Mon Oct 17, 2011 7:31 pm is great. My CSS is set up in exactly that way, and it all works as it should (yay!). However, in the headers I want only the chapter name and not its number. Is there some other way of achieving thsi (or a different variable I should be selecting), as Heading:Level 1 is giving me both the number and the heading?
Post Reply