Authoring Book Chapters

When authoring a book, you will be provided with an account into a CVS repository. Since all the source files for your book are text files, CVS provides us with a ready-made solution that makes it possible for all the people involved in your project to collaborate freely.

File Structure

Each chapter of the book should be stored in its own directory inside the root of the repository. The directory should be named according to the chapter title, so that it can be easily told apart from the other chapters in the book. For example, if your chapter's title is “Extending Web Services,” the directory could be called extending_web_services. Note that, at this stage, we do not assign a chapter number in any form—this is done automatically by our software when it generates the final PDF of the book, depending on how we order each chapters in the layout phase.

The chapter's source file should be stored inside the directory and given the name chapter.src.txt. This will make it readable to any text editor on your end, while on our end the system will recognize it and compile it.

The chapter's directory can also contain an optional figures sub-directory, which can be used to store figures for the chapter.

You should always use a UTF-8-compliant text editor to create your text files. This will ensure that all special characters are encoded properly for our system to read.

The Title

The title of your chapter should go at the very beginning of the source file. For example, if the chapter's title is “Extending Web Services,” its source file should start as follows:

  1. =t=Connecting to a MySQL Database=t=
  2.  
  3. Normal text starts here.
As you can see, Ceres uses special tags to indicate the beginning and end of each element. For example, the =t= tag is used to indicate the beginning and end of the title.

Note that you cannot have any line breaks inside the title. Also, the title should be followed by an empty line.

The Body

Once you have completed the masthead, you can move on to the body of the chapter. Here, there are only a handful of rules to keep in mind.

First of all, for the most part you can type your text directly as if you were using a word processor; if you need to use characters outside the standard ASCII set, such as accented letters, em-dashes, and so forth, you can type them directly without having to worry about special encoding. On those operating systems that do not support extended character sets natively, most editors usually provide key combinations that make it possible to enter them anyway.

In any case, you need to ensure that, if you use non-ASCII character, your text editor is capable of saving files in UTF-8 format. This is very important, as our system may be unable to properly display your text otherwise.

Other than this particular precaution, there is very little that you need to worry about; paragraphs in your text are separated by two newline characters (in other words, press Enter twice and you've started a new paragraph), and there is no need to indent the first line of a new paragraph.

Formatting Text

Our system supports three types of inline text format:

These three inline formats can, of course, be combined. For example: //**bold italic**// becomes bold italic. You can also escape the tag sequences by prefixing them with a backslash. For example, \ //not italic is printed as “//not italic”.

Headings

Headings (like the one above this line) are used to break up your chapter into smaller units that the reader can use as reference points to navigate the text. For book chapters, Ceres recognizes three levels of headings, identified by the =n= tag:

  1. This is the last paragraph of the previous section.
  2.  
  3. =1=This is a Level-1 Heading=1=
  4.  
  5. This is the first paragraph of the next section.
  6.  
  7. =2=This is a Level-2 Heading=2=
  8.  
  9. More text goes here
  10.  
  11. =3=This is a Level-3 Heading=3=
Note that the text of the heading must be all in one line (no line breaks!) and that it must be isolated from the previous and next paragraphs by an empty line.

Headings are designed to be nested—you cannot jump from a level-1 heading directly to a level-3 heading, or the system will generate a compilation error.

Lists

Ceres only supports unordered lists. A list block is identified by a line that starts with a dash, followed by a space. For example:

  1. This is normal text.
  2.  
  3. - This is the first element of a list
  4. - This is the second
  5.  
  6. - This is the beginning of a new list
  7. - And this is its second element
The source code above will be rendered as follows:

This is normal text.

Note that a list must be preceded and followed by an empty line (which tells the parser to stop looking for list elements).

Floating Elements

“Floating elements” are elements outside the normal flow of your chapter's body. These include code listings, tables, figures and callouts.

In our design template, floating elements are actually anchored to the paragraph that precedes them. This makes the term “floating elements” a bit of a misnomer, since listings, tables and figures are rendered inline with the text. You should keep this in mind when writing your chapter, so that you can position these elements accordingly. For example, if you want to introduce a listing, you can reference it as “the listing below,” and then immediately follow that with the listing itself.

Code Listings

Code listings are encapsulated by a <code> tag, which must be on a line of its own:

  1. <code>
  2. $x = 10;
  3. $y = 20;
  4. echo $x * $y;
  5. </code>
The source code above becomes:

  1. $x = 10;
  2. $y = 20;
  3. echo $x * $y;
Note that you should not indent the first level of your code, as the system already provides the indentation for you. You should, however, indent any subsequent levels (using either tabs or spaces). For example:

  1. <code php>
  2. $x = 10;
  3. $y = 20;
  4. if ($y > $x) {
  5.   echo $x * $y;
  6. }
  7. </code>
This will result in the following:

  1. $x = 10;
  2. $y = 20;
  3. if ($y > $x) {
  4.   echo $x * $y;
  5. }
As you noticed in this last example, Ceres supports syntax highlighting for PHP code. In fact, it supports highlighting a large number of different languages, which you can specify inside the <code> tag. The list is too long to include here, but chances are that any language you may need to highlight is actually supported by Ceres—including SQL, XML and HTML.

IMPORTANT: code listings should be wrapped at 70 characters.

Tables

Tables can be inserted directly in the body of your chapters using a syntax that is very similar to HTML (but much simpler and stricter). Here's an example:

  1. <table center>
  2. <tr>
  3.     <th>Position Name</th>
  4.     <th>Level</th>
  5.     <th>Salary</th>
  6. </tr>
  7. <tr>
  8.     <td center>**CEO**</td>
  9.     <td>Senior</td>
  10.     <td right>€100,000</td>
  11. </tr>
  12. <tr>
  13.     <td center>Vice President</td>
  14.     <td>Senior</td>
  15.     <td right>€90,000</td>
  16. </tr>
  17. <tr>
  18.     <td center>Senior Architect</td>
  19.     <td>Senior</td>
  20.     <td right>€70,000</td>
  21. </tr>
  22. <tr>
  23.     <td center>Developer</td>
  24.     <td>Intermediate</td>
  25.     <td right>€50,000</td>
  26. </tr>
  27. </table>
As you can see, the syntax is very similar to straight HTML. In fact, the only difference is that, instead of using align=“center” or valign=“top”, you simply specify one of left, right, center for horizontal alignment and top, bottom and middle for vertical alignment. As you can see above, the aligment parameters can be used to align both table cells and the table itself.

Here's what the table above will be rendered like:

Position Name Level Salary
CEO Senior €100,000
Vice President Senior €90,000
Senior Architect Senior €70,000
Developer Intermediate €50,000

Images

Images and figures can be embedded in your chapter by using the {{figure}} tag:

  1. {{figure figure123.tif}}
Note that you should never embed external images. Instead, you should store your images in the figures folder and reference them by filename only.

Note that any images you send must be in one of the following formats: GIF, PNG, JPG (RGB only), TIF (RGB only), BMP, EPS and PDF, with a minimum resolution of 300 dpi. Our preferred formats are TIF (using a lossless compression format) for rasterized images and EPS for lineart.

Sidebars

A sidebar is a section of text that the Ceres interpreter highlights for visibility; you can use it for warnings, notes, or to otherwise attract the reader's attention.

Here's an example:

  1. {{sidebar Important Information
  2.  
  3. You should never run while holding scissors;
  4. it can be bad for your health}}
As you can see, a sidebar is composed of the opening tag {{sidebar, followed by a space and the title of the sidebar. You can then press ENTER twice (as if you were starting a new paragraph), followed by the body of the sidebar, which can contain pretty much any other formatting element, with the exclusion of another sidebar.

Ceres Resources