OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] How to make chemical structure automatically numbered


Hi Bernhard,

You said:

> As long as there is no possible was to have a "proprietary"counter for structures (as figures) structures do not have anindependent numbering.

The DocBook XSL stylesheets allow for a great deal of customization, so it is possible to set up independent counters if you are willing to write sufficient code. In this case, it isn't too hard because there is a separate XSL mode used for that called 'label.markup'. In the stylesheet file common/labels.xsl, you will find this template:

<xsl:template match="d:figure|d:table|d:example" mode="label.markup">
 <xsl:variable name="pchap"
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ select="(ancestor::d:chapter
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |ancestor::d:appendix
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |ancestor::d:article[ancestor::d:book])[last()]"/>

 <xsl:variable name="prefix">
ÂÂÂ <xsl:if test="count($pchap) &gt; 0">
ÂÂÂÂÂ <xsl:apply-templates select="$pchap" mode="label.markup"/>
ÂÂÂ </xsl:if>
 </xsl:variable>

 <xsl:choose>
ÂÂÂ <xsl:when test="@label">
ÂÂÂÂÂ <xsl:value-of select="@label"/>
ÂÂÂ </xsl:when>
ÂÂÂ <xsl:otherwise>
ÂÂÂÂÂ <xsl:choose>
ÂÂÂÂÂÂÂ <xsl:when test="$prefix != ''">
ÂÂÂÂÂÂÂÂÂÂÂ <xsl:apply-templates select="$pchap" mode="label.markup"/>
ÂÂÂÂÂÂÂÂÂÂÂ <xsl:apply-templates select="$pchap" mode="intralabel.punctuation">
ÂÂÂÂÂÂÂÂÂÂÂÂÂ <xsl:with-param name="object" select="."/>
ÂÂÂÂÂÂÂÂÂÂÂ </xsl:apply-templates>
ÂÂÂÂÂÂÂÂÂ <xsl:number format="1" from="d:chapter|d:appendix" level="any"/>
ÂÂÂÂÂÂÂ </xsl:when>
ÂÂÂÂÂÂÂ <xsl:otherwise>
ÂÂÂÂÂÂÂÂÂ <xsl:number format="1" from="d:book|d:article" level="any"/>
ÂÂÂÂÂÂÂ </xsl:otherwise>
ÂÂÂÂÂ </xsl:choose>
ÂÂÂ </xsl:otherwise>
 </xsl:choose>
</xsl:template>

When a counter needs to be generated, the stylesheet does <xsl:apply-templates mode="label.markup">, and the element matched is processed by this template rather than the main template for that element. All it does is output a number label.

Most of the template code is handling whether or not the label contains chapter-number or just number. The key line that generates the sequence number is:

<xsl:number format="1" from="book|article" level="any"/>

This instruction is quite flexible and has a long reference page describing all the ways its attributes can be combined to do counting. One of its attributes that isn't shown is "count", which indicates what element is being counted. It isn't shown here because the default is the current context element (that element matched by the template). The count attribute holds a match _expression_, so can be written as:

count="d:figure[@condition='chem']"ÂÂ

so then each instance of its application will count only <figure condition="chem"> elements. You'll need two custom xsl:templates, one to match on figure[@condition != 'chem'] and one to match on figure[@condition = 'chem']. In each, you have <xsl:number> elements to match the condition for counting.

One further complication is the word "Figure" in your language would be applied to all of them. To change that will require further customization.

Bob Stayton
Sagehill Enterprises
bobs@sagehill.net
On 10/12/2018 6:46 AM, Bernhard Kleine wrote:
Hi, Peter and Thomas,

@Peter: It seems that figure is a valid element, however, the numbering
of figure for structures would conflict with the numbering a normal
figure. As long as there is no possible was to have a "proprietary"
counter for structures (as figures) structures do not have an
independent numbering. I wonder since there are an awful lot of chemical
papers where there is an independent list of structures, that none of
them has been prepared with docbook. Otherwise there would be a solution
already.

@Thomas: since the structures are svg as well as most figure in my book,
I have considered svg. However, than I would lable a contruct of
structures, but not the individual ones. Coming from LaTeX, the
numbering of figures was always a simple use of apropriate macros.

Regards

Bernhard


Am 12.10.2018 um 14:28 schrieb Thomas Schraitle:
Hi,

Am Freitag, 12. Oktober 2018, 14:12:15 CEST schrieb Bernhard Kleine:
In my second mail to this threat a showed a complex table with
structures, arrows labeling etc. I cannot envisage this without a table
structure.
As Dave already pointed out, a table might not be the appropriate way to 
layout things.

Have you considered SVG? With SVG (or any other vector format) you can do all 
the fancy stuff (arrows, labeling etc.) that you need.



    



[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]