<!ELEMENT note (#PCDATA | title | %inlinetags; | %blocktags;)*>
<!ATTLIST note type CDATA #IMPLIED>
-<!ELEMENT table (tr)+>
+<!ELEMENT table (columnspec | tr)+>
<!ATTLIST table summary CDATA #IMPLIED
width CDATA #IMPLIED
bgcolor CDATA #IMPLIED
border CDATA #IMPLIED
style CDATA #IMPLIED>
+<!ELEMENT columnspec (column)+>
+
+<!ELEMENT column EMPTY>
+<!ATTLIST column width CDATA #IMPLIED>
+
<!ELEMENT tr (th | td)+>
<!ATTLIST tr valign CDATA #IMPLIED >
since you can just take the existing LaTeX as an example, and combine
it with the xslt stuff under style/xsl/.]
-- Fix tables
-
- Perhaps we need to add some xml hints about the size of different
- columns in the source files.
-
- Here is a proposal:
-
- xml:
- <table>
- <columnspec><column width=".2"/><column width=".2"/><column width=".6"/>
- </columnspec>
- <tr><td>1</td><td>2</td><td>3</td></tr>
- </table>
-
- latex:
- \begin{tabular}{lll} % number of "l"s matches the number of <column>s.
- \begin{minipage}{.2\linewidth}
- 1
- \end{minipage} &
- \begin{minipage}{.2\linewidth}
- 2
- \end{minipage} &
- \begin{minipage}{.6\linewidth}
- 3
- \end{minipage} \\ % And continue in the same way if there are more rows
- \end{tabular}
-
- This should be enough to get an xsl expert started.
-
- Images
A quick search makes me believe that pdftex will not handle gifs.
</xsl:template>
<xsl:template match="table">
-<xsl:text>\begin{tabular}{ll}</xsl:text>
-<xsl:for-each select="tr">
- <xsl:for-each select="td">
- <xsl:text>\begin{minipage}{.5\linewidth}</xsl:text>
- <xsl:apply-templates/>
- <xsl:text>\end{minipage}</xsl:text>
- <xsl:if test="not(last())">
- <xsl:text> & </xsl:text>
- </xsl:if>
- </xsl:for-each>
- <xsl:text>\\
-</xsl:text>
+<xsl:text>\begin{tabular}{</xsl:text>
+<xsl:for-each select="columnspec/column">
+ <xsl:text>l</xsl:text>
</xsl:for-each>
+<xsl:text>}</xsl:text>
+<xsl:apply-templates select="tr"/>
<xsl:text>\end{tabular}
</xsl:text>
</xsl:template>
+<xsl:template match="tr">
+ <xsl:apply-templates select="td"/>
+ <xsl:text>\\
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="td">
+ <xsl:variable name="pos" select="position()"/>
+ <xsl:text>\begin{minipage}{</xsl:text>
+ <xsl:value-of select="../../columnspec/column[$pos]/@width"/>
+ <xsl:text>\linewidth}</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>\end{minipage}</xsl:text>
+ <xsl:if test="not(position()=last())">
+ <xsl:text> & </xsl:text>
+ </xsl:if>
+</xsl:template>
+
<!--
This is a horrible hack, but it seems to mostly work. It does a
few things:
</xsl:template>
<!-- /helper.uri.fix -->
+
+<!-- ==================================================================== -->
+<!-- Ignore table hints used for latex -->
+<!-- ==================================================================== -->
+<xsl:template match="columnspec">
+</xsl:template>
+
+<xsl:template match="column">
+</xsl:template>
+
</xsl:stylesheet>