2

How do I add section numbering of topics in PDF output in the DITA OT? I mean numbering like this:

1. Heading

     Some content

1.2. Heading

     Some more content

1.2.1. Heading

     Some further content

EDIT: My question was a bit unclear, I realize. I meant to say topic numbering (meant section in the more generic sense than section as a DITA element). Also, I know how to do this in code, but was wondering if I had missed some easier way to do this by simple configuration in the DITA OT - like a switch on or off argument or something. It's such a common request that it should be easier than having to modify stylesheets like this all the time:

http://tech.groups.yahoo.com/group/dita-users/message/18417

jelovirt
  • 5,844
  • 8
  • 38
  • 49
Anders
  • 12,556
  • 24
  • 104
  • 151
  • Could you add the XML source to the question, as the desired output doesn't give information which blocks are sections and which as topics. – jelovirt Feb 27 '13 at 08:49
  • @jelovirt: Yes, sorry meant topics, and also not the way I already know in stylesheets, see edit. – Anders Feb 27 '13 at 11:08

2 Answers2

2

You could use DITA-OT PDF plug-in generator, it has a switch for numbering all hierarchy levels. DITA-OT doesn't provide a separate configuration property for this, because it makes more sense to keep the built-in configuration set small.

jelovirt
  • 5,844
  • 8
  • 38
  • 49
  • Ok, I'm not sure it doesn't make sense to have it configurable, sort of like you can select whether to use labels or not for steps etc, but at least your plugin is an easy way to get this, so that's surely a workaround. Thanks. – Anders Mar 06 '13 at 22:27
1

Here's what I do. CSS:

body { counter-reset: H1; }     /* Create the counter for H1 */
h1:before {
  content: counter(H1) ". ";    /* Print the H1 number */
  counter-increment: H1;    /* Add 1 to next H1 */
 }
h1 { counter-reset: H2; }
h2:before {
  content: counter(H1) "." counter(H2) " ";
  counter-increment: H2;
}
h2 { counter-reset: H3; }
h3:before {
  content: counter(H1) "." counter(H2) "." counter(H3) " ";
  counter-increment:H3;

then render to XHTML (chunked to a single page) and convert the web page to PDF. Possibly not the canonical approach, but it works.

johntait.org
  • 740
  • 1
  • 8
  • 22
  • Ok, that's a different approach, and interesting. But no, it won't do in my situation, since I could never go through HTML. Most of our clients have high demands on the PDF output which we couldn't handle that way. – Anders Feb 28 '13 at 16:41