Appearance
Getting Started
In this section, we'll walk through an example template to introduce Press. After reading this section, you should be able to start writing your own templates and refer back to the remainder of the documentation for specific details and advanced features.
For our example, we're going to create a document giving a brief overview of the history of Artificial Intelligence.
Let's start with a simple Press document:
xml
<press>
<document>
<page width="21cm" height="29.7cm" page-margin="2cm">
<h1>The History of AI</h1>
<p>From Turing's test to modern neural networks, AI has transformed from philosophy to reality.</p>
</page>
</document>
</press>Breaking it down
Let's examine what's happening here, piece by piece:
The <press> wrapper
xml
<press>
<!-- Everything goes inside here -->
</press>Every Press document starts with this root element. It's just a container for everything else.
The Document Structure
xml
<document>
<!-- Your pages go here -->
</document>The <document> tag contains a sequence of pages. Right now, we only have one page, but we could add more here later.
Defining the Page
xml
<page width="21cm" height="29.7cm" page-margin="2cm">
<!-- Your content goes here -->
</page>Now we start describing our page. Here, we're setting up the physical dimensions of a page:
width="21cm"andheight="29.7cm"– This is A4 paper size. You can also use points instead of centimetres. PDFs have 72 points per inch, so an A4 page would be "595pt" wide and 842 points tall. We can easily mix pages of different sizes within the same document. Or set the dimensions on the<document>tag to save some typing.page-margin="2cm"– This creates a two centimetre margin around your content. A page in Press is just a special kind of frame, so you can also usepaddinghere as in CSS, butpage-marginis more intuitive.
The Content
xml
<h1>The History of AI</h1>
<p>From Turing's test to modern neural networks, AI has transformed from philosophy to reality.</p>We've dropped content directly into the page. Press supports familiar tags like <h1>, <h2>, <p> and much, much, more.
Ready to add more content? Let's move on to building a more substantial document with lists, images, and tables.