Equation Overrides
If you have 2009.3 or later follow this link: Article revised for 2009.3 release and subsequent releases
Version |
Date |
Changes |
1.0 |
2009-11-9 |
Initial version. |
Description
This project presents the customizations that were developed in conjunction with Jesse Wiles for improved equation handling in ePublisher 2009. Note that this was developed using FrameMaker as the source format.
Contents
- Equation Overrides
Problems with Equation Rendering
The problems addressed in this project are illustrated in the graphic below. The equation numbers are not aligned correctly at the right hand side of the equations, the resolution at which equations are rendered can not be controlled, and the inline equations appear to float some way above the baseline. These have been addressed with customizations.
Customization 1: Labeling an Anchored Frame as a Graphic
ePublisher rasterizes equations to postscript format in the initial stages of the conversion pipeline. The resulting graphics are referenced by anchored frames. By default, ePublisher does not distinguish between an ordinary anchored frame (that could contain a user-referenced image) and an anchored frame containing an equation. To get round this problem, a change was made in the ww-mifxml-frames.xsl file that adds an additional "is-equation" attribute to the markup for anchored frames in the generated WIF file.
Note: For ePublisher 2009.2 and earlier, the ww-mifxml-frames.xsl file must be modified within the installation structure itself. Making changes here could have a potentially adverse effect on the operation of ePublisher... However, I've tried it and it seems to work.
Finding the ww-mifxml-frames.xsl file
This has to be modified for each of the three WebWorks Packages, and can be found as follows (for a default installation on a 32-bit Windows machine):-
Package |
Path to file |
ePublisher Pro |
C:\Program Files\WebWorks\ePublisher Pro\Adapters\Support\FrameMaker\ww-mifxml-frames.xsl |
ePublisher Express |
C:\Program Files\WebWorks\ePublisher Express\Adapters\Support\FrameMaker\ww-mifxml-frames.xsl |
ePublisher Automap |
C:\Program Files\WebWorks\ePublisher AutoMap\Adapters\Support\FrameMaker\ww-mifxml-frames.xsl |
On a 64-bit Windows machine, the default path would begin with: C:\Program Files (x86).
Making the change
The change required is demonstrated by presenting the relevant section of the file before and after the change. This should help locate the point at which the new code is to be added.
Before
<xsl:template name="AFrame"> <xsl:param name="ParamFrameID" /> <xsl:param name="ParamTopLevel" /> <xsl:variable name="ThisFrame" select="key('KFrames', $ParamFrameID)" /> <xsl:variable name="LocalRefFile" select="$ThisFrame/wwmif:ImportObject/wwmif:ImportObFileDI/@value" /> <xsl:variable name="LocalRefType" select="$ThisFrame/wwmif:ImportObject/wwmif:ImportObUpdater/@value" /> <wwdoc:Frame id="{$ThisFrame/wwmif:Unique/@value}"> <!-- Handle Graphic style -->
After
<xsl:template name="AFrame"> <xsl:param name="ParamFrameID" /> <xsl:param name="ParamTopLevel" /> <xsl:variable name="ThisFrame" select="key('KFrames', $ParamFrameID)" /> <xsl:variable name="LocalRefFile" select="$ThisFrame/wwmif:ImportObject/wwmif:ImportObFileDI/@value" /> <xsl:variable name="LocalRefType" select="$ThisFrame/wwmif:ImportObject/wwmif:ImportObUpdater/@value" /> <xsl:variable name="VarIsEquation"> <xsl:variable name="VarMathCount" select="count($ThisFrame/wwmif:Math[1])"/> <xsl:choose> <xsl:when test="$VarMathCount = 1"> <xsl:text>true</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>false</xsl:text> </xsl:otherwise> </xsl:choose> </xsl:variable> <wwdoc:Frame id="{$ThisFrame/wwmif:Unique/@value}" is-equation="{$VarIsEquation}"> <!-- Handle Graphic style -->
Note the change in the second line from the end: this adds the is-equation attribute to the corresponding XML output.
Observing the change
The change will be seen in the generated WIF files for each Framemaker document containing equations. The XSL code is checking for the presence of a <math> element in the MIF file produced by FrameMaker. If this element is found, the is-equation attribute will be set to true. Otherwise the attribute will be false.
Customization 2: Modifying the nameinfo.xsl file
The goal is to be able to apply a default graphic style to every equation. Now that frames containing equations can be detected, it is possible to modify the nameinfo.xsl template so that equations frames detailed in the splits_uniquenames.xml file (created for each project in the users data directory tree) will have the correct stylename associated with them.
The modification required here is shown in the nameinfo_modified.xsl file attached (click here). Search for the comment <!-- Begin Customization --> to see the change, and continue to the point <!-- End Customization -->. This customization must be inserted at the correct point in the file. If the attached file is to be used directly, rename it to nameinfo.xsl.
Placement of the file
To override all targets that use the WebWorks Help 5.0 format, create a format override directory for your ePublisher Pro project (select View > Format Override Directory in ePublisher Pro). This assumes you have opened or created a project using the WebWorks Help 5.0 format.
Within the WebWorks Help 5.0 directory that will be shown, create the following directory structure:
Shared\common\splits\
Copy the modified nameinfo.xsl file to this folder. The complete path to the file will therefore be something like:
[PROJECTDIR]\Formats\WebWorks Help 5.0\Shared\common\splits\nameinfo.xsl
The effect of this modification will be seen in the splits_uniquenames.xml for your project. This file can be found by selecting View > Data Directory from the ePublisher Pro menubar. Navigate one level down from the folder(s) contained within this location, and you should see the splits_uniquename.xml file. Any frames containing equations will have the attribute stylename="EquationGraphic".
Create the EquationGraphic graphic style in ePublisher Pro
In your ePublisher Pro project, create a new Graphic Style called "EquationGraphic", as shown below.
By virtue of the modifications made previously, the settings for this style will be applied to all equations. In the example above, the Render DPI has been increased to 120, and the output type was change to GIF instead of JPG.
Customization 3: Placing the Equation Number on the Right-Hand Side
The solution here is to create a two-cell table that will have the equation graphic in the first cell, and the equation number in the second cell. The XSL code for this is placed in a content.xsl file, located within a format specific override directory.
Using the same approach as before, create the following override directory for the WebWorks Help 5.0 format directory:
Transforms
The content.xsl file attached (click here) should be placed in this directory. The complete path to the file will therefore be:
[PROJECTDIR]\Formats\WebWorks Help 5.0\Transforms\content.xsl
It should be noted that this particular section of code depends on the source Framemaker document having a Paragraph Style called "Equation" that is applied to all anchored frames containing equations. If a different Paragraph Style is used, the appropriate name should replace Equation in the match statement of the XSL instruction in content.xsl. This line is shown below.
<xsl:template match="wwdoc:Paragraph[@stylename = 'Equation']" mode="wwmode:content">
Customization 4: Placing in-line equations on the line
This customization is achieved by creating an Additional CSS class for the EquationGraphic graphic style referred to previously. Inline equations will receive the EquationGraphic graphic style.
Create a custom css file
To do this, select View > User Files from the ePublisher Pro menu bar. Within the [PROJECTDIR]\Files directory that appears, create a css directory. Copy the custom.css file attached click here to this directory. The complete path to the custom.css file will be:
[PROJECTDIR]\Files\css\custom.css
Add the CSS class to the EquationGraphic graphic style
This is illustrated in the graphic below:-
Final Output
If everything works as intended, the final output should contain improved rendering and positioning of equations:-