
## Section2.4Extending the Minimal Example

We will not keep reproducing the entire example but instead suggest a series of modifications. After each edit, process the file again to make sure your syntax is correct (before you get too far along) and to see the changes.

The generic name of the resulting files is pretty bland, and it would be nice to have a title for our article. We will add an attribute to the <article> tag, specifically @xml:id, which is a very important part of PreTeXt and used frequently. For now, it will be used to generate the names of the output files. (The “at” symbol is a way of reminding you that it is an attribute, it is not part of what you author.)

So make the following modifications:

<article xml:id="quick">
<title>My First Small Example</title>

<p>This is a short sentence.</p>


Your outputs should now have a title, and more importantly, the filenames will be quick.html and quick.tex. Of course, you might like your outputs to have similar names to your input, but you see that this is not necessary.

Let us give our article a bit of structure. We will have an introduction and two sections with their own titles. So replace the one-sentence paragraph by the following, all following the article title and contained within the <article> tags. Remember, do not include any newlines (carriage returns, line feeds, hard wrap) in the longer lines. (We have to format things differently so you can see exactly what is happening.)

<introduction>
<p>Let's get started.</p>
</introduction>

<section xml:id="section-short">
<title>Beginnings</title>

<p>This is a short sentence.</p>
</section>

<section xml:id="section-multiple-paragraph">
<title>Endings</title>

<p>This is a longer sentence that is followed by another sentence.
Two sentences, and a second paragraph to follow.</p>

<p>One more paragraph.</p>
</section>


The /PDF output will be a bit odd looking since every paragraph is so short, but all the content should be there. Notice that the HTML output now has a table of contents to the left and active navigation buttons. Also the two sections are in their own files and the URLs have been constructed from the supplied values of the @xml:id attribute.

One last experiment—let us add some mathematics. We use XML tags, <m> for “inline” mathematics and <me> for a “math equation” which will be rendered with a bit of vertical separation and centered from left to right. We use syntax for mathematics, which has been the standard for working mathematicians for decades. For electronic presentation, we rely on the excellent MathJax project which basically supports all the syntax of the amsmath package from the American Mathematical Society. Add the following sentence to any of the paragraphs of your article.

If the two sides of a right triangle have lengths <m>a</m>
and <m>b</m> and the hypotenuse has length <m>c</m>,
then the equation <me>a^2 + b^2 = c^2</me> will always hold.


So your final source file might look like the following. You now have many of the basic skills you would need to write an entire research article in mathematics, and should be in a position to learn the remainder easily and quickly.

<mathbook>
<article xml:id="quick">
<title>My First Small Example</title>

<introduction>
<p>Let's get started.</p>
</introduction>

<section xml:id="section-short">
<title>Beginnings</title>

<p>This is a short sentence.</p>
</section>

<section xml:id="section-multiple-paragraph">
<title>Endings</title>

<p>This is a longer sentence that is followed by another sentence.
Two sentences, and a second paragraph to follow.</p>

<p>One more paragraph.  If the two sides of a right triangle have
lengths <m>a</m> and <m>b</m> and the hypotenuse has length <m>c</m>,
then the equation <me>a^2 + b^2 = c^2</me> will always hold.</p>
</section>
</article>
</mathbook>