Discussion:
Numbered paragraphs
Richard Hamilton
2014-08-01 22:47:59 UTC
Permalink
Before I dive into a customization, has anyone ever customized the fo stylesheets to generate paragraph numbers? That is, sequentially numbering every paragraph in a book from the beginning to the end.

The ideal would be to put them into the margin, but I'd be happy with any method that assigned a sequential number to each paragraph.

Best regards,
Dick Hamilton
-------
XML Press
XML for Technical Communicators
http://xmlpress.net
***@xmlpress.net
Jens Stavnstrup
2014-08-01 22:55:33 UTC
Permalink
Hi Richard

Have used this solution for many years.

Note the parameter $use.para.numbering, which have to be defined or removed.

Regards

Jens


<xsl:template match="chapter/para
|appendix/para
|sect1/para
|sect2/para
|sect3/para
|sect4/para
|sect5/para">
<fo:block xsl:use-attribute-sets="normal.para.spacing">
<xsl:if test="$use.para.numbering != 0">
<xsl:number from="book"
count="para[parent::chapter or
parent::appendix or
parent::sect1 or
parent::sect2 or
parent::sect3 or
parent::sect4 or
parent::sect5]" format="111" level="any"/>
<xsl:text>. </xsl:text>
</xsl:if>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
Post by Richard Hamilton
Before I dive into a customization, has anyone ever customized the fo
stylesheets to generate paragraph numbers? That is, sequentially numbering
every paragraph in a book from the beginning to the end.
The ideal would be to put them into the margin, but I'd be happy with any
method that assigned a sequential number to each paragraph.
Best regards,
Dick Hamilton
-------
XML Press
XML for Technical Communicators
http://xmlpress.net
---------------------------------------------------------------------
Stefan Seefeld
2014-08-01 22:56:15 UTC
Permalink
Post by Richard Hamilton
Before I dive into a customization, has anyone ever customized the fo stylesheets to generate paragraph numbers? That is, sequentially numbering every paragraph in a book from the beginning to the end.
The ideal would be to put them into the margin, but I'd be happy with any method that assigned a sequential number to each paragraph.
For an OMG specification I have used ordered lists to wrap all text to
get essentially the same effect as you seem to seek (see
http://www.omg.org/spec/VSIPL++/1.2/PDF/).
You can find my customization in
https://github.com/vsip/specs/tree/master/xsl, though this may look like
a set of crude hacks to trained eyes. (Feel free to clone at your
leisure....)

Stefan
--
...ich hab' noch einen Koffer in Berlin...
Richard Hamilton
2014-08-02 00:35:47 UTC
Permalink
Thanks Stefan and Jens,

Both of your suggestions were useful in leading me to a possible resolution.

I tried Jens' solution, which worked as advertised, but then after looking at Stefan's, I decided to create an intermediate DocBook source with the numbering. This has the advantage of letting me merge back into the source content (like index entries) that might have been generated using the PDF.

I tried to do this in two ways. The first way was to insert a phrase with the number at the beginning of every paragraph. The second was to insert a sidebar in the same spot, then monkey with the parameters to get the sidebar contents in the outside margin (basically just change body.start.indent and body.end.indent to .5in, though I think this won't work with FO. It does work with XEP).

Both methods work, but even though it seemed a bit strange to insert sidebars all over the place, I went with the second method, which works and is valid DocBook (though if I use "real" sidebars in a book, I'll need to detect them to avoid nesting sidebars:).

Since the objective was not to get beautiful output, but rather to get a working draft that an indexer can use, this does what I need. And, it looks like it wouldn't take too much to make this look pretty good, if you wanted to have a production output that did this kind of thing.

Thanks again, Jens and Stefan, for pointing me in the right direction.

Best regards,
Dick Hamilton
-------
XML Press
XML for Technical Communicators
http://xmlpress.net
Post by Stefan Seefeld
Post by Richard Hamilton
Before I dive into a customization, has anyone ever customized the fo stylesheets to generate paragraph numbers? That is, sequentially numbering every paragraph in a book from the beginning to the end.
The ideal would be to put them into the margin, but I'd be happy with any method that assigned a sequential number to each paragraph.
For an OMG specification I have used ordered lists to wrap all text to
get essentially the same effect as you seem to seek (see
http://www.omg.org/spec/VSIPL++/1.2/PDF/).
You can find my customization in
https://github.com/vsip/specs/tree/master/xsl, though this may look like
a set of crude hacks to trained eyes. (Feel free to clone at your
leisure....)
Stefan
--
...ich hab' noch einen Koffer in Berlin...
Continue reading on narkive:
Loading...