First Column Format

Oct 17, 2010 at 9:26 AM

Hi Yves

Fantastic project. After a failed attempt at hacking an existing XSL style sheet I found your solution here. 

I'm now using a modified version of the ACS Citation Sequene (Italic) template - and it's working great.

I've read your FAQ as well - and understand that most of the numerical bibliographies use a two column table - and that the first column needs to be adjusted if text for the RefOrder is wrapping because the column is not wide enough.

If I've understood your approach - there is a 'format-bibliography-table-column' xsl template that is being used to create each column (the same template with a single TD)

Would there be a way to test for the column Id? And if it is the first column - set a percentage width so that the table does not have to be adjusted after each bibliography update?

Thoughts?

Coordinator
Oct 17, 2010 at 9:57 AM

The problem is you can't predict what the end-user's font size will be. What might work for a font size 8, might fail for font size 11. And you also don't know how many references there will be. Less than 10, between 10 and 99, and more than 100 all require different widths for your first column.

Currently, the following line is used to define a table cell:

    <td align="{$params/bibliography/source[@type = $type]/column[@id = $columnId]/halign}" valign="{$params/bibliography/source[@type = $type]/column[@id = $columnId]/valign}">

You could rewrite that slighly to take into account a width element. For example just above, you could define a variable colWidth which takes it input depending on column id and then add

    style="width: {$columnWidth}"

into the td definition.



Alternatively, and probably less messy, you could use colspan elements. Right now you have a line

    <table width="100%">

Directly under it, you could probably put something like:

  <colgroup span="1"style="width: 5%"></colgroup>
  <colgroup span="1"></colgroup>

In theory, a simple nowrap should prevent the need of any of the above workarounds, but unfortunately, Word seems to ignore any such HTML 'hints' when importing the table.

Oct 17, 2010 at 9:59 AM

For example... inside the format-bibliography-table-column template - just before the TD I have...

 <xsl:variable name="width">    
<xsl:choose>
                  <xsl:when test="$columnId = 1">
                    <xsl:value-of select="20"></xsl:value-of>
                 </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="80"></xsl:value-of>
                </xsl:otherwise>
        </xsl:choose>
</xsl:variable>

 

And then...

<td width="{$width}%" align= etc...

Thoughts?

I've got the template working ok - but not sure if the width is being set yet.

Oct 17, 2010 at 10:12 AM

 

Well this is actually working now - but only in Web Layout view of Word :-(

I'm using <td style="width: {$width}%"  for the width setting.

Do you know if there is there an equivalent attribute that will set the width of a column in Print Layout?

May 29, 2011 at 3:37 PM

Hey,

i want define the column width for the first column but i have the same problem like "abouch", it only works in the web layout and not in print layout!

Has someone a solution for this problem?

Thx

Feb 23, 2012 at 3:47 PM
Edited Feb 23, 2012 at 3:48 PM

Hi,

I was running into the same problem and couldn't figure out how to generate a table of the correct width using a "width" tag.  However, I found out if you add a non-breaking space after entries with a RefOrder greater than 9 it automagically resizes the column.  This is a hack but it seems to do the trick.  I haven't tested this with RefOrder greater than 99 (i.e. 3 digits) but it seems to do the trick for 2 digit numbers.

Here is the code change:

<!-- Convert the formatted source to html. -->
<xsl:choose>
  <xsl:when test="msxsl:node-set($data)/general/citation_as_link = 'yes' and $columnId = 1">
    <a name="{$source/b:Tag}">
      <xsl:value-of select="$columnX" disable-output-escaping="yes"/>
      <xsl:if test="number($source/b:RefOrder) > 9">
      &#xa0;
      </xsl:if>
    </a>
  </xsl:when>
  <xsl:otherwise>
    <xsl:value-of select="$columnX" disable-output-escaping="yes"/>
  </xsl:otherwise>
</xsl:choose>

The new code is:

<xsl:if test="number($source/b:RefOrder) > 9">
              &#xa0;
</xsl:if>
&#xa0; is the unicode for non-breaking space.
Hope this helps.
Coordinator
Feb 23, 2012 at 8:59 PM

Interesting. While whitespace: nowrap doesn't work, a non-breaking space does? Shows that there clearly is something wrong with Word's interpretation of HTML.

Thanks for sharing.