venerdì 9 dicembre 2011

The Shunned House -- From Text To Page, step 0

Let's (really) start.
After I've posted three articles about setting up a proper ConTeXt environment, it's time to get started.
This is the first a series of posts which will show you how I transform an ASCII document into a well-formatted PDF.
What do I mean with "Well-Formatted?" I mean that we will end up with a well formatted two-column book, laid out in an A4-sheet. Two-column layout is somewhat of a standard in RPG world: I think that seven games out of ten use such layout. Columns, however, are not enough: I will show you how to integrate new fonts in the system, how to insert cliparts and add flair to your pages (like, for instance, a background on every page). What I want to get is something not unlike this layout, and this series of posts will show you how to do it.

The Shunned House

For this task, I will use H.P. Lovecraft's "The Shunned House".
Why?
The text is available from Project Gutenberg's Site free of charge. Moreover, it is in the Public Domain, so we can use it without fear of infringing any copyright. Lastly, "Call of Cthulhu" was one of the first game I played, so I have quite a good reason to choose HPL as a starting point for my tutorial.



Go!

According to ConTeXt author Hans Hagen, while ConTeXt comes with a lot of commands, you can obtain satisfying results with only ten groups of these, namely:

  1. \starttext, \stoptext
  2. \chapter, \section, \title, \subject, \setuphead, \completecontent
  3. \em, \bf, \cap
  4. \startitemize, \stopitemize, \item, \head
  5. \abbreviation, \infull, \completelistofabbreviations
  6. \placefigure, \externalfigure, \useexternalfigures
  7. \placetable, \starttable, \stoptable
  8. \definedescription, \defineenumeration
  9. \index, \completeindex
  10. \setuplayout, \setupfootertexts, \setupheadertexts
In this lesson, we'll use some of them, namely

    \starttext, 
    \stoptext, 
    \chapter 
    \em

What we're going to get is simply generating a pdf of "Shunned House".
In a self-contained ConTeXt document, all the text must be included between \starttext and \stoptext

\starttext

[...your text here...]

\stoptext

So, let's remove from the text the preamble and the Project Gutemberg's license text and put the remainder between \startext and \stoptext. Save the resulting file in a text file ending with .tex extension.

Special characters

There are some characters that have a special meaning for TeX: they are

 $  # & % _ ^ ~ { } \ 

To include them in the pdf, you must type

\$  \# \& \% \_

for the first five of them, while for the next you must use some more elaborated code:

 \^{ }  \~{ }  $\{$   $\}$   $\backslash$   

In "Shunned House" there is an Ampersand and a lots of "", used to emphasize words. So, let's substitute the & with \& throughout the text. When, however, we begin to replace the ""s, we quickly realize that it's not enough to enable "_"s production in document, since we'll lose the emphasis these character mean in text. So, for every word thusly emphasized

  This _word_ is emphasized

we can choose to use the proper ConTeXt emphasis command, \em. The above examples thus becomes:

This {\em word} is emphasized

So, emphasize the words following this rule.

Lastly, we need to add more structure to the text, marking chapters.

To mark a chapter, we use the \chapter{chapter title} command. This will produce

 1. Chapter Title

An empty chapter command like this: \chapter{} will produce

 1.

Since we have five numbered chapter with no title, we'll substitute every chapter number with an empty chapter command

\chapter{}

When we're done, we're ready to build our first PDF. Save the document with "The_Shunned_House_1.tex" name and compile the file to a pdf by launching the following command:

  texexec The_Shunned_House_1.tex

If everything goes OK, you will get 23 pages of text, divided in five chapters. We're still quite far from our target... but hey, it's our first step! Don't worry: it'll get better!

Files for this project are available here.

Nessun commento: