5 Advanced Features

5.1 Lists

eCromedos knows three types of lists: ordered lists, unordered lists (a.k.a. bullet lists) and definition lists.

Unordered lists are set with the ul tag and ordered lists with ol. List items are enclosed by the li tag. In addition, these two types of lists may be nested arbitrarily, up to four levels deep. Take a look at the following example:

<ol>
    <li>First item</li>
    <li>Second item</li>
    <ul>
        <li>Subitem</li>
        <li>Subitem</li>
    </ul>
    <li>Third item</li>
    <ol>
        <li>Subitem A</li>
        <li>Subitem B</li>
        <li>Subitem C</li>
    </ol>
</ol>

Definition lists are set with the dl tag. Items in definition lists have two components: a term to be defined and its actual definition. Take a look at this example:

<dl>
    <dt>eCromedos</dt>
        <dd>
            A document publishing system that allows generating
            different target formats from one document source.
        </dd>
    <dt>ECML</dt>
        <dd>
            The eCromedos markup language is an XML based markup
            language for describing the logical structure of
            standard text documents, such as books.
        </dd>
</dl>

The most common use of definition lists is the creation of glossaries (see section 4.3.4).

5.2 Figures

Figures are incorporated into a document via the figure element. You can give figures a caption and a label. Note that you may label a figure if and only if you also give it a caption. You may refer to a figure's label with the ref and pageref elements (see section 4.7). Here is an example:

<figure align="center">
    <caption>The Beach</caption>
    <label name="fig:thebeach"/>
    <img src="thebeach.jpg" print-width="100%" screen-width="400px"/>
</figure>
<p>
    Figure <ref name="fig:thebeach"/> shows a beautiful sunset at
    the Galveston beach.
</p>

With the src element you specify the location of the image on your harddisk. If the image's file format is not suitable for use with a particular output format, the document processor will automatically convert it. For instance, when generating LATEX output, eCromedos automatically converts raster images to encapsulated postscript.

Note You should supply images in a resolution high enough for proper representation in all target formats.

The attributes print-width and screen-width determine the width of the image in printed output and in HTML output, respectively. For printed output this can be a value in points (pt) or centimeters (cm) or a relative width in percent of the text body's width. The width for HTML output is specified in pixels (px).

The figure's horizontal alignment can be controlled by setting the align attribute to left, center or right.

5.3 Tables

Generating good-looking tables with eCromedos is a little bit complicated. Therefore, we will start right out with an example:

<table print-width="100%" screen-width="600px" align="center">
    <caption>An Exemplary Table</caption>
    <label name="tab:example"/>
    <colgroup>
        <col width="40%"/>
        <col width="30%"/>
        <col width="30%"/>
    </colgroup>
    <tr>
        <td>1st row, 1st column</td>
        <td>1st row, 2nd column</td>
        <td>1st row, 3rd column</td>
    </tr>
    <tr>
        <td colspan="2">2nd row, cell over 2 columns</td>
        <td>2nd row, third column</td>
    </tr>
</table>

As you can see, tables may be given a caption and a label. A table's label can be referenced with the ref and pageref elements (s. section 4.7).

Before writing down the table's contents, you must first specify its column layout. This is done with the colgroup element. For each column in your table, you must specify its relative width with respect to the overall table width.

The overall width is specified via the table attributes print-width and screen-width. The table's width in printed documents can be a value in centimeters (cm) or points (pt) or a percentage of the overall width of the text body. The width in on-screen documents may be specified in pixels (px) or in percent of the window width.

The horizontal alignment can be controlled by setting the align attribute to left, center or right.

After the layout specification follows the actual content. In our example, you see two table rows, set with the tr tag. The first row contains three cells, set with the td tag, whereas the second row contains only two cells. This is because the first cell in the second row spans two columns, as specified by its colspan attribute.

5.3.1 Activating the Grid Rules

The table above does not have a grid. To activate the grid rules of a table, you have to use the frame attribute. Take a look at this example:

<table print-width="100%" screen-width="600px" align="center"
    rulecolor="#000000" print-rulewidth="2pt" screen-rulewidth="2px"
    frame="top,bottom,rowsep">
    <caption>An Exemplary Table</caption>
    <label name="tab:example"/>
    <colgroup>
        <col width="40%"/>
        <col width="30%"/>
        <col width="30%"/>
    </colgroup>
    <tr frame="colsep">
        <td>1st row, 1st column</td>
        <td>1st row, 2nd column</td>
        <td>1st row, 3rd column</td>
    </tr>
    <tr>
        <td colspan="2">2nd row, cell over 2 columns</td>
        <td>2nd row, third column</td>
    </tr>
</table>

The frame attribute contains a comma separated list of grid element names: left, right, top and bottom activate the outer table borders; colsep and rowsep activate column and row separators. Note that column and row separators can also be activated for individual rows or cells.

The thickness of the grid rules may be specified with the print-rulewidth and the screen-rulewidth attributes. The color of the rules can be controlled via the rulecolor attribute. The color value must be an HTML style RGB triplet in hexadecimal notation.

5.3.2 Coloring Table Cells

You may color individual rows or cells by setting a color attribute on the corresponding tag. For example, to give the first cell in the first row from the previous example a gray background, you could write:

<tr frame="colsep">
    <td color="#dddddd">1st row, 1st column</td>
    <td>1st row, 2nd column</td>
    <td>1st row, 3rd column</td>
</tr>

Note Colored cells may overlap with dark grid rules when viewing PostScript or PDF documents on screen. Therefore, you should avoid using colored cells and grid rules together or instead use white rules when working with colored tables.

5.3.3 Text Alignment in Table Cells

The vertical alignment of text in tables can be controlled only for entire rows, but not for individual cells. This is due to LATEX's limited capabilities in this respect. To determine the vertical alignment of text in a table row, set the valign attribute on the corresponding row element to one of the specifiers top, middle or bottom.

Horizontal text alignment must be controlled for each cell individually, by setting the cell's align attribute to left, center or right. By default, text is set left-aligned.

5.4 Floating Objects

By default, figures and tables are placed exactly where specified in the source document. Imagine though, you are generating printed output and so far the page has been filled by two thirds with text. Technically, the next thing to be inserted would be a picture, but it occupies more space than is remaining and thus has to be moved to the next page, leaving the page before empty by one third. This is visually unpleasant and in addition bloats your document unnecessarily.

As a soluting, you can turn figures or tables into floating objects by setting the float attribute on the main element to “yes”. Making an object float means basically that you give LATEX permission to move it to a different location in the text in order to warrant optimal text flow across pages.

5.5 Program Listings

You can use the verbatim element when you need to represent scripts or shell code. Text inside the verbatim tag will be printed in typewriter letters and whitespace will be printed just as it appears in your editor.

For program code, you should use the listing element which, for now, has a single child, namely the code element. You can have your code syntactically highlighted by specifying the name of the programming language in the syntax attribute. Take this for an example:

<listing>
    <code syntax="c" colorscheme="ide-eclipse"
        strip="yes" startline="1" linestep="100">
    
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int main(void) {

    printf("Hello World!\n");
    return 0;
}

    </code>
</listing>

The document processor can highlight a wide range of programming languages. For a complete list, take a look into the folder lib/highlight/langDefs below the installation folder.

With the colorscheme attribute you can choose between available coloring schemes. For a complete list, take a look into the folder lib/highlight/themes below the installation folder.

If you specify a startline, the syntax highlighter will number each line in your code. The linestep attribute specifies the increment from one line to the next.

Setting the strip attribute to “yes” will result in whitespace being stripped from the beginning and end of your listing.

5.6 Mathematic Formulas

Mathematic formulas are entered in TEX notation. Explaining TEX is beyond the scope of this document. For more information, please refer to appropriate literature, such as [4].

5.6.1 Inline Math

In order to set mathematic expressions inline, i.e. in the running paragraph, you use the m tag. Take a look at this example:

<p>
    The main proposition of Einstein's
    theory of relativity is <m>e = mc^2</m>.
</p>

5.6.2 Block Formulas

Formulas can also be set as block elements. To do so, you enclose the math element inside an equation element. To have your equation automatically numbered, set the number attribute to “yes”. The following listing shows, how to set the eqation from above as a block element:

<equation number="yes">
    <m>e = mc^2</m>
</equation>

Support for math is not yet very sophisticated and the mechanisms presented above will not allow for more than the occasional mathematical one-liner. Future versions of eCromedos will provide better control over alignment and grouping of formulas.