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] changing how xrefs to listings are rendered in PDF


Bob,

thanks for answering.

I have introduced some changes to the asciidoc file I'm working with,
and now, docbook version which is generated, has all listings are
included in <example> tag, as you suggested, e.g.:

<example id="listing_some_id">
<title>Some Title</title>
<programlisting language="java" linenumbering="unnumbered">
some code here
</programlisting>
</example>

In PDF this is rendered as "Example 5.1" and references (xref
linkend="listing_some_id"/>) are also rendered like "Example 5.1".
This is almost perfect, but I would like to have "Listing 5.1"
instead.

Could you please explain how to do this?

I tried to do the following:
<l:context name="xref-number-and-title">
        <l:template name="example" text="Listing %n"/>
</l:context>
but it did not help.

-- 
Regards / Pozdrawiam
Tomek Kaczanowski
http://kaczanowscy.pl/tomek


2011/9/27 Bob Stayton <bobs@sagehill.net>:
> Hi Tomek,
> Are you using the <example> element in your documents?  If not, you could
> use it instead of formalpara to contain your programlistings. The example
> element already has the machinery for titling, numbering and cross
> referencing to those numbers.  You could even generate a list of Listings
> like a List of Figures at the front.  You would need to change the gentext
> file for all instances of example to display "Listing %n" rather than
> "Example %n", but otherwise that's it.
>
> Adding numbering to formalpara in the display and the cross referencing can
> be done, but requires a lot more customization.  Also, you would not be able
> to use formalpara for other purposes.
>
> Bob Stayton
> Sagehill Enterprises
> bobs@sagehill.net
>
>
> ----- Original Message ----- From: "Tomek Kaczanowski"
> <kaczanowski.tomek@gmail.com>
> To: <docbook-apps@lists.oasis-open.org>
> Sent: Monday, September 26, 2011 12:51 PM
> Subject: [docbook-apps] changing how xrefs to listings are rendered in PDF
>
>
>> Hi All,
>>
>> I'm writing a book using Docbook and have an issue with how references
>> to listings are rendered in PDF version.
>>
>> For example, my docbook file contains the following fragment:
>>
>> <simpara>Blah blah blah as presented on listing <xref
>> linkend="listing_shortest_test"/>.</simpara>
>>
>> <formalpara id="listing_shortest_test">
>> <title>One-Liner Test</title>
>> <para>
>> <programlisting language="java" linenumbering="unnumbered">
>> // some cool code here
>> </programlisting>
>> </para>
>> </formalpara>
>>
>> In PDF version (generated with fop) xhref link to the listing is rendered
>> as:
>>
>> "Blah blah blah as presented on listing One-Liner Test."
>>
>> I would like to look it differently, i.e. like this:
>>
>> "Blah blah blah as presented on listing 3.1"
>>
>> I have achieved similar thing with tables and figures (as discussed
>> here http://is.gd/wAInBB) by tweaking the docbook-xsl/fo.xsl like
>> this:
>> <xsl:param name="local.l10n.xml" select="document('')"/>
>> <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
>>  <l:l10n language="en">
>>    <l:context name="xref-number-and-title">
>>      <l:template name="table" text="Table %n"/>
>>    </l:context>
>>  </l:l10n>
>> </l:i18n>
>>
>> I have tried to do the same with listings, using various options
>> (well, I was just shooting in the dark, I know...):
>>
>>     <l:context name="xref-number-and-title">
>>       <l:template name="listing" text="Listing %n"/>
>>       <l:template name="example" text="Listing %n"/>
>>       <l:template name="formalpara" text="Listing %n"/>
>>     </l:context>
>>
>> but without any success. I have also tried to change value of
>> xref.with.number.and.title but
>> this seems to be broken (nothing happens).
>>
>> I read http://www.sagehill.net/docbookxsl/CustomGentext.html and a lot
>> of other docbook xsl information, but I still do not know how to do
>> this.
>>
>> Could you please help?
>>
>> P.S. To give you the full picture, I'm using AsciiDoc, but I do not
>> think it matters. At some point I got a valid docbook document which
>> is converted to PDF and this is the part I'm struggling with.
>>
>> --
>> Regards,
>> Tomek Kaczanowski
>> http://kaczanowscy.pl/tomek
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
>> For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
>>
>>
>>
>
>


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