Popisky obrazku a tabulek...

Jiri Tyr jiri.tyr na cern.ch
Čtvrtek Květen 3 15:01:53 CEST 2007


Dobry den,

mozna nekomu usetrim cas, kdyz vlozim i nejake sve zkusenosti s upravou 
stylu. Resil jsem, jak udelat centrovani obrazku a tabulek spolecne s 
jejich popiskama. Pozadavek byl mit popisek kurzivou. Priklad:

,- okraj stranky
v
|     oooooooooooooooooooooo    |
|     o                    o    |
|     o                    o    |
|     o        IMG         o    |
|     o                    o    |
|     o                    o    |
|     oooooooooooooooooooooo    |
|        Popisek obrazku        |

Pouzil jsem pro to tuto customizaci:

<xsl:attribute-set name="formal.object.properties">
  <xsl:attribute name="text-align">center</xsl:attribute>
  <xsl:attribute name="font-style">italic</xsl:attribute>
  <xsl:attribute name="font-weight">normal</xsl:attribute>
</xsl:attribute-set>

<xsl:template name="formal.object.heading">
  <xsl:param name="object" select="."/>
  <xsl:param name="placement" select="'before'"/>
  <xsl:choose>
    <xsl:when test="name(.) = 'figure' or name(.) = 'table'">
      <fo:block xsl:use-attribute-sets="my.formal.title.properties">
        <xsl:choose>
          <xsl:when test="$placement = 'before'">
            <xsl:attribute
                   
name="keep-with-next.within-column">always</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute
                   
name="keep-with-previous.within-column">always</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates select="$object" mode="object.title.markup">
          <xsl:with-param name="allow-anchors" select="1"/>
        </xsl:apply-templates>
      </fo:block>
    </xsl:when>
    <xsl:otherwise>
      <fo:block xsl:use-attribute-sets="formal.title.properties">
        <xsl:choose>
          <xsl:when test="$placement = 'before'">
            <xsl:attribute
                   
name="keep-with-next.within-column">always</xsl:attribute>
          </xsl:when>
          <xsl:otherwise>
            <xsl:attribute
                   
name="keep-with-previous.within-column">always</xsl:attribute>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates select="$object" mode="object.title.markup">
          <xsl:with-param name="allow-anchors" select="1"/>
        </xsl:apply-templates>
      </fo:block>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:attribute-set name="my.formal.title.properties" 
use-attribute-sets="normal.para.s
  <xsl:attribute name="text-align">center</xsl:attribute>
  <xsl:attribute name="font-style">italic</xsl:attribute>
  <xsl:attribute name="font-weight">normal</xsl:attribute>
  <xsl:attribute name="font-size">
    <xsl:value-of select="$body.font.master"></xsl:value-of>
    <xsl:text>pt</xsl:text>
  </xsl:attribute>
</xsl:attribute-set>

Upravou sady parametru formal.title.properties toho nelze dosahnout, 
protoze to zmeni formatovani i jinych titulky nez jen u tabulek a 
obrazku (napr. titulek abstraktu).

Pokud by nekdo vedel, jak parametrizovat:

<fo:block xsl:use-attribute-sets="my.formal.title.properties">

necim jako:

<xsl:variable name="myset">
  <xsl:choose>
    <xsl:when test="name(.) = 'figure' or name(.) = 'table'">
      <xsl:text>my.formal.title.properties</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>formal.title.properties</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>
<fo:block xsl:use-attribute-sets="{$myset}">
...

tak bych byl kdyby to sem napsal.

S pozdravem,
Jiri Tyr

PS: Nove prispevky do teto konference se uz nezobrazuji na webu 
http://www.linux.cz/lists/archive/docbook? Byla by to skoda, protoze se 
to zda byt jako dobry zdroj informaci pro ceske uzivatele DocBooku.



Další informace o konferenci Docbook