I had exactly the same problem wanting to keep a leading text together
with the following image for manuals. I solved this by some heavy
lifting in the XSL customization layers. I changed the stylesheet for
simpara that if the paragraph ends with a colon it keeps it together
with the next element. This works quite well as the leading text for
an image/grafic often can end with a colon instead of a full stop and
avoids polluting your text with processing instructions.
Modified simpara XSL template below. I am using is with FOP 1.0 and
Docbook XSL 1.57.2.
Henrik
<!--
Make paragraphs which end with colon to keep together with next
paragraph
-->
<xsl:template match="simpara">
<xsl:variable name="textStr">
<xsl:apply-templates/>
</xsl:variable>
<xsl:variable name="normalizedStr">
<xsl:if test="$textStr != ''">
<xsl:value-of select="normalize-space($textStr)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="lastChar">
<xsl:if test="$normalizedStr != ''">
<xsl:value-of select="substring($normalizedStr,string-
length($normalizedStr),1)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="keep.together">
<xsl:call-template name="pi.dbfo_keep-together"/>
</xsl:variable>
<xsl:variable name="height">
<xsl:call-template name="pi.dbfo-need"/>
</xsl:variable>
<fo:block xsl:use-attribute-sets="normal.para.spacing">
<xsl:if test="$keep.together != ''">
<xsl:attribute name="keep-together.within-column"><xsl:value-of
select="$keep.together"/></xsl:attribute>
</xsl:if>
<xsl:if test="$height != ''">
<xsl:attribute name="keep-with-next.within-column">always</
xsl:attribute>
</xsl:if>
<xsl:if test="$lastChar = ':'">
<xsl:attribute name="keep-with-next.within-column">always</
xsl:attribute>
</xsl:if>
<xsl:call-template name="anchor"/>
<xsl:copy-of select="$textStr"/>
</fo:block>
</xsl:template>
<!-- The following is required as otherwise we are not processing
footnote/simpara correctlty -->
<xsl:template match="footnote/simpara">
<xsl:apply-imports/>
</xsl:template>
<xsl:template match="listitem/*[1][local-name()='para' or
local-name()='simpara' or
local-name()='formalpara']
|glossdef/*[1][local-name()='para' or
local-name()='simpara' or
local-name()='formalpara']
|step/*[1][local-name()='para' or
local-name()='simpara' or
local-name()='formalpara']
|callout/*[1][local-name()='para' or
local-name()='simpara' or
local-name()='formalpara']"
priority="2">
<xsl:variable name="textStr">
<xsl:apply-templates/>
</xsl:variable>
<xsl:variable name="normalizedStr">
<xsl:if test="$textStr != ''">
<xsl:value-of select="normalize-space($textStr)"/>
</xsl:if>
</xsl:variable>
<xsl:variable name="lastChar">
<xsl:if test="$normalizedStr != ''">
<xsl:value-of select="substring($normalizedStr,string-
length($normalizedStr),1)"/>
</xsl:if>
</xsl:variable>
<fo:block>
<xsl:if test="$lastChar = ':'">
<xsl:attribute name="keep-with-next.within-column">always</
xsl:attribute>
</xsl:if>
<xsl:call-template name="anchor"/>
<xsl:copy-of select="$textStr"/>
</fo:block>
</xsl:template>
On Jan 6, 1:18 am, Tim Mertens <[email protected]> wrote:
> Yes, it is related to images that are inline in lists:
>
> [options="unbreakable"]
> . Item 1
> . Item 2
> +
> image::imagetwo.jpg[]
> . Item 3
> +
> image::imagethree.jpg[]
>
> The "unbreakable" option for the list can only be applied to the
> entire list and not individual list items, so while it will attempt to
> keep an entire list on one page when the 'unbreakable' option is
> applied to the list, if the list exceeds one page in length then it
> will not attempt to keep individual list items containing multiple
> blocks (such as a line of text and a following image) on the same
> page. So in the example above, supposing "imagethree.jpg" overflows
> onto page 2, the text "Item 3" will be displayed on page 1 and the
> image on page 2, even though "unbreakable" is applied to the list as a
> whole.
>
> My document contains a lot of images in this manner so it occurs very
> often that the image following the text for a list item overflows onto
> the following page rather than staying with the text.
>
> -Tim
>
> On Jan 5, 4:47 am, Henrik <[email protected]> wrote:> I thought your issue
> related to images.
>
> > For lists the unbreakable attribute was added to AsciiDoc 8.6.3.
>
> > Example:
>
> > [options="unbreakable"]
> > - Item 1
> > - Item 2
>
> > On Jan 5, 4:37 am, Tim Mertens <[email protected]> wrote:
>
> > > OK, so here is my solution in case anyone else runs into the same
> > > problem:
>
> > > To keep listitems together with elements that follow it (this applies
> > > to ALL numbered lists in the document, so do not use this method if
> > > that matters to you):
>
> > > Create an asciidoc.conf file with the following content:
> > > ========asciidoc.conf=========
>
> > > [listtags-numbered]
> > > item=<listitem><?dbfo keep-together="always"?>|</listitem>
>
> > > ==============================
>
> > > You can add the same setting for [listtags-bulleted] if you want the
> > > keep-together to apply to bulleted lists as well.
>
> > > The asciidoc.conf file should be in the same directory as your
> > > Asciidoc source text file. You must use FOP for PDF output, as
> > > dblatex PDF output does not appear to respect the keep-together tag
> > > (although it could perhaps be tweaked to handle it, but that is beyond
> > > me).
>
> > > Thanks,
> > > -Tim
>
> > > On Jan 4, 11:49 am, Tim Mertens <[email protected]> wrote:> Thanks
> > > Henrik,
>
> > > > It appears that neither dbfo-need nor dbfo keep-together works with
> > > > dblatex.
>
> > > > However, I did find that <?dbfo keep-together="always"?> works when
> > > > using FOP for output if I insert it manually in the XML where needed
> > > > (I dislike the default FOP formatting, however, which will require a
> > > > bit more work to make look as good as the default dblatex output).
>
> > > > The main issue I have now is that the keep-together tag must be
> > > > inserted after the <listitem> tag but before the <simpara> tag in the
> > > > xml output, which I have not found possible with asciidoc and the a2x
> > > > converter. Whenever I try to passthrough the tag, it either breaks
> > > > the list or puts the pass through into the <simpara> of the bullet
> > > > point text. I suppose there may be a way to customize a2x to handle
> > > > this and insert the keep-together tag in each listitem, or in
> > > > listitems containing images, although I'm not sure exactly how to
> > > > accomplish this.
>
> > > > For example, this XML keeps the bullet point with the following image
> > > > in the FOP PDF output:
> > > > ============================
> > > > <listitem>
> > > > <?dbfo keep-together="always"?>
> > > > <simpara>
> > > > Some Text
> > > > </simpara>
> > > > <informalfigure>
> > > > . . .
> > > > ============================
>
> > > > Getting closer!
>
> > > > Thanks,
> > > > -Tim
>
> > > > On Jan 4, 6:00 am, Henrik <[email protected]> wrote:
>
> > > > > The unbreakable applies only to the object itself.
>
> > > > > Are you using FOP or DBLatex?
>
> > > > > If you are using FOP, you would need the dbfo-need processing
> > > > > instruction applied to the paragraph preceding the image. This
> > > > > processing instruction would inform FOP that more space is needed
> > > > > after the paragraph but on the same page. FOP does not support this
> > > > > processing instruction yet, so you are out of luck here.
>
> > > > > I cannot comment on DBLatex.
>
> > > > > On Dec 23 2010, 5:33 am, Tim Mertens <[email protected]> wrote:
>
> > > > > > Hello,
>
> > > > > > I am fairly new to asciidoc and was wondering if someone can help me
> > > > > > understand how to apply the 'unbreakable' attribute to an image
> > > > > > and/or
> > > > > > text block so that the image stays with the line above it across
> > > > > > page
> > > > > > breaks.
>
> > > > > > In almost all cases, I want the line above the image to stay with
> > > > > > the
> > > > > > image if the image forces a page break. Based on the asciidoc
> > > > > > manual,
> > > > > > it seems that the 'unbreakable' attribute should accomplish this,
> > > > > > but
> > > > > > I must be applying it incorrectly or it does not work as I imagined.
> > > > > > After trying to apply the 'unbreakable' attribute, the PDF output
> > > > > > still has the line before the image on one page and the image itself
> > > > > > on the next page.
>
> > > > > > I use a2x to export the asciidoc text file directly to PDF. I am
> > > > > > using asciidoc 8.6.3 on Mac OS X 10.6.5. (I have also used it on
> > > > > > Ubuntu 10.04).
>
> > > > > > For example, below is a simple list with an image and other elements
> > > > > > in it. (The '=' lines are not in the actual document)
>
> > > > > > ===================================
>
> > > > > > . List item one
> > > > > > +
> > > > > > image::myimageone.jpg[]
>
> > > > > > . List item two
>
> > > > > > . List item three
> > > > > > +
> > > > > > anchor:Item-three-diagram001[]
> > > > > > +
> > > > > > image::anotherimage.jpg[]
> > > > > > +
> > > > > > NOTE: This is a note which will appear underneath the image.
>
> > > > > > ===================================
>
> > > > > > And here is the same list with some of my attempts to add the
> > > > > > unbreakable attrib, which are probably completely incorrect:
>
> > > > > > ===================================
>
> > > > > > [options="unbreakable"]
> > > > > > . List item one
> > > > > > +
> > > > > > image::imageone.jpg[]
>
> > > > > > . List item two
> > > > > > +
> > > > > > image::imagetwo.jpg[options="unbreakable"]
>
> > > > > > . List item three
> > > > > > +
> > > > > > anchor:Item-three-diagram001[]
> > > > > > +
> > > > > > image::anotherimage.jpg[unbreakable]
> > > > > > +
> > > > > > NOTE: This is a note which will appear underneath the image.
>
> > > > > > ===================================
>
> > > > > > Any help would be greatly appreciated! I have already spent quite a
> > > > > > bit of time searching and have been unable to find any useful (to
> > > > > > someone new to asciidoc) explanation of the unbreakable attribute
> > > > > > apart from the asciidoc documentation.
>
> > > > > > Thanks,
> > > > > > -Tim
>
>
--
You received this message because you are subscribed to the Google Groups
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/asciidoc?hl=en.