docbook-apps

Expand all | Collapse all

How to make chemical structure automatically numbered

  • 1.  How to make chemical structure automatically numbered

    Posted 10-11-2018 04:46
    Hi,

    this is for sure not the first instance of numbering chemical structure
    automatically during docbook transformation for print. But I can not
    find an example to learn from.

    I have the following example (of about 100 structures in my book). I
    want have these structures numbered with a bold number and
    automatically. I was told by Thomas Schaitle, this can be done by xsl.
    In "docbook xsl", I do not find an example. Chemical structures in my
    book are characterized by property="chemical". What is needed is

    1. make a individual number for each structure
    2. avoid numbering doubly if a structure is shown again
    3. generate the xreflabel with this number that the xref references
    find a target.

    BTW, if I generate an xreflabel by hand then these structures are
    correctly numbered. However, to be able to change the sequential
    arrangement of structures and still have the structures labeld
    sequentially, it is desirable to number them automatically. Please give
    me an example how to proceed. I have attached the svg file with the
    structure.

    Regards

    Bernhard


    schematypens="http://relaxng.org/ns/structure/1.0"?>
    type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
        xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
       
            <tgroup cols="1" align="center">
                <colspec colname="c1" colnum="1" colwidth="4cm" align="center"/>
               
                    <row>
                        <entry><emphasis
    role="chemname">Steran</emphasis></entry>
                    </row>
                    <row>
                        <entry><inlinemediaobject property="chemical"
    xml:id="chem.steran">
                            <imageobject>
                                <imagedata fileref="../bkchem/steran.svg"
    width="3.8cm"/>
                            </imageobject>
                        </inlinemediaobject></entry>
                    </row>
                    <row>
                        <entry align="right" valign="top"><xref
    linkend="chem.steran"/></entry>
                    </row>
               
            </tgroup>
       
       



    --
    spitzhalde9
    D-79853 lenzkirch
    bernhard.kleine@gmx.net
    www.b-kleine.com, www.urseetal.net
    -
    thunderbird mit enigmail
    GPG schlüssel: D5257409
    fingerprint:
    08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09




  • 2.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-11-2018 12:34
    Hi, Bernhard.

    It sounds like you should be using the formal title numbering behavior
    of one of the existing elements like example or figure. I hope I'm not
    misunderstanding, is your problem that you are using those elements
    already, and you need a custom formal element to hold *only* chemical
    structure figures?

    I think that if you use the formal
    element to hold your
    chemical structure SVG diagrams, you should be able to use the default
    formal title numbering behavior of
    to automatically number
    those figures. You can do things like generate a list of figures and
    customize the words in the figure numbering (for example, "Chemical
    structure #: Steran Backbone").

    I'm surprised that the element in your example isn't numbered
    in the way you want though.

    Here are some pages from Bob Stayton's DocBook XSL guide:

    http://www.sagehill.net/docbookxsl/FormalTitles.html#FormalNumbering
    http://www.sagehill.net/docbookxsl/TOCcontrol.html#TOCcomponents (if
    you wanted a list of figures at the start of a book or chapter)

    For example, I use figure elements like the one I pasted below. Good luck!

    Peter


    <topic version="5.1" xmlns="http://docbook.org/ns/docbook">
    <info>

    </info>




    <mediaobject>
    <imageobject>
    <imagedata fileref="your-image.png"/>
    </imageobject>


    </mediaobject>

    </topic>
    On Thu, Oct 11, 2018 at 12:46 AM Bernhard Kleine
    <bernhard.kleine@gmx.net> wrote:
    >
    > Hi,
    >
    > this is for sure not the first instance of numbering chemical structure automatically during docbook transformation for print. But I can not find an example to learn from.
    >
    > I have the following example (of about 100 structures in my book). I want have these structures numbered with a bold number and automatically. I was told by Thomas Schaitle, this can be done by xsl. In "docbook xsl", I do not find an example. Chemical structures in my book are characterized by property="chemical". What is needed is
    >
    > make a individual number for each structure
    > avoid numbering doubly if a structure is shown again
    > generate the xreflabel with this number that the xref references find a target.
    >
    > BTW, if I generate an xreflabel by hand then these structures are correctly numbered. However, to be able to change the sequential arrangement of structures and still have the structures labeld sequentially, it is desirable to number them automatically. Please give me an example how to proceed. I have attached the svg file with the structure.
    >
    > Regards
    >
    > Bernhard
    >
    >
    >
    >
    >
    > xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
    >
    > <tgroup cols="1" align="center">
    > <colspec colname="c1" colnum="1" colwidth="4cm" align="center"/>
    >

    > <row>
    > <entry><emphasis role="chemname">Steran</emphasis></entry>
    > </row>
    > <row>
    > <entry><inlinemediaobject property="chemical" xml:id="chem.steran">
    > <imageobject>
    > <imagedata fileref="../bkchem/steran.svg" width="3.8cm"/>
    > </imageobject>
    > </inlinemediaobject></entry>
    > </row>
    > <row>
    > <entry align="right" valign="top"><xref linkend="chem.steran"/></entry>
    > </row>
    >
    > </tgroup>
    >

    <para>Steran</para>

    >
    >
    >
    >
    > --
    > spitzhalde9
    > D-79853 lenzkirch
    > bernhard.kleine@gmx.net
    > www.b-kleine.com, www.urseetal.net
    > -
    > thunderbird mit enigmail
    > GPG schlüssel: D5257409
    > fingerprint:
    > 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09



  • 3.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-11-2018 14:27
      |   view attached
    Hi, Peter,

    unfortunately, using figures does not work in my example for the
    following reasons. It seems not possible to arrange a couple of figure
    inside a table: I show to you an example of a table containing
    structures and errors and labelling:

    The structures in  svg format are evident, the arrows are equally svg
    files; enzymes accompany the arrows and the structures are labeled,
    (???) for the missing numbers. If you show to me how to do this with
    figures in a table I will think of changing the whole work. Figures in a
    table are possible in LaTex, but not with docbook. Here
    inlinemediaobjects are used. And these - when containing structures -
    have to be numbered.
    Regards
    Bernhard

    Am 11.10.2018 um 14:34 schrieb Peter Desjardins:
    > Hi, Bernhard.
    >
    > It sounds like you should be using the formal title numbering behavior
    > of one of the existing elements like example or figure. I hope I'm not
    > misunderstanding, is your problem that you are using those elements
    > already, and you need a custom formal element to hold *only* chemical
    > structure figures?
    >
    > I think that if you use the formal
    element to hold your
    > chemical structure SVG diagrams, you should be able to use the default
    > formal title numbering behavior of
    to automatically number
    > those figures. You can do things like generate a list of figures and
    > customize the words in the figure numbering (for example, "Chemical
    > structure #: Steran Backbone").
    >
    > I'm surprised that the element in your example isn't numbered
    > in the way you want though.
    >
    > Here are some pages from Bob Stayton's DocBook XSL guide:
    >
    > http://www.sagehill.net/docbookxsl/FormalTitles.html#FormalNumbering
    > http://www.sagehill.net/docbookxsl/TOCcontrol.html#TOCcomponents (if
    > you wanted a list of figures at the start of a book or chapter)
    >
    > For example, I use figure elements like the one I pasted below. Good luck!
    >
    > Peter
    >
    >
    > <topic version="5.1" xmlns="http://docbook.org/ns/docbook">
    > <info>
    >
    > </info>
    >
    >

    >
    >
    > <mediaobject>
    > <imageobject>
    > <imagedata fileref="your-image.png"></imagedata>
    > </imageobject>
    >
    >

    > </mediaobject>
    >
    > </topic>
    > On Thu, Oct 11, 2018 at 12:46 AM Bernhard Kleine
    > <bernhard.kleine@gmx.net> wrote:
    >> Hi,
    >>
    >> this is for sure not the first instance of numbering chemical structure automatically during docbook transformation for print. But I can not find an example to learn from.
    >>
    >> I have the following example (of about 100 structures in my book). I want have these structures numbered with a bold number and automatically. I was told by Thomas Schaitle, this can be done by xsl. In "docbook xsl", I do not find an example. Chemical structures in my book are characterized by property="chemical". What is needed is
    >>
    >> make a individual number for each structure
    >> avoid numbering doubly if a structure is shown again
    >> generate the xreflabel with this number that the xref references find a target.
    >>
    >> BTW, if I generate an xreflabel by hand then these structures are correctly numbered. However, to be able to change the sequential arrangement of structures and still have the structures labeld sequentially, it is desirable to number them automatically. Please give me an example how to proceed. I have attached the svg file with the structure.
    >>
    >> Regards
    >>
    >> Bernhard
    >>
    >>
    >>
    >>
    >>

    >> xmlns:xlink="http://www.w3.org/1999/xlink" version="5.1">
    >>
    >> <para>polycyclic steran (<xref linkend="chem.steran" role="chem.ref"></xref>)</para>
    >>

    > <para>Steran</para>
    >

    >>
    >> <tgroup cols="1" align="center">
    >> <colspec colname="c1" colnum="1" colwidth="4cm" align="center"></colspec>
    >>
    >> <row>
    >> <entry><emphasis role="chemname">Steran</emphasis></entry>
    >> </row>
    >> <row>
    >> <entry><inlinemediaobject property="chemical" xml:id="chem.steran">
    >> <imageobject>
    >> <imagedata fileref="../bkchem/steran.svg" width="3.8cm"></imagedata>
    >> </imageobject>
    >> </inlinemediaobject></entry>
    >> </row>
    >> <row>
    >> <entry align="right" valign="top"><xref linkend="chem.steran"></xref></entry>
    >> </row>
    >>
    >> </tgroup>
    >>

    >>
    >>
    >>
    >>
    >> --
    >> spitzhalde9
    >> D-79853 lenzkirch
    >> bernhard.kleine@gmx.net
    >> www.b-kleine.com, www.urseetal.net
    >> -
    >> thunderbird mit enigmail
    >> GPG schlüssel: D5257409
    >> fingerprint:
    >> 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >

    --
    spitzhalde9
    D-79853 lenzkirch
    bernhard.kleine@gmx.net
    www.b-kleine.com, www.urseetal.net
    -
    thunderbird mit enigmail
    GPG schlüssel: D5257409
    fingerprint:
    08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09


    </bernhard.kleine@gmx.net>


  • 4.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-11-2018 14:45
    On 11.10.2018 16:26, Bernhard Kleine wrote:
    > unfortunately, using figures does not work in my example for the
    > following reasons. It seems not possible to arrange a couple of figure
    > inside a table: I show to you an example of a table containing
    > structures and errors and labelling:

    You can use <equation> element for this. It can appear almost anywhere
    in block context.

    --
    ------------------------------------------------------------------
    Jirka Kosek e-mail: jirka@kosek.cz http://xmlguru.cz
    ------------------------------------------------------------------
    Professional XML and Web consulting and training services
    DocBook/DITA customization, custom XSLT/XSL-FO document processing
    ------------------------------------------------------------------
    Bringing you XML Prague conference http://xmlprague.cz
    ------------------------------------------------------------------




  • 5.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 11:57
    Hi Jirka,

    This works but raises an error: equation must not occur among the
    children or descendants of table

    It transforms anyhow.

    Thanks for the hint.

    Bernhard


    Am 11.10.2018 um 16:45 schrieb Jirka Kosek:
    > On 11.10.2018 16:26, Bernhard Kleine wrote:
    >> unfortunately, using figures does not work in my example for the
    >> following reasons. It seems not possible to arrange a couple of figure
    >> inside a table: I show to you an example of a table containing
    >> structures and errors and labelling:
    > You can use <equation> element for this. It can appear almost anywhere
    > in block context.
    >

    --
    spitzhalde9
    D-79853 lenzkirch
    bernhard.kleine@gmx.net
    www.b-kleine.com, www.urseetal.net
    -
    thunderbird mit enigmail
    GPG schlüssel: D5257409
    fingerprint:
    08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09





  • 6.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 12:07
    I might question if the table (as layout) is necessary for your purposes?
    That would allow more flexibility in markup?
    Dave
    On Fri, 12 Oct 2018 at 12:57, Bernhard Kleine <bernhard.kleine@gmx.net> wrote:
    >
    > Hi Jirka,
    >
    > This works but raises an error: equation must not occur among the
    > children or descendants of table
    >
    > It transforms anyhow.
    >
    > Thanks for the hint.
    >
    > Bernhard
    >
    >
    > Am 11.10.2018 um 16:45 schrieb Jirka Kosek:
    > > On 11.10.2018 16:26, Bernhard Kleine wrote:
    > >> unfortunately, using figures does not work in my example for the
    > >> following reasons. It seems not possible to arrange a couple of figure
    > >> inside a table: I show to you an example of a table containing
    > >> structures and errors and labelling:
    > > You can use <equation> element for this. It can appear almost anywhere
    > > in block context.
    > >
    >
    > --
    > spitzhalde9
    > D-79853 lenzkirch
    > bernhard.kleine@gmx.net
    > www.b-kleine.com, www.urseetal.net
    > -
    > thunderbird mit enigmail
    > GPG schlüssel: D5257409
    > fingerprint:
    > 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
    >
    >


    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    Docbook FAQ.



  • 7.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 12:12
    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.

    Bernhard


    Am 12.10.2018 um 14:06 schrieb Dave Pawson:

    > I might question if the table (as layout) is necessary for your purposes?
    > That would allow more flexibility in markup?
    > Dave
    > On Fri, 12 Oct 2018 at 12:57, Bernhard Kleine <bernhard.kleine@gmx.net> wrote:
    >> Hi Jirka,
    >>
    >> This works but raises an error: equation must not occur among the
    >> children or descendants of table
    >>
    >> It transforms anyhow.
    >>
    >> Thanks for the hint.
    >>
    >> Bernhard
    >>
    >>
    >> Am 11.10.2018 um 16:45 schrieb Jirka Kosek:
    >>> On 11.10.2018 16:26, Bernhard Kleine wrote:
    >>>> unfortunately, using figures does not work in my example for the
    >>>> following reasons. It seems not possible to arrange a couple of figure
    >>>> inside a table: I show to you an example of a table containing
    >>>> structures and errors and labelling:
    >>> You can use <equation> element for this. It can appear almost anywhere
    >>> in block context.
    >>>
    >> --
    >> spitzhalde9
    >> D-79853 lenzkirch
    >> bernhard.kleine@gmx.net
    >> www.b-kleine.com, www.urseetal.net
    >> -
    >> thunderbird mit enigmail
    >> GPG schlüssel: D5257409
    >> fingerprint:
    >> 08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09
    >>
    >>
    >

    --
    spitzhalde9
    D-79853 lenzkirch
    bernhard.kleine@gmx.net
    www.b-kleine.com, www.urseetal.net
    -
    thunderbird mit enigmail
    GPG schlüssel: D5257409
    fingerprint:
    08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09





  • 8.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 12:29
    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.


    --
    Gruß/Regards
    Thomas Schraitle






  • 9.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 13:20
    I think the table is adding valid semantic structure here. It allows the
    figure numbering to exist at the Docbook level, not in SVG.

    Maybe use
    elements inside an <informaltable>? You could wrap the
    informaltable in an example to give the entire set of diagrams a title.

    Peter

    <informaltable>
    <tgroup cols="2">

    <row>
    <entry>


    <mediaobject>
    <imageobject>
    <imagedata fileref="1.svg"/>
    </imageobject>
    </mediaobject>
    </entry>

    <entry>


    <mediaobject>
    <imageobject>
    <imagedata fileref="2.svg"/>
    </imageobject>
    </mediaobject>
    </entry>
    </row>

    </tgroup>
    </informaltable>


    On Fri, Oct 12, 2018, 08:28 Thomas Schraitle <tom_schr@web.de> wrote:

    > 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.
    >
    >
    > --
    > Gruß/Regards
    > Thomas Schraitle
    >
    >
    >
    >
    > ---------------------------------------------------------------------
    > To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    > For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >
    >



  • 10.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 13:47
    Hi,

    Am Freitag, 12. Oktober 2018, 15:19:59 CEST schrieb Peter Desjardins:
    > I think the table is adding valid semantic structure here. It allows the
    > figure numbering to exist at the Docbook level, not in SVG.
    >
    > Maybe use
    elements inside an <informaltable>? You could wrap the
    > informaltable in an example to give the entire set of diagrams a title.

    Thanks for your reply Peter. I'm sorry, but I have to disagree. :)

    If Bernhard tries to display chemical structures, why using an overly
    complicated structure? KISS (keep it simple, stupid)! ;) I see no benefit in
    using a table here. Even the opposite: tables on mobile devices (EPUB) can
    have issues. It's better to avoid them.

    Even if you go from simple chemical structure to a chemical reaction, there is
    even no reason to split it into several pieces. A structure---and so a
    reaction---belongs together IMHO. With the features of SVG, it's possible.

    As DocBook doesn't provide a element for chemical structures, you need either
    use figure or equation (as Jirka pointed out). For example:

    <equation condition="chem">

    <mediaobject>
    <imageobject>
    <imagedata fileref="steran.svg"/>
    </imageobject>

    <para>Steran...</para>

    </mediaobject>
    </equation>

    IMHO, this is totally enough. Put everything in steran.svg what you need:
    labeling, text, arrows, etc.

    With the @condition attribute, you can distinguish a chemical structure from a
    "normal" equation (if you need to).

    Even if you really have to use subfigures for a chemical structure I would
    avoid table structures at all costs. For example, if you need to have two
    subfigures, you could use two mediaobjects:

    <equation condition="chem">

    <mediaobject>
    <imageobject>
    <imagedata fileref="steran-A.svg"/>
    </imageobject>

    <para>Steran A...</para>

    </mediaobject>
    <mediaobject>
    <imageobject>
    <imagedata fileref="steran-B.svg"/>
    </imageobject>

    <para>Steran B...</para>

    </mediaobject>
    </equation>

    Of course, you need to delegate the layout to the stylesheet and you need to
    write a customization layer. For FO it can be rendered indeed as a table and
    for HTML there are different (CSS) methods to position two objects side by
    side.


    --
    Gruß/Regards
    Thomas Schraitle






  • 11.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 14:59
    I.e. Semantically marked up docbook is clearly the wrong tool then.

    Dave
    On Fri, 12 Oct 2018 at 14:20, Peter Desjardins
    <peter.desjardins.us@gmail.com> wrote:
    >
    > I think the table is adding valid semantic structure here. It allows the figure numbering to exist at the Docbook level, not in SVG.
    >
    > Maybe use
    elements inside an <informaltable>? You could wrap the informaltable in an example to give the entire set of diagrams a title.
    >
    > Peter
    >
    > <informaltable>
    > <tgroup cols="2">
    >
    > <row>
    > <entry>

    >
    > <mediaobject>
    > <imageobject>
    > <imagedata fileref="1.svg"/>
    > </imageobject>
    > </mediaobject>
    >
    </entry>
    >
    > <entry>

    >
    > <mediaobject>
    > <imageobject>
    > <imagedata fileref="2.svg"/>
    > </imageobject>
    > </mediaobject>
    >
    </entry>
    > </row>
    >
    > </tgroup>
    > </informaltable>
    >
    >
    > On Fri, Oct 12, 2018, 08:28 Thomas Schraitle <tom_schr@web.de> wrote:
    >>
    >> 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.
    >>
    >>
    >> --
    >> Gruß/Regards
    >> Thomas Schraitle
    >>
    >>
    >>
    >>
    >> ---------------------------------------------------------------------
    >> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
    >> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
    >>


    --
    Dave Pawson
    XSLT XSL-FO FAQ.
    Docbook FAQ.



  • 12.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 13:47
    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.
    >
    >

    --
    spitzhalde9
    D-79853 lenzkirch
    bernhard.kleine@gmx.net
    www.b-kleine.com, www.urseetal.net
    -
    thunderbird mit enigmail
    GPG schlüssel: D5257409
    fingerprint:
    08 B7 F8 70 22 7A FC C1 15 49 CA A6 C7 6F A0 2E D5 25 74 09





  • 13.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 14:19
    Hi,

    Am Freitag, 12. Oktober 2018, 15:46:50 CEST schrieb Bernhard Kleine:
    >
    > @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.

    As I've pointed out in my last mail (coincidentally sent at the same time),
    you could use <equation>.

    However, I see the following solutions in regards to numbering:

    1. Use <equation> or <equation condition="chem">
    Pros:
    * if the book doesn't contain any normal equation, it's easy to apply
    * no schema customization
    * no stylesheet customization needed

    Cons:
    * Not sure if you want to label your chemical structure as "Equation"
    (can be fixed)
    * More stylesheet customization is needed, if you need to distinguish
    between numbering of a normal equation and numbering of a chemical
    structure

    2. Use

    Same as equation, it's just a matter of taste which one do you prefer.
    The same pros and cons apply.

    3. Create your own element (<chemical>?); creating DocBook RNG customization
    Pro:
    * free to design what structure you really need
    * easy with the help of RELAX NG
    * independent of any numbering of figure or equation

    Cons:
    * not be DocBook compatible anymore; to validate, you need your
    own schema
    * you need to write a customization layer for the DocBook XSL
    stylesheets


    I hope I haven't misunderstood your ideas. Does that make sense?


    > @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.

    I also come from a LaTeX background. ;)


    --
    Gruß/Regards
    Thomas Schraitle






  • 14.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 18:38
    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) > 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
    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.
    >>
    >>




  • 15.  Re: [docbook-apps] How to make chemical structure automatically numbered

    Posted 10-12-2018 20:09
    Bernhard--

    I'll just comment on one thing, then shut up :-). It appears you're
    already familiar with LaTeX. It's possible to convert DocBook to LaTeX
    using the dblatex program (http://dblatex.sourceforge.net/), and you can
    create customizations to take advantage of other LaTeX packages, etc.
    We've used dblatex for over a decade to do grammars; we added a few XML
    schemas + transformations not in standard DocBook for linguistic
    structures. There was a bit of a learning curve; xslt is definitely my
    un-favorite programming language. (Andy Black, who may be lurking on
    this list, helped us through the early days.)

    Mike Maxwell
    University of Maryland