OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: Equation number on same line as equation contents

Stephen Langer <stephen.langer@nist.gov> writes:

> [...]
> On a related topic, is it possible to put the title of an equation on  
> the same line, but to the right?  I'd really like to have an just  
> automatically generated equation number, like this:
>     x^2 + y^2 = z^2               (1.1)

There are two separate requirements that need to be satisfied to
enable what you describe.

  1. Output the equation title in the form "(1.1") instead of in
     the default "Equation 1.1. Foo" form.

  2. Cause the equation title to be rendered on the same line as
     equation contents.

Regarding requirement #1: Changing the output for the equation
title requires you to add some things to your stylesheet
customization layer(s). The process for doing that is described in
Bob Stayton's book, in the "Customizing generated text" section -


For HTML output, to get the output you describe, you need to have
a customization layer that, at a minimum, contains the following.

  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl"/>
    <xsl:param name="local.l10n.xml" select="document('')"/>
    <l:i18n xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0";>
      <l:l10n language="en">
        <l:context name="title">
          <l:template name="equation" text="(%n)"/>

For FO output, you'd need to do something similar to that.

Regarding requirement #2: For HTML output, the optimal way to
control the placement of the title is to use CSS.

It is possible to construct a CSS stylesheet that uses the "float"
property to place the title on the same line as the contents of
the equation. But for output of the existing XSL stylesheets,
you'd need to have a CSS rule for each element that's allowed as a
direct child of the equation -- because the existing stylesheets
do no output a wrapper around the equation contents.

I think it would be better to have the stylesheets output a
wrapper around the equation contents. So I checked in a change
today to cause that output. You can test it using the latest


What I did was to add change that causes a the stylesheets to
output a <div class="{$class}-contents"> wrapper around of
contents of all formal objects, including Equation. I also, added
a change that causes an optional <br class="{class}-break"/>
linebreak to be output after all formal objects.

Note: Because these changes places an additional DIV between the
DIV wrapper for the equation and the equation contents, they may
break some existing CSS stylesheets that have been created with
the assumption that there would never be an intervening DIV there.

The following is an example of what Equation output looks like as
a result of the changes described above.

  <div class="equation">
    <a name="three" id="three"></a>

    <p class="title"><b>(1.3)</b></p>

    <div class="equation-contents">
      <span class="mathphrase">1+1=3</span>
  </div><br class="equation-break">

So you can now cause the equation title to be rendered to the
right of the equation contents by using a stylesheet fragment like
the following.

  .equation {
    margin-top: 20px;
    margin-bottom: 20px;
  .equation-contents {
    float: left;

  .equation .title {
    margin-top: 0;
    float: right;
    margin-right: 200px;

  .equation .title b {
    font-weight: normal;

  .equation-break {
    clear: both;

Note that the purpose of the ".equation-break" class is to provide
a way to clear off the floats. In my testing, it does not seem to
work to have the "clear: both" property specified on the rule for
the "equation" class.

If you want to instead have the equation title rendered to the left
of the equation contents, you can do something like this:

  .equation {
    margin-top: 20px;
    width: 300px;
    margin-bottom: 20px;
  .equation-contents {
    float: right;

  .equation .title {
    margin-top: 0;
    float: left;
    margin-right: 200px;

  .equation .title b {
    font-weight: normal;

  .equation-break {
    clear: both;

In each case, the equation title is top-aligned with the equation
contents. I have not been able to figure out a way to have it
middle-aligned with the equation contents.

Anyway, please give it a try and let me know if it works for you.

I have not looked at the FO stylesheets yet to figure out how
similar output could be implemented in those. I suspect it will
require quite a bit more work than the HTML case.


Michael Smith


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]