Derivatives and Integrals: An Annotated Discourse
Section 1 Introduction
We consider definite integrals of functionsSection 2 The Fundamental Theorem
There is a remarkable theorem: 1Theorem 2.1. The Fundamental Theorem of Calculus.
If
Proof.
Left to the reader.
[provisional cross-reference: some textbook about the FTC]
or we might want to reference a later [provisional cross-reference: chapter about DiffEq's, and an_underscore]
.
We can also embed “todo”s in the source by making an XML comment that begins with the four characters todo
, and selectively display them, so you may not see the one here in the output you are looking at now. Or maybe you do see it?
Because a definite integral can be computed using an antiderivative, we have the following definition.
Definition 2.2.
Suppose that
Section 3 Computing Integrals with Sage ( )
Sage can compute definite integrals. The output contains the approximate numerical value of the definite integral, followed by an upper bound of the error in the approximation.
xxxxxxxxxx
numerical_integral(sin(x)^2, (0, 2))
xxxxxxxxxx
integral(sin(x)^2, x)
xxxxxxxxxx
integral(sin(x)^2, (x, 0, 2))
xxxxxxxxxx
integral(e^(x^2), x)
doctest
attribute, whose value mirrors the optional hash tags used in Sage doctests. Possible values are random
, long time
, not implemented
, not tested
, known bug
, absolute
, relative
, and optional
. The values absolute
and relative
refer to floating-point tolerances for equality and require a second attribute tolerance
to specify a floating point value. The value optional
refers to the test requiring that an optional Sage package be present. The name of that package should be provided in the package
attribute.
The next cell is marked in the source as doctest="random"
, and so is specified as unpredictable and not tested. But there is some “sample” output which will appear in the LaTeX version (and always be the same).
xxxxxxxxxx
random()
random()
function stays between xxxxxxxxxx
12 + 0.01*random()
xxxxxxxxxx
pretty_print(html("$a^2$"))
R
language, a popular open source language for statistics. As an author, you add the attribute language="r"
to your sage
element. (The default language is Sage, so you do not need to indicate that repeatedly.) Note that a language like R
likes to use a “less than” character, <, special character in XML. You need to escape it by writing <
as we have done in the source for this example. (See the discussion in Subsection 8.1.)
As a reader you learn that the “Evaluate” button for a pre-loaded Sage cell will indicate the language in use.
xxxxxxxxxx
ruth <- c(22, 25, 34, 35, 41, 41, 46, 46, 46, 47, 49, 54, 54, 59, 60)
bonds <- c(16, 25, 24, 19, 33, 25, 34, 46, 37, 33, 42, 40, 37, 34, 49, 73, 46, 45, 45, 5, 26, 28)
dimaggio <- c(12, 14, 20, 21, 25, 29, 30, 30, 31, 32, 32, 39, 46)
summary(ruth)
summary(bonds)
summary(dimaggio)
boxplot(ruth, bonds, dimaggio)
sage
, gap
, gp
, html
, maxima
, octave
, python
, r
, and singular
.
Here is another R
cell. Unfortunately, it seems Sage's doctest
facility cannot be used easily with code from other languages. In the source for this example, we have employed the XML escape sequence, <
several times (see Subsection 8.1).
xxxxxxxxxx
age <- c(25, 30, 56)
gender <- c("male", "female", "male")
weight <- c(160, 110, 220)
mydata <- data.frame(age,gender,weight)
summary(mydata)
cor(mydata$age,mydata$weight)
mean(mydata$age)
sd(mydata$age)
plot(mydata$age,mydata$weight)
xxxxxxxxxx
# Practice area (not linked for Sage Cell use)
<sage>
element with no content will also create an empty Sage cell for the reader's use, but now it will be specific to a particular language and linked to others of the same language. Run the R
cell above that defines the variable ruth
and then try typing summary(ruth)
in the cell below. (The linking seems a bit buggy, as it repeats the boxplot in the output, as of 2016-06-13).
xxxxxxxxxx
type="invisible"
, which will never be shown to a reader, but which get doctested. Why do this? If some code produces an error, and you hope it is fixed someday, use an invisible block to raise the error. Once fixed, the doctest will fail, and you can adjust your commentary to suit. There is such a block right now, but you will need to go to the source to see it.
Our maximum width for text, designed for readability, suggests you should format your Sage code with a maximum of about 54 characters. On a mobile device, the number of displayed characters might be as low as 28 in portrait orientation, and again around 50 in landscape. You can use a variety of techniques to shorten long lines, such as using intermediate variables. Since Sage is just a huge Python library, you can use any of Python's facilities for handling long lines. These include a continuation character (which I try to avoid using) or natural places where you can break long lines, such as between entries of a list. Also, if writing loops or functions, you may wish to have your indentation be only two characters wide (rather than, say, four).
Sage output can sometimes be quite long, though this has improved with some changes in Sage's output routines. Output code should be included primarily for doctesting purposes, and in this use, you may break at almost whitespace character and the doctesting framework will adjust accordingly. You may wish to show sample output in a static format, like a PDF, so you can consider formatting your output to fit the width constraints of that medium. Or you may even adjust exactly what is output, to keep it from being too verbose. Sage doctesting also allows for a wild-card style syntax which allows you to skip over huge chunks of meaningless or unpredictable output, such as tracebacks on error messages.
This paragraph is just a placeholder. It has handful of index entries, all starting with the letters “gas”, taken from Indexing for Editors and Authors: A Practical Guide to Understanding Indexes by Leise, Mertes, and Badgett. The intent is to test letter-by-letter versus word-by-word sorting of index entries. We use a word-by-word order, resulting in:
gas
gas masks
gas production
gas works
gasoline
gastritis
Titled Sage Cells.
xxxxxxxxxx
integral(sin(x)^2, x)
paragraphs
if you want to give them a title, but no numbers, etc. Their surrounding box sometimes gets clobbered in LaTeX output if they are the first piece of content, so we test that here also. A defensive \leavevmode
solves the problem.Section 4 An Interesting Corollary
Objectives: Fundamental Structures
This is an <objectives>
element you are reading, and this is its introduction. This early section has really grown and tries to accomplish many things. Not all of them are listed here.
Display various “blocks”, fundamental units of the flow.
More.
Evermore.
This concludes the (incomplete) objectives for this section, so now we can carry-on as before.
phrase-global
form of the text. It should describe the objective as belonging to the section (rather than the objectives), since objectives are one-per-subdivision and are numbered based upon the containing division: Objective 1 of Section 4. For comparison this is the (forced) type-global
cross-reference: Objective 4.1.
The Fundamental Theorem comes in two flavors, where usually one is a corollary of the other.Subsection 4.1 Second Version of FTC
Corollary 4.1 (Leibniz, Newton).
Suppose
Proof.
We simply take the indicated derivative, applying Theorem 2.1 at (4.2)
Alternate Proof.
You can have multiple proofs, and they can have titles which replace the word “Proof” as a heading. Here we just exercise displayed math with no automatic numbering, and an elective number on the middle equation.
xxxxxxxxxx
c = 832
c
Example 4.2. A Mysterious Derivative!
So if we define a function with its variable employed as a limit of integration, like so
then we get the derivative of that function so easily it seems like a mystery,
That's it.
For testing purposes, there is a simple Sage Cell here, buried inside an example that should be a knowl (embedded in the page).
We test a Sage cell inside a knowl, which should set the value of a variable that will be available to subsequent cells within the knowl.
Even if you ran the cell at the top of this page, within this knowl the value of the variable c
is not known, so the next cell will cause an error.
xxxxxxxxxx
c/2
<example>
. The results there are restricted to the knowl. In other words, the scope of those cells is the knowl. So if you opened the example and executed the Sage cells there, or if you skipped the example entirely, the next cell should not “know” the values of those variables and will raise an error.
xxxxxxxxxx
a + b
Claim 4.3. An Equivalent Claim.
This claim is an equivalence: it is true if and only if it is correct.
Proof.
Our purpose here is to show how you can structure a proof with cases, such as an equivalence structured with the arrows typically used to demonstrate the two “directions” involved in the proof, by using the direction
attribute on a case
element.
(⇒)
Nulla non lectus suscipit, bibendum leo quis, dignissim justo. In urna turpis, tincidunt id elementum id, faucibus ac tellus.
(⇐)
Quisque auctor ligula turpis, ut aliquam urna consectetur hendrerit. Aenean porta dolor et justo facilisis feugiat in sed sapien. Nullam porta ex et commodo semper.
Case 3b: The inductive step.
A case may also have a title
, whose formatting and structure is entirely up to the author. This then becomes the text of a cross-reference, as well.
(⇒) Necessity.
If you like, you can have both indications.
Case.
No direction, no title, then just a generic title.
Exciting Proof!
We test here that punctuation at the end of the title of a proof is handled correctly.
Exact Proof.
This proof should fill exactly three lines (as of defaults in place 2018-12-31) and so the tombstone/Halmos should be on a fourth line, and then flush right. xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx xxx.
Subsection 4.2 A Pedagogical Note about Subsection 4.1
Subsubsection 4.2.1 Symbolic and Numerical Integrals
The Fundamental Theorem explains why we use the same notation for a definite integral, which is a numerical calculation, 1 and an antiderivative, which is a symbolic expression.Checkpoint 4.4. Essay Question: Compare and Contrast.
Write a short paragraph which compares, and contrasts, the definite and indefinite integral. This is an exercise which sits in the midst of the narrative, so is formatted more like an example or a remark. It can have a hint and a solution, but this one does not. It can have a title, which this one does.
Start writing!
Subsubsection 4.2.2
This subsubsection has a title in the source, but it is empty. That's OK, but not advisable since titles get used lots of places (such as page headers and the table of contents).Subsubsection 4.2.3 Advice
Using an “integral sign” for an antiderivative (aka indefinite integral) would seem to make the Fundamental Theorem a fait accompli. So I would suggest not conflating the notation for two very different things until the Fundamental Theorem exposes them as being highly related.Example 4.5. An Example of Structure.
This is an example of an example with a bit more structure. Specifically, the example has a title
, as usual, but then has a statement
, which is separate from the solution
. Why did we implement an example in two ways?
Authors asked for it and it seemed a very natural thing to do, even if we only had an unstructured version for a long time.
Question 4.6. An Example of a Question.
Any kind of question can be marked as such with <question>
. Or similarly, as a <problem>
. They behave identically to example
s, such as the one preceding and are numbered along with theorems, examples. etc.
Checkpoint 4.7. An Inline Exercise.
There are lots of exercises in this sample article, but mostly they are in special exercise sections. Sometimes you just want to sprinkle some exercises through the narrative. We call these inline exercises, in contrast to divisional exercises. The inline exercises look a bit more like a theorem or definition, with titles and fully-qualified numbers.
These may also have hints, answers and solutions.
A good hint.
42.
If your exercise feels like proving a theorem, then you might want to make some comments, but also clearly delineate which part of the solution is a the complete proof.
Proof.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lorem diam, convallis in nulla sed, accumsan fermentum urna. Pellentesque aliquet leo elit, ut consequat nunc dapibus ac. Sed lobortis leo tincidunt, vulputate nunc at, ultricies leo. Vivamus purus diam, tristique laoreet purus eget, mollis gravida sapien. Nunc vulputate nisl ac mauris hendrerit cursus. Sed vel molestie velit. Suspendisse sem sem, elementum at vehicula id, volutpat ac mi. Nullam ullamcorper fringilla purus in accumsan. Mauris at nunc accumsan orci dictum vulputate id id augue. Suspendisse at dignissim elit, non euismod nunc. Aliquam faucibus magna ac molestie semper. Aliquam hendrerit sem sit amet metus congue tempor. Donec laoreet laoreet metus, id interdum purus mattis vulputate. Proin condimentum vitae erat varius mollis. Donec venenatis libero sed turpis pretium tempor.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra. Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
Example 4.8. An Example of with math formula in the title.
Just for testing math in knowls, and also extra whitespace in a <p>
.
<project>
is very similar to a <question>
or <problem>
Project 4.1. Start Exploring PreTeXt.
You could grab the minimal.xml
file from the examples/minimal
directory and experiment with that.
Projects get their own independent numbering scheme, since they may be central to your textbook, workbook, or lab manual. If you process this sample article with --stringparam numbering.projects.level 0
then you will get consecutive numbers from the beginning of your book, starting with 1.
Exploration 4.2. Exploring Explorations.
This is an <exploration>
. Other similar possibilities are <project>
, <activity>
, <task>
, and <investigation>
.
Note that projects, activities, explorations, tasks and investigations share the independent numbering scheme, so it is really only intended you use one of these. If you want a variant of the name (e.g. “Directed Activity”) you can use the <rename>
facility (Subsection 28.1).
This is a “solution” to the exploration. In practice, you might choose to not make this visible for students, but instead include it as part of some guidance you might provide to instructors (e.g. an Instructor's Manual).
prelude
authored within the activity
element, but visually just prior.
Activity 4.3. Hints, Answers, Solutions.
Another variant of these project-like items is to possibly include a <hint>
and an <answer>
before the <solution>
.
postlude
authored within the activity
element, but visually just after.
Note 4.9. A Note on Remarks.
<remark>
, <convention>
, <note>
, <observation>
and <warning>
are designed to hold very simple contents, with no additional structure (no proofs, no solutions, etc.).
But they do carry a title and a number, can be the target of a cross-reference, and may be optionally knowlized in HTML with the html.knowl.remark
processing switch.
<exercise>
can be structured with <task>
.
Checkpoint 4.10. A very structured exercise.
This is an over-arching introduction to the whole exercise. We follow with some tasks. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(a) A super-simple task.
This first task is very simple, just a paragraph. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(b)
Now three paragraphs. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(c) A title of a task that has a subtask with an <answer>
for the Solutions.
This second task is further divided by more tasks. This is its introduction. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(i) A task with a title and an <answer>
for the Solutions.
A really simple subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
A short paragraph, before an answer.
(ii)
A subtask with an answer. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
Right! In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(iii)
Three simple sub-sub-tasks. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(A)
First subsubtask. Short paragraph.
(B) A second three-deep subsubtask!
Second subsubtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(C)
Third subsubtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
The conclusion of the structured subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(iv)
A simple task as the last subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
This concludes our structured second task. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(d)
This third top-level task is intermediate in complexity, you are reading the statement
, which is followed by more items. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
One hint. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
First answer. In interdum suscipit ullamcorper.
Second answer. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
At last, the solution. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
This is a conclusion where you could summarize the exercise. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
<project>
is nearly identical to the preceding <exercise>
.
The next block is a project, demonstrating the use of the task
element to structure its parts. You are reading the prelude
now. The project has lots of nonsense words, so we can test spacing the nested items. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
Project 4.4. A very structured project.
This is an over-arching introduction to the whole project. We follow with some tasks. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(a)
This first task is very simple, just a paragraph. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(b)
Now three paragraphs. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(c)
This second task is further divided by more tasks. This is its introduction. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(i)
A really simple subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
A short paragraph, before an answer.
(ii)
A subtask with an answer. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
Right! In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(iii)
Two simple sub-sub-tasks. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(A)
First subsubtask. Short paragraph.
(B)
Second subsubtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(C)
Third subsubtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
The conclusion of the structured subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(iv)
A simple task as the last subtask. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
This concludes our structured second task. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
(d)
This third top-level task is intermediate in complexity, you are reading the statement
, which is followed by more items. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
One hint. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
First answer. In interdum suscipit ullamcorper.
Second answer. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
At last, the solution. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
This is a conclusion where you could summarize the project. In interdum suscipit ullamcorper. Morbi sit amet malesuada augue, id vestibulum magna. Nulla blandit dui metus, malesuada mollis sapien ullamcorper sit amet. Nulla at neque nisi. Integer vel porta felis.
<example>
, from Elise Desgreniers, is structured with <task>
.
Example 4.11. Notation mathématique 2.
Écrivez chacun des exemples suivants avec les conditions pertinentes.
(a)
Soit l'ensemble \(A=\lbrace 1,2,3,4,5\rbrace\text{.}\)
On constate que cet ensemble contient uniquement des entiers positifs allant de 1 à 5.
Donc, on peut écrire \(A=\lbrace x\mid x\in\mathbb{N}\text{ et } 1\leq x\leq 5\rbrace\text{.}\)
(b)
\(\{3,6,9,12,15,\ldots,27,30\}\)
(c)
\(\{1,3,5,7,9,11,\ldots\}\)
(d)
\(\{2,3,5,7,11,13,17,19,23,\ldots\}\)
(e)
\(\{1,4,9,16,25,36,\ldots,961\}\)
(f)
\(\{1,8,27,64,125,\ldots\}\)
Technology 4.12. Sample Use of Sage.
This would be a good place to talk about Sage, including a cell or two.
xxxxxxxxxx
diff(x^4, x)
But you might want to describe how to use some other calculator, or maybe some numerical method.
Exercises 4.2.4 Exercises
1.
This is an exercise in an “Exercises” subdivision at the level of a subsubsection. There is no question other than if the numbering is appropriate. Here is a self-referential link: Exercise 4.2.4.1.
The subsubsection has no title in the source, so one is provided automatically, and will adjust according to the language of the document.
This solution will migrate to a list of solutions in the backmatter. We include a sidebyside
as a test.
This is a skinny paragraph which should be just 30% of the width.
And another skinny paragraph which should also be just 30% of the width.
2.
An <exercise>
can be structured with parts, called <task>
. This is the <introduction>
.
(a)
Do this.
(b)
And the other thing.
Reading Questions 4.2.5 Reading Questions
<introduction>
, perhaps for preparatory explanation.
If a student has logged in to the HTML version, then they can answer the reading questions directly in the book. Inline math LaTeX can be entered using $
...$
or \(
...\)
delimiters, and inline AsciiMath using backticks `
...`
as delimiters. Here are some 1.
This is a reading question that you might have a student answer prior to a class session, based on reading part of the book. A quick glance before class can help you tailor class time to the specific needs of your students. The perfect reading question will reveal whether the student has read and understood the material, and will be difficult to answer if they have not. What do you think of that?
2.
And a second one, with a cross-reference to the first, as a check on numbering: Reading Question 4.2.5.1. Reading questions are allowed to have answers, but providing answers misses the point of a reading question, and the answer knowl interacts poorly with the mechanism used to allow students to answer directly in the book. Do you think the schema should ban answers to reading questions?
<conclusion>
.Glossary 4.2.6 Glossary
<introduction>
, perhaps with some explanation.- bar.
A part of foobar. See foobar.
- foobar.
A synonym for the acronym FUBAR.
<conclusion>
.Solutions 4.2.7 Solutions for This Subsection
Subsubsection 4.2.1 Symbolic and Numerical Integrals
Checkpoint 4.4. Essay Question: Compare and Contrast.
Subsubsection 4.2.3 Advice
Checkpoint 4.7. An Inline Exercise.
Exploration 4.2. Exploring Explorations.
Activity 4.3. Hints, Answers, Solutions.
Checkpoint 4.10. A very structured exercise.
(c) A title of a task that has a subtask with an <answer>
for the Solutions.
(i) A task with a title and an <answer>
for the Solutions.
(ii)
(d)
Project 4.4. A very structured project.
(c)
(i)
(ii)
(d)
Exercises 4.2.4 Exercises
4.2.4.1.
Subsection 4.3 Theorem-Like Environments
There are a variety of pre-defined environments in PreTeXt. All take a title, and must have a statement. Some have proofs (theorems, corollaries, etc.), while some do not have proofs (conjectures, axioms, principles).Principle 4.13. The Title Principle.
It is a fundamental principle that many elements can have a title. Try it and see. If you get better formatting, then it is being recognized. If it looks very plain, check the documentation and perhaps make a feature request.
<theorem>
, <corollary>
, <lemma>
, <algorithm>
, <proposition>
, <claim>
, <fact>
, and <identity>
, all behave exactly the same, requiring a statement (as a sequence of paragraphs) followed by an optional proof, and may have an optional title. The elements <axiom>
, <conjecture>
, <principle>
, <heuristic>
, <hypothesis>
, and <assumption>
are functionally the same, barring a proof (since they would never have one!). Definitions are an exception, as it is natural to place <notation>
within—see the source for Definition 2.2 for an example.Subsection 4.4 Linking Sage Cells
Sage cells share their results on a per-webpage basis, or a per-knowl basis, so if you move to a new chapter, section, or subsection that happens to be on another webpage, your Sage computations are gone and you start fresh. But maybe you need some results from elsewhere. As an author, you can make an exact copy of a cell in another location by placing the code in an external file, which is pure text, freed from any need to format for XML processing. So, in particular, there is no need to escape ampersands and angle brackets, nor is there employment of theCDATA
mechanism. But the real value is that there is just one version to edit, and any changes will be reflected in both copies. We demonstrate this in the sample book, since it has the xinclude
mechanism in place. In the chapter on groups, find the section on Sage and then find the discussion of subgroups, and you will find an example of two identical Sage cells produced from one source file.Subsection 4.5 Hierarchy
Structure.
This section of this article has subsections and subsubsections. In a book you can have chapters enclosing multiple sections. There is one finer subdivision, it is achieved with theparagraphs
element.
It is basically a sequence of paragraphs, where the first one gets an inline title. You are reading the second, and final, paragraph of one right now. It is useful for organizing very short documents, where numbered subdivisions might be overkill.A Second Paragraphs.
This is a second consecutiveparagraphs
element, so should seem related to its title, but distinct from the two paragraphs in the grouping with the title “Structure” immediately prior.Assemblages: Collections and Summaries.
An <assemblage>
is a collection, or summary, that does not have much structure to it. So you are limited to paragraphs and friends (p
, blockquote
, pre
) and side-by-sides that do not contain captioned items (sidebyside
, sbsgroup
). The intent is that contents are not numbered, so cannot be cross-referenced individually, and so also do not become knowls. You may place <image>
, <tabular>
, and <program>
inside a <sidebyside>
, in addition to other objects that do not have captions. Note that p
may by extension contain lists (ol
, ul
, dl
). Despite limited structure, the presentation should draw attention to it, because the contents should be seen as more important in some way. It should be “highlighted” in some manner. If you need to connect the entire assemblage with material elsewhere, you can do that with the usual xref/xml:id
mechanism.
What have we seen so far in this (disorganized) sample?
Theorems, definitions and corollaries. (Section 2)
Sage cells, including with R. (Section 3)
Lots of document structure, like introductions and conclusions (next). (Section 4)
A sample table, as a tabular
inside a sidebyside
with no caption, follows.
A | B | C |
Uno | Dos | Tres |
This is a small assemblage
with no title, simply to make sure the surrounding box behaves properly, especially for LaTeX output.
Assemblages containing .
It is acceptable for an assemblage to contain mathematical content, even in its title.
Subsection 4.6 Introductions and Conclusions
An Introductory Introduction.
Any subdivision may have a sequence of paragraphs within an<introduction>
that precedes subsequent further subdivisions. You are reading one now. They are always leaves of the document structure, so are rendered on some pages that reference the following subdivisions.
An introduction or conclusion is an extremely restrictive container with simple presentation. A title is optional (and probably not advisable). Content is meant to be short and unstructured, in particular, nothing that can be numbered is allowed. If this feels too restrictive, then place your content in an initial numbered subdivision and perhaps title it “Introduction”. Or make your entire subdivion unstructured and place whatever you want into it.
This ends this introduction to introductions.Subsubsection 4.6.1 Test One
An intervening subsubsection just after an introduction.Subsubsection 4.6.2 Test Two
An intervening subsection section which contains an<exercises>
division which must be at the level of a Subsubsubsection.
Exercises Exercises
1.
A mock exercise to appease validation.
2.
And a second to help with formatting the division heading.
Subsubsection 4.6.3 Test Three
An intervening subsubsection just before a conclusion.<conclusion>
that follows previous further subdivisions. You are reading one now. They are always leaves of the document structure, so are rendered on some pages that reference the preceding subdivisions.
This concludes this conclusion (and this subsection and this section).Subsection 4.7 Some Paragraph-Level Markup
Text within a paragraph may be emphasized with<em>
or if you want to take it to the next level you can identify the text as an alert with <alert>
.
Similarly, within a paragraph, you can identify edits between versions as inserted text that has been added with <insert>
or as <delete>
. Note that these identified edits are slightly different than <stale>
. The original request for stale text came from an instructor with an online list of student topics for presentations, and as students claimed topics they were marked as no longer available for other students.
If you need a “fill-in blank”, like this, it can be obtained with an empty <fillin>
element that defaults to roughly a 10-character width. You can use the <characters>
attribute to make the rule longer or shorter, such as a 40-character blank: . The character count is approximate, based on typical character widths within a proportional font carrying English language text. Adjust to suit, or request a language-specific adjustment if it is critical.
Long after we started this mess, we added PreTeXt tags to mark up tags and attributes. The elements are: <tag>
, <tage>
, <attr>
. Examples of how these render are (respectively): <section>
, <hash/>
, @width
. Perhaps this document will make greater use of these tags.
We supply two provisional cross-references for testing purposes only: [provisional cross-reference: a first incomplete cross-reference]
, [provisional cross-reference: a second incomplete cross-reference]
.type-global
form of the text. It should describe the outcome as belonging to the section (rather than the outcomes), since outcomes are one-per-subdivision and are numbered based upon the containing division: Outcome 2 of Section 4. For comparison this is the (forced) type-global
cross-reference: Outcome 4.2.Outcomes: Fundamental Structures, Revisited
This is a <outcomes>
element you are reading, and this is its introduction. This early section has really grown and we have tried to accomplish many things. Not all of them are listed here.
Display various “blocks”, fundamental units of the flow.
More, and this is what the cross-references above are pointing to.
Evermore.
This concludes the (incomplete) outcomes for this section, so now we can carry-on to the next section.
Section 5 Some Facts and Figures
Because of the Fundamental Theorem 1 , for every derivative we know, there is an antiderivative we might find useful. Because of the Fundamental Theorem of Calculus 2 , we recycle the “-
Derivatives
-
Antiderivatives
Remark 5.1.
You can 3 gain a greater understanding of derivatives by studying the graphs of functions with their derivatives. Can 4 you discern the derivative–antiderivative 5 relationship in Figure 5.2?

Red
Blue
Green
Purple
Yellow
Black
Orange
Pink
Salmon
Aqua
Cyan
Puce
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lorem diam, convallis in nulla sed, accumsan fermentum urna. Pellentesque aliquet leo elit, ut consequat nunc dapibus ac. Sed lobortis leo tincidunt, vulputate nunc at, ultricies leo. Vivamus purus diam, tristique laoreet purus eget, mollis gravida sapien. Nunc vulputate nisl ac mauris hendrerit cursus. Sed vel molestie velit. Suspendisse sem sem, elementum at vehicula id, volutpat ac mi. Nullam ullamcorper fringilla purus in accumsan. Mauris at nunc accumsan orci dictum vulputate id id augue. Suspendisse at dignissim elit, non euismod nunc. Aliquam faucibus magna ac molestie semper. Aliquam hendrerit sem sit amet metus congue tempor. Donec laoreet laoreet metus, id interdum purus mattis vulputate. Proin condimentum vitae erat varius mollis. Donec venenatis libero sed turpis pretium tempor.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra. Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
-
Donec vestibulum auctor nisl. Nullam placerat interdum dui. Quisque lobortis scelerisque augue imperdiet placerat. Maecenas ultricies massa tempor, laoreet urna a, eleifend enim. Integer sed suscipit odio. Pellentesque non dapibus diam, eget tempus dui. Maecenas sollicitudin magna viverra, egestas velit nec, tristique sem. Cras iaculis mattis dui ac cursus. Integer volutpat, urna vel tempus convallis, erat nisi consectetur turpis, id varius dolor lorem vitae mauris. Phasellus erat orci, laoreet commodo gravida quis, congue in lacus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent at bibendum turpis. Pellentesque est nisl, dapibus at sagittis non, ultricies in nunc. Etiam ipsum arcu, porta sed feugiat eget, facilisis nec libero. Mauris tempor convallis felis.
Cras iaculis sapien elit, at convallis ligula convallis nec. Duis ante tortor, euismod a libero vitae, ornare viverra purus. Pellentesque facilisis urna a velit volutpat, in malesuada tortor porttitor. Sed vehicula mauris id lectus dignissim, eget consectetur dui pellentesque. Sed vel quam molestie, euismod ligula ac, venenatis arcu. Fusce sit amet sapien non urna dignissim tempus in vitae metus. Aliquam arcu turpis, mattis non libero eu, lacinia feugiat turpis. Phasellus rhoncus lacinia lacus facilisis ullamcorper. Praesent hendrerit accumsan neque, eu dignissim est consequat sed. Nulla facilisi. Proin at mi scelerisque, scelerisque felis ut, tristique diam. Proin in leo in lorem porttitor varius. Praesent condimentum in dui sit amet blandit. In imperdiet blandit congue.
-
Ut nec sem vitae ipsum interdum vestibulum sit amet sed velit. Aliquam tempor nibh vitae augue pulvinar, at ultricies urna commodo. Donec in porta lectus, ac sagittis felis. Vestibulum tincidunt quis metus facilisis luctus. In lobortis lacus vel ornare vehicula. Duis aliquet, ligula semper sodales adipiscing, augue nibh ornare ante, quis pulvinar justo mi eget mi. Mauris varius imperdiet vehicula. Duis dignissim magna quis velit mattis, in cursus lectus vehicula. Morbi quis tempus felis, ut gravida nisi.
Vivamus eu commodo est, pretium fringilla dolor. Curabitur vel sollicitudin libero. Integer sit amet auctor felis. Maecenas sagittis erat at ante feugiat, in tincidunt ligula pretium. Integer eget auctor ipsum, quis volutpat felis. Morbi id dignissim eros. Suspendisse aliquet pulvinar lorem gravida egestas. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Praesent nec massa dui. Suspendisse convallis lacus sit amet adipiscing varius. Suspendisse tempus diam vitae justo ornare, in condimentum metus pharetra. Curabitur sem dolor, auctor vitae sagittis vestibulum, posuere imperdiet metus. Etiam pretium lacus urna, vel auctor diam tincidunt non. Etiam viverra sodales iaculis.
-
Sed varius leo urna. Phasellus tempus mollis ultricies. Curabitur non neque aliquet, facilisis tortor in, sodales dui. Donec hendrerit ultricies nulla mollis rhoncus. In vel lobortis est. Vestibulum consectetur lacus vel sem dignissim vestibulum. Etiam sed elementum ligula, vel congue turpis. Morbi nec diam mattis, venenatis eros et, elementum tellus. Integer sed orci ornare, elementum elit id, lacinia augue. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In et libero id turpis pharetra faucibus. Integer consequat dignissim semper. Donec pretium magna at ullamcorper ultricies. Nam quis suscipit elit. Donec cursus tellus et venenatis feugiat. Mauris dictum molestie leo, vitae aliquet metus luctus vitae.
Ut id iaculis leo. Sed nec vestibulum mi. Mauris est mauris, porta in nulla eget, bibendum luctus nisl. Praesent et posuere felis, molestie vehicula velit. Nulla a nunc venenatis, aliquam orci nec, congue felis. Vestibulum a dolor nisi. Morbi sed nisi nulla. Nam iaculis felis a enim blandit, at venenatis diam congue. Nulla augue diam, egestas eget fermentum nec, posuere eget risus. Praesent egestas nulla eros, eget accumsan augue euismod vel. Pellentesque pellentesque non erat vitae posuere. Curabitur lacus arcu, varius sed risus ut, ullamcorper tincidunt lorem. Sed et lacus dignissim, tincidunt nisl ac, porttitor sapien.
Section 6 Some Advanced Ideas
The multi-row displayed mathematics in the proof of the Fundamental Theorem had equations aligned on the equals signs via the & character. Sometimes you don't want that. Here is an example with some differential equations, with each equation centered and unnumbered,<idx>
and a <notation>
, adjacent, but separated by some whitespace in the authored source. That insignificant whitespace will be removed akways, which will be a (slightly) noticeable improvement in the LaTeX output. We test referencing notation here, placed before the sentence-ending period and right after some inline mathematics—for And so it follows that,
intertext
portion for testing.
First an external reference to http://example.com
and internal cross-reference to Corollary 4.1. And so it follows that,
<table>
to actually be a “subtable”, which exposes a bug provoked by Emiliano Vega and fixed around 2020-08-06. (So we have to place this early to create the same behavior that exposed the bug.)
One |
Two |
0 | 0.00 | 0.0000 | 0.5000 |
1 | 0.20 | 0.1000 | 0.4800 |
2 | 0.40 | 0.1960 | 0.4560 |
3 | 0.60 | 0.2872 | 0.4295 |
4 | 0.80 | 0.3731 | 0.4027 |
5 | 1.00 | 0.4536 | 0.3783 |
6 | 1.20 | 0.5293 | 0.3591 |
7 | 1.40 | 0.6011 | 0.3480 |
8 | 1.60 | 0.6707 | 0.3474 |
9 | 1.80 | 0.7402 | 0.3603 |
10 | 2.00 | 0.8123 | 0.3900 |
Section 7 Mathematics
AMSsymbols
library and the library for extensible arrows, extpfeil
.Subsection 7.1 Basic Mathematics
The following is from the MathJax demonstration page, an identity due to Ramanujan:\sfrac{}{}
macro in your mathematics to achieve this presentation.
We consider a system of equations. We number the first and last equation (there are just two) and include an xml:id
on each. We reference the whole system later as the range of equations from the first to the last.
Subsection 7.2 Displayed Mathematics
Multi-line displays of mathematics are achieved with themd
tag (“math display”), and the variant that produces numbers on each line, mdn
(“math display numbered”), used within a paragraph (p
). As a good example of how XML syntax is superior, you author mrow
tag, rather than using \\
).
If you use no ampersands to express alignment (read ahead), then each equation is centered independently on the width of the text. This is implemented according to the AMSmath LaTeX package's gather
environment. Example:
\amp
as one way specify these, but the escape sequence &
may be used also. The second, fourth, sixth, … ampersands separate columns, and the spacing between columns will be provided automatically. The first, third, fifth, … ampersands are alignment points for the equations in each column. Typically this is placed just prior to a binary operator, such as an equal sign (\amp =
), or for a column of explanations or commentary, just prior to the \text{}
macro. Note that this scenario suggests always having an odd number of ampersands in each mrow
. In the example below, alignment is on the equals sign in the first two columns, and provides left-justification to the explanations in the third column. N.B.: the use below of the \text{}
macro does not include mathematics within its argument. Doing so may yield unpredictable results depending on your choice of delimiters for the mathematics (and using an m
tag will be ineffective).
@alignment
attribute can override automatic detection. We use a simple LaTeX macro to demonstrate setting alignment='align'
to override the use of a gather
environment and use a align
environment instead. Example:
alignat
environment is a third variant of alignment. It never happens automatically, you need to ask for it with alignment="alignat"
. It is very similar to align
but adds no space between the equation columns. So you can leave it that way, or you can add your own “extra” space to suit. Here is a previous example with no inter-column space:
mrow
with the greatest number of ampersands (and how many there are),
alignat-columns
. This is the number of columns not the number of ampersands. Generally, for alignat
option to advantage by not including any extra space. This example is modified slightly from a post by Alex Jordan:
Example 7.1. Excessive Display Mathematics.
In print versions, a long run of displayed equations often needs to be broken across pages. If you are reading some other version of this, then there is nothing to see here. But for LaTeX output it could be interesting. First, with no extra effort, this page-long display should break naturally, no matter how the preceding material changes.
In this version we have turned off page breaking for the entire display, but then allowed a break at every fourth equation, so you should see a reasonably attractive page break right after one of the \(m^2+n^2=p^2\) equations.
So. Do not take any extra steps and let LaTeX figure out the breaks. If you do not like a break, modify the md
or mdn
to go back to the AMSmath default behavior and not break at all. Ever. Or rather, go further and modify an individual mrow
to suggest that it is a good place for a break.
Subsection 7.3 LaTeX Packages and MathJax Extensions
If you would like to use macros from a LaTeX package and there is a MathJax extension of the same name which implements the same macros, then you may use these with your mathematics as we demonstrate here. This example is from Jason Underdown. The package is namedcancel
and is included in the TeXLive distribution, so is fairly standard. The particular macro being demonstrated is \cancelto{}{}
.
latex-preamble/package
element within the docinfo
section. That is the only setup required to make the macro usable in LaTeX and HTML output.
The packages appear before the author-supplied macros, so you can use macros from the packages as building blocks for document-specific macros. We cannot guarantee there will be no conflicts between additional packages and those in use normally, or added in the future. So use at your own risk.Subsection 7.4 Advanced Mathematics
MathJax is extremely capable in rendering a subset of LaTeX in web browsers, and improving all the time. You can get fairly fancy with some of its supported commands. In particular, if you need to mix in a few words with your mathematics, the\text{}
macro is supported. For example, you might use an “if” or an “otherwise” in the definition of a piecewise function.
Consider that the first line below is text sandwiched in-between two Greek letters, wrapped in a \text{}
macro. In HTML output we have taken care that the font for text material within display mathematics should match the font of the surrounding paragraph, as also happens with LaTeX output. The second line is nearly identical in the source, but is just naked text being rendered like a slew of variables.
\text{}
macro to achieve certain effects. Note the Unicode left and right smart quotes. This a contribution from Alex Jordan as part of his work on APEX Calculus.
\mathord{}
and \mathrel{}
macros to control spacing around the mathematical symbols. Examine the source to see how the quotation marks have been authored with XML syntax for Unicode characters, since we do not allow most markup inside mathematics.
xref
element which you might want to use to provide justifications for the steps of a derivation. Here is a visual example that is mathematically meaningless,
\overset
and \underset
macros wrapping a PreTeXt <xref>
, with and without content, inside an <me>
element. Note that \stackrel
is obsolete, and \overunderset
is not yet supported by MathJax (but see GitHub #2704 1 ). The mathematics is Scott's, the reasons are totally unrelated to the math.
<xref>
with @text
set to global
) since if you stick to elements like <theorem>
, <lemma>
, <definition>
, or <axiom>
, then the numbers will be unambiguous and the target of the cross-reference will contain full information. But note that if you mix in divisions, or perhaps figures, as reasons then there is a possibility that numbers will need to be qualified by their type. We have provided an abbreviation for one cross-reference to Theorem 2.1 (which will not benefit from automatic translation to other languages).
github.com/mathjax/MathJax/issues/2704
Subsection 7.5 Local Tags on Equations
If you are not writing a research monograph, maybe (a) you will not use many numbered equations, or do not like the looks of them, or feel they scare your readers, and (b) maybe your cross-references are always local-ish, like strictly within anexample
or a proof
. For this situation you can create, and employ, a “local” tag on a displayed equation. Nothing enforces the idea of what constitutes local, and there is nothing to stop you from using the same symbols more than once. With freedom comes responsibility.
Use the @tag
attribute on an mrow
, only. (Remember, you can have just one mrow
.) The behavior is identical within an md
or mdn
. The value of the @tag
attribute is a symbol name. The prefix d
means “double”, and the prefix t
means “triple”. So allowed values are
star, dstar, tstar dagger, ddagger, tdagger hash, dhash, thash maltese, dmaltese, tmalteseCross-references to these tagged equations happens in the usual way and should behave as expected.
Subsection 7.6 Commutative Diagrams
This diagram is authored by Tom Judson using the syntax of the AMS LaTeX “CD” package. Inside of a<me>
element start with \begin{CD}
. Remember to escape the less-than character.
Subsection 7.7 Line-Breaking after Mathematics
As of 2021-05-14, in HTML output the next sentence should just fill a full line across the page. We take active measures to bind the concluding period to the final bit of mathematics, the variableSection 8 Entering Text in Paragraphs, Titles, Captions
Subsection 8.1 Special XML characters
One of the goals of PreTeXt is to relieve an author of managing the numerous conflicts when mixing languages that use different characters for special purposes. But, of course, XML has its own special characters. If you type a “less-than” symbol in your source, the XML processor thinks you are starting an opening, or closing, tag. So how do you get a less-than sign into your source so that it survives into your output, like this: < ? You use an escaped version. Type literally, the four characters<
in your source. Then the XML processor will know you want the character and will not mistake it for a tag. But now we want to get an ampersand into our source like: &. How? Another escaped version of a character, literally the five characters &
.
Otherwise, keys on your keyboard, even international versions, should be fine in your source and behave as expected. WYTIWYG = What You Type Is What You Get. So the principal concession to using XML markup is the following very simple rule.
Simple. And it will work in “running text,” verbatim text (like when authoring the content ofRather than pressing the < and & keys on your keyboard, instead always enter the escape sequences
<
and&
as replacements.
<c>
or <pre>
elements), and mixed into LaTeX syntax to desribe mathematical expressions. XML has three other escape sequences >
, '
, and "
, for the characters >, ', and " (respectively). But they seem largely unnecessary for authoring in PreTeXt, as we now demonstrate by typing them directly from our keyboard into our source: >, ', and ".
Checkpoint 8.1.
How was &
authored? Work it out, and then check the source here for the answer.
Subsection 8.2 Quotations
The<q>
tag will provide beginning and ending double quotations, while the <sq>
tag will behave similarly but provide single quotes. Given the complexity of quotations, the different symbols used in different languages, and the over-simplified versions provided on keyboards, it is necessary to use markup.
“The roots of education are bitter, but the fruit is sweet.” (Aristotle)
‘It is always wise to look ahead, but difficult to look further than you can see.’ (Winston Churchill)
A large quote can be accomodated with the <blockquote>
tag, which can carry within itself an <attribution>
element.
We say that again, to test a multiline attribution of a block quotation. Notice how the dash appears automatically, and that it is a quotation dash in HTML, distinct from other sorts of dashes.The problem with writing a book in verse is, to be successful, it has to sound like you knocked it off on a rainy Friday afternoon. It has to sound easy. When you can do it, it helps tremendously because it's a thing that forces kids to read on. You have this unconsummated feeling if you stop.
―Dr. Seuss
Sometimes a quote may extend across several paragraphs. Or a balanced pair of quotations marks crosses an XML boundary, so we need left, right, single and double versions. (For example, see Section 25 on poetry.) Here are all four in a haphazard order: ”, ‘, “, ’. These should be a last resort, and not a replacement for theThe problem with writing a book in verse is, to be successful, it has to sound like you knocked it off on a rainy Friday afternoon. It has to sound easy. When you can do it, it helps tremendously because it's a thing that forces kids to read on. You have this unconsummated feeling if you stop.
―Dr. Seuss
Children's Author
q
and sq
tags. The left/right versions are used for the following quote from Abraham Lincoln, which we have edited into two paragraphs.
“I am not bound to win, but I am bound to be true. I am not bound to succeed, but I am bound to live by the light that I have.
I must stand with anybody that stands right, and stand with him while he is right, and part with him when he goes wrong.”
And as a tests, we try some crazy combinations of quotes, which would normally give LaTeX some trouble where the quotation marks are adjacent.
“we use ‘single quotes inside of double quotes’”
‘“double quotes inside of single quotes” with more’
“‘single quotes tight inside of double quotes’”
‘“double quotes tight inside of single quotes”’
An “‘‘“absurd test”’’” of two adjacent single quotes inside a pair of double quotes
you would never do this, but a ‘‘pair of single quotes’’
Subsection 8.3 Groupings
It is possible to make some other groupings like quotations, such as {some emphasized text grouped within braces}, or [a Book Title inside brackets], an “Article Title”, 〈some foreign words inside angle brackets〉, or ⟦just a bit of text within double brackets⟧. Some of these are used extensively by scholars who study texts to note various restorations or deletions. Note that the<foreign>
element may have a xml:lang
attribute.
Note that the angle brackets, 〈 and 〉, are not the keyboard characters, < and >. Your best bet is to use the provided <angles>
element when constructing a balanced pair. Similarly, <dblbrackets>
is provided to make the double-bracket characters easily available, since they are likely not on your keyboard.Subsection 8.4 Characters, Symbols, and Constructions
Some keyboard characters are ambiguous. Is the character'
an apostrophe or a right single quote? We presume the former, ', and provide markup as an alternative for the latter (described above). Is /
used to separate words, or to form a fraction? We presume the former, /, and provide <solidus/>
, ⁄, for the latter. We test some other characters straight from our US keyboard (with two being escape sequences).
~ ` ! @ # $ % ^ & * ( ) _ - + = [ ] { } | \ ; : ' " , < . > ? /
And again as verbatim text.
~ ` ! @ # $ % ^ & * ( ) _ - + = [ ] { } | \ ; : ' " , < . > ? /
Note that for a long time PreTeXt had empty elements for many of these characters, as a consequence of naïveté. So you might see <dollar/>
, <ampersand/>
, or others in old source. They will be deprecated and will raise warnings.
Now, when a character is nowhere to be found on your keyboard, we provide conveniences as markup. Or a keyboard character may have a different variant which we implement as an empty element. Here we test many of these. Read the Author's Guide for tags and more detail.
© ℗ 🄯 ® ™ ℠ … · ⁓ ‰ ¶ § − × ⁄ ÷ ±
There are a few common abbreviations of Latin phrases that can be achieved in HTML one way, and in LaTeX with a slightly different mechanism. These are due to LaTeX's treatment of a period (full stop), depending on its surroundings. So not reserved characters, but just divergent treatment. Using these will lead to the best quality in all your outputs. See Will Robertson's informative and arcane blog post on the topic if you want the full story for the treatment of a full stop in LaTeX.
Tag | Realization | Meaning |
ad |
AD | anno Domini, in the year of the Lord |
am |
AM | ante meridiem, before midday |
bc |
BC | English, before Christ |
ca |
ca. | circa, about |
eg |
e.g. | exempli gratia, for example |
etal |
et al. | et alia, and others |
etc |
etc. | et caetera, and the rest |
ie |
i.e. | id est, in other words |
nb |
NB | nota bene, note well |
pm |
PM | post meridiem, after midday |
ps |
PS | post scriptum, after what has been written |
vs |
vs. | versus, against |
viz |
viz. | videlicet, namely |
emdash.space
can be set to none
or thin
to control this.Subsection 8.5 Currency
For best results, be certain the right Unicode characters are in your source. If you only need a certain symbol rarely, you can enter it in your source via its Unicode number. For example, to obtain a peso, type₱
. This table has been tested with our default fonts, and should be fine for HTML output. Please report any difficulties with different LaTeX fonts, as there are extra measures we can take to make these more robust. (We've already done this for the Paraguayan guaraní.)
Sign | Unicode | Name |
$ | U+0024 |
dollar |
¢ | U+00A2 |
cent |
£ | U+00A3 |
sterling |
¤ | U+00A4 |
currency |
¥ | U+00A5 |
yen |
ƒ | U+0192 |
florin |
฿ | U+0E3F |
baht |
₡ | U+20A1 |
colon |
₤ | U+20A4 |
lira |
₦ | U+20A6 |
naira |
₩ | U+20A9 |
won |
₫ | U+20AB |
dong |
€ | U+20AC |
euro |
₱ | U+20B1 |
peso |
₲ | U+20B2 |
guarani |
Subsection 8.6 Icons in Text
A limited supply of icons can be used when explaining how to use some computer application. The empty element is<icon/>
and the attribute is @name
.
We sprinkle a few into a few sentences to check baselines and font sizing. We sprinkle a few into a few sentences to check baselines and font sizing. We sprinkle a few into a few sentences to check baselines and font sizing. We sprinkle a few into a few sentences to check baselines and font sizing.
Name | Icon | Name | Icon | Name | Icon |
arrow-down |
arrow-left |
arrow-right |
|||
arrow-up |
file-save |
gear |
|||
menu |
wrench |
Have a Unicode character representation.
Be in the HTML/CSS/JS Font Awesome catalog.
Be in the LaTeX
fontawesome
package.Have a reasonably semantic PreTeXt name.
Warning 8.4. Icons, xelatex
, and Fonts.
When processing a LaTeX file with xelatex
the FontAwesome icons are expected to be in a system font whose name is FontAwesome
. This is not a filename, and installing the LaTeX fontawesome
package into your LaTeX installation does not mean you have made this font available as a system font.
The Publisher's Guide contains some discussion about installing fonts into a system, as part of the documentation of creating a LaTeX style, and has particular warnings about only using the LaTeX fontawesome
package as a vehicle for installing and accessing these fonts.
Subsection 8.7 Keyboard Keys
Your text can include specialized text meant to look like a key on the keyboard of a calculator or other device. So you can go b Enter < or F1. Or maybe a sequence as: Tab > Ctrl > T. Use the<kbd>
element, with the label of the key as content.
There is a growing supply of keys which are labeled with graphics rather than text, such as a left arrow ←, right arrow →, up arrow ↑, down arrow ↓, and Enter ⮠. See The PreTeXt Guide for the definitive list. In 8.5 the literal column means the symbol/character is the content of a <kbd>
element, while the named column means the symbol/character has been chosen via the value of the @name
attribute of an empty <kbd/>
element.
Literal | Named | |
Ampersand | & | & |
Less than | < | < |
Greater than | > | > |
Dollar | $ | $ |
Per cent | % | % |
Open brace | { | { |
Close brace | } | } |
Hash | # | # |
Backslash | \ | \ |
Tilde | ~ | ~ |
Circumflex | ^ | ^ |
Underscore | _ | _ |
~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | _ | + | |
Tab | Q | W | E | R | T | Y | U | I | O | P | { | } | | |
CapsLock | A | S | D | F | G | H | J | K | L | : | ' | Enter | |
Shift | Z | X | C | V | B | N | M | < | > | ? | Shift |
` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | |
Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ |
CapsLock | a | s | d | f | g | h | j | k | l | ; | ' | Enter | |
Shift | z | x | c | v | b | n | m | , | . | / | Shift |
Subsection 8.8 URLs, such as http://example.com
An internet URL can contain a limited subset of keyboard characters. So we include a long URL for testing: www.pcc.edu/enroll/registration/dropping.html#withdraw. Notice in the source that you do not put any tags inside the href
attribute, but you may need to provide XML escape sequences, see 8.1). Here is a totally bogus URL, which contains every possible legal character, so if this fails to convert there is some problematic character. In order to test the use of a percent sign (%
) in a URL, we follow it by two hex digits, specifically, 58
, which is a way to represent the character X
in a URL. Three versions: one with the content as normal text, one with the characters as verbatim text, and then as a URL with the same string of characters as the address and the clickable, viewable part.
The source of the four above examples can be instructive.ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%-._~:/?#[]@!$&'()*+,;=
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789%-._~:/?#[]@!$&'()*+,;=
Four ampersands need to be authored as
&
: twohref
attributes and two strings of verbatim text.Two ampersands are authored as
<ampersand />
: two strings of normal text.
url
has no content, then its href
attribute is displayed as the text, automatically in a typewriter font.
We are not fans of footnotes, they are totally unstructured. 1 A URL in a footnote migrates around, and so care must be taken. 2 This paragraph has two footnotes, one with a real URL from Jesse Oldroyd, another with a fake URL from the above suite (the fourth one). For good measure, we repeat the URL found in the first footnote: Carleson's Theorem. And we include a no-content version of the same link:
https://en.wikipedia.org/wiki/Carleson%27s_theorem
.
Subsection 8.9 Biological Names
Thetaxon
element can be used all by itself to get an italicized scientific name, as in Escherichia coli. It can also be structured with the elements genus
and species
, as in using both together in Cyclops kolensis. Or the subelements can be used individually. Rules for capitalization are presently your responsibility as an author. Possible improvements include new subelements, attributes for database identifiers, and checks on capitalization. Also, we might automatically abbreviate the genus after first use.
There is an attribute, @ncbi
that you can use on the taxon
element to precisely identify the organism you are discussing using an identification number from the National Center for Biotechnology Information. Their taxonomy is at www.ncbi.nlm.nih.gov/taxonomy
. Right now, we do not do anything with this attribute, but things like links are certainly possible. See the source of this document to see it in use with Drosophila miranda which could be used to construct a link to further information via id number or even further information via just the name.
Subsection 8.10 Verbatim in titles, \a&b#c%d~e{f}g$h_i^j
, OK
You can test the migration of the LaTeX special characters in this section title by requesting a 2-deep Table of Contents with --stringparam toc.level 2
.Subsection 8.11 Special Situations
Sage defines a nice syntax for generators of algebraic structures, but we must remember to use an escape sequence for the < symbol (see Subsection 8.1).xxxxxxxxxx
P.<t> = ZZ[]
P
xxxxxxxxxx
R = ZZ['u']
u = R.gen(0)
(u, R)
<![CDATA[
]]>
. It should be possible to write without ever using the “CDATA” mechanism, but it might get tedious in places to use the supplied macros or XML escape sequences. This construction is often mis-understood as a solution better remedied by reading Subsection 8.1 again.
We test the three pre-defined LaTeX macros for &, <, and > with a pair of aligned equations:
Subsection 8.12 Jupyter Notebook, Markdown, MathJax, Delimiters
A Jupyter notebook allows a mix of HTML (our logistical preference for a conversion) and Markown (another set of special characters and their escaped versions). Certain pairs of delimiters, when appearing in consecutive HTML<code>
elements require extraordinary care. But the one nut we cannot crack is pairs of dollar signs. So the next paragraph is known to render badly in a Jupyter notebook, but should otherwise be a bit boring.
$
and $
Subsection 8.13 LaTeX Characters, Ligatures, and More
This section is just for testing, and the more you know about LaTeX, the more we would encourage you to not to read this. Look to the Author's Guide for the right way to author your source. The ten reserved characters, directly in the source: # $ % ^ & _ { } ~ \. And again: X#X$X%X^X&X_X{X}X~X\X, but smashed up tight to intermediate characters. In a verbatim presentation:# $ % ^ & _ { } ~ \
.
And X#X$X%X^X&X_X{X}X~X\X
. (These verbatim versions are authored in different paragraphs to work around the Jupyter notebook bug described above.)
We also disrupt certain constructions from LaTeX. Attempting to sneak-in any traditional macro for the purposes of LaTeX-only output, such as, say a \newpage, will fail since the leading backslash will be caught and converted to \textbackslash
. (See? It just happened twice.) For technical reasons we want to particularly test \textbackslash, \textbraceleft, and \textbraceright.
Four “TeX ligatures”, --
, ---
, ``
, and ''
, authored in running text, --, ---, "
, to not morph into some other character: " .
More testing: runs of hyphens. Such as: - (one), -- (two), --- (three), ---- (four), ----- (five), ------ (six), ------- (seven). Use the empty elements <ndash/>
and <mdash/>
for the longer dashes/hyphens.
Runs of apostrophes should not become smart right double quotes: ' (one), '' (two), ''' (three), '''' (four), ''''' (five), '''''' (six), ''''''' (seven). You might want to cut-and-paste these into a text file to convince yourself there are the right number of characters. Here are two smart right double quotes, separated by a non-breaking space, for visual comparison: ” ”. Or 30 apostrophes on a line of their own (longer) followed by 15 smart right double quotes (shorter).
''''''''''''''''''''''''''''''.
”””””””””””””””.
Runs of backticks (accent grave) should not become smart left double quotes when the output is processed by LaTeX: <solidus/>
character for super-simple text fractions like 7⁄32 (which will not line-break), and math elements or SI unit markup for technical work.
A/test/of/some/short/words/that/go/off/the/end/of/a/line/A/test/of/some/short/words/that/go/off/the/end/of/a/line/A/test/of/some/short/words/that/go/off/the/end/of/a/line/A/test/of/some/short/words/that/go/off/the/end/of/a/line/A/test/of/some/short/words/that/go/off/the/end/of/a/line.Subsection 8.14 HTML and accidental mathematics
We render mathematics in web pages with the fantastic MathJax Javascript library. Simplifying just a bit, it recognizes LaTeX syntax within a page, takes control of that text, and replaces it wth nice fonts and formatting. Now, if you write about LaTeX you might well have some mathematics in your examples. Best practice would be to use verbatim text for that, and we mark off such text as being off-limits to MathJax. But if you are writing running text, then you can (accidentally) author some text which MathJax recognizes and converts to something (unintended). And if you are doing this intentionally, then you have ignored PreTeXt markup for mathematics, and are missing out on some features. A few tests that we can prevent any accidents. Inline mathematics: \(x^2\). Display mathematics: \begin{align}x^2+y^2=z^2\end{align}Section 9 Graphics
Subsection 9.1 Images from External Sources
If you have raster images (photographs, etc.) then they are specified with complete filenames, as above in Figure 5.2 or just below.
commons.wikimedia.org
1 , CC-BY-SA-2.0commons.wikimedia.org/wiki/File:NZ_Landscape_from_the_van.jpg
pdf2svg
works well for converting PDF to SVG. In this case, specify your source as a filename, but leave off the file extension, and the appropriate version will be used for the current output format.
The image below is provided from a PDF file in LaTeX output, and was converted to an SVG for use with the HTML output. It has been explicitly scaled to a width of 65% of the text width.
www.texample.net
Remark 9.3. Footnote Buried.
Nested tcolorbox
(in LaTeX conversion) need special care when footnotes are interior.
A paragraph interior to a sidebyside
with a footnote 2 buried inside the paragraph.
A second paragraph, just to avoid a one-panel warning.
The final paragraph of this remark, randomly placed, to test footnotes in LaTeX conversions.
Subsection 9.2 LaTeX images
There are several graphics engine packages that a LaTeX document can employ. Code from these packages renders diagrams automatically as part of normal processing of LaTeX files. For HTML output thepretext
script produces SVG versions of the pictures. The script can also produce standalone TeX source files, PDFs, PNGs, and EPSs. The packages should be loaded in docinfo/latex-image-preamble
, which is also where global package settings should be made. If any ampersands occur in your LaTeX code you should use the \amp
macro pre-defined by PreTeXt. These first examples are from the TeXample.net site. Note that any LaTeX macros used in the rest of your document may be employed in the LaTeX-standalone or Asymptote diagrams (with this feature coming to Sage graphics next?).
docinfo/latex-image-preamble
. Here, it is used. Also, here we demonstrate using \amp
where you would normally use an ampersand in LaTeX. There are known issues with xelatex
processing any gradient shading in tikz
. To (successfully) create the gradient shading in the 3D image here, you may need to use pdflatex
until LaTeX developers resolve this issue.
data
is the directory and hodgkin-huxley-data.dat
is the file with the data points. You must place the file in a subdirectory (it cannot reside next to your source file), but that directory may have subdirectories if you have many such files and want to organize them that way. Then the --include
command-line argument to the pretext
script will manage the external files properly as it creates individual image files.
It is still your responsibility to be sure this directory of external data files follows your LaTeX output to whatever directory you use to convert to a PDF and is in the right location for the relative path given in the XML source. The discussion above only applies to generating individual image files, such as you would need for the HTML output.
pdflatex
engine. But it will work easily with the xelatex
engine. We try to keep this present sample document workable with both engines, so we have presented an example of the use of PSTricks in the xelatex
-exclusive sample document where we test obscure fonts and characters. So your best bet is to look there.
There are suggestions online that
\usepackage[pdf]{pstricks}along with
pdflatex --shell-escape *.texis workable. We could not make it happen, and a “shell escape” can be a dangerous security hole. That said, updates to this approach are welcome.
Subsection 9.3 Asymptote, 2D
The Asymptote graphics language may be placed in your source to draw graphs, diagrams or pictures. Rules for formatting code are identical to those for Sage code. For more on Asymptote seehttp://asymptote.sourceforge.net/
.
This is a simple physics diagram about levers, taken from the Asymptote documentation. In the HTML version of this article, the images are SVG's and so should scale nicely when you zoom in on the page.
Subsection 9.4 Asymptote, 3D via WebGL
Asymptote can create an HTML file that is an interactive version of a 3D shape. At this writing (2020-05-18) support via thepretext
script is evolving. Plus, you will need newer versions of Asymptote and the dvisvgm
utility to duplicate all of the results being displayed here in this testing document. The other distinction is that the author needs to provide the aspect ratio of the figure, and this should be placed on the <asymptote>
element (not on the <image>
element). Figure 9.11 is from the Asymptote Gallery 3 .
asymptote.sourceforge.net/gallery/3Dwebgl/
Key | Action |
x | Rotate around |
y | Rotate around |
z | Rotate around |
+ | Enlarge image |
- | Shrink image |
h | Return to home position |
Subsection 9.5 Sage Plots
Any of the numerous capabilities of Sage may be used to produce any graphics object, be it the simple graph of a single-variable function or some realization of a more complicated object. All of the usual rules about formatting Sage code (esp. indentation) apply, along with one more caveat. The last line of your Sage code must return a SageGraphics
object (or 3D plot). The pretext
script will isolate this last line, use it as the RHS of an assignment statement, and the Sage .save()
method will be called to generate the image, which is either a Portable Document Format (PDF) file amenable to LaTeX output, or a Scalable Vector Graphics (SVG) file amenable to HTML output. For visualizations of 3D plots, Sage will only produce Portable Network Graphics (PNG) files, which can be included in HTML pages or LaTeX output.
![A standard parabola on the interval [-2,4]](images/sageplot-parabola.png)
show()
might appear to do the right thing, it evaluates to Python's None
object and that is just what you will get. The code for Figure 9.15 illustrates creating two graphics objects and combining them into an expression on the last line that evaluates to a graphics object.


sidebyside
layout element, see Section 23.



Subsection 9.6 Inkscape Images
Inkscape 4 is a great tool for creating images. It ticks all the boxes: open source, mature, cross-platform, standards-compliant. Read much more about it in The PreTeXt Guide. In HTML output the two images below are both in SVG format. The first is “pure” SVG, while the second has embedded information that makes it easier to edit in Inkscape. You could view the source for this page in the HTML version, deduce the filename of the second image, download it, and manipulate it profitably with Inkscape. Both files are quite small, but the first is half the size of the second. In PDF the two images come from files that are identical, so nothing is being tested. The PDF version is smaller still.inkscape.org
Subsection 9.7 Copies of Images
Sometimes you want to use the same image more than once. For a raster image, you can just point to it again. You are free to wrap it in afigure
and thus change the caption. It will get a new number as a new figure, and you will need to assign a unique @xml:id
attribute. Maybe appending -copy-2
, or similar, to the @xml:id
will be helpful.

xinclude
it twice. The pretext
script will make two copies if you include the source twice, but with different names (generated from the different @xml:id
). Furthermore, with the @parse
attribute on the xinclude
element set to text
you are absolved from escaping the dangerous XML characters (see Subsection 8.1) and definitely have no need for the often mis-understood CDATA
mechanism. We demonstrate this with the sample book, since it is all set up with the xinclude
mechanism. See the two plots of the 8-th roots of unity in the complex numbers section of the chapter on cyclic groups.Subsection 9.8 Caption Testing
A caption could be as substantial as a paragraph, here we test out one such example.
pretextbook.org
. There could be some inline mathematics, such as Subsection 9.9 Captionless Images
We strongly suggest placing images within a<figure>
, as we have done above, so that you can reference them, and use the (required) <caption>
to explain what they are. However there are places, such as a <preface>
, where numbered items are not permitted. So you might want a solo image there. Or maybe graphics are an illustration of sorts, and a numbered figure feels like overkill. Or it is part of an <exercise>
or <proof>
of a <theorem>
. But notice that you cannot then use this image as the target of a cross-reference, so you may need to refer to some enclosing container.
The image can be scaled by specifying the @width
as a percentage, including the percent-sign (%). The height is scaled to preserve the aspect ratio. There is no facility to change the height, it is your responsibility to manage the aspect ratio independently. The @margins
can be given as a pair of percentages, separated by a space. The @width
defaults to 100%, while @margins
defaults to the value auto
, which will center the image. Missing values are computed sensibly, and there is robust error-checking. The layout control here is a subset of what is available for the more elaborate <sidebyside>
element, see Section 23.
Two simple examples. The first has width 10%
and so defaults to being centered, and the second has width 10%
and left margin of 25%
.


margins
attribute as a pair of percentages for different left and right margins. The following are laid out with two margins, with a 0% left margin and right margin (respectively).




Testing (2019-06-02).
All the images above are specified by filenames. We need to test how various options behave when incorporated into the (new) implementation for images, being introduced with solo images. Atikz
image recycled from above, now 40% width, with 40% left margin, 20% right margin.
pgfplot
image recycled from above, now 20% width, with 40% left margin, 40% right margin, and no longer legible.
![A standard parabola on the interval [-2,4]](images/sageplot-parabola-solo.png)
Subsection 9.10 Technical Details
The table below is a summary of how graphics and images are specified, constructed and manipulated. Additional processing is indicated by reference to the Python scriptpretext
. Images need to be placed relative to the LaTeX file that includes them during compilation, and placed relative to the HTML files which reference/include them. Author-provided image files may be placed in any subdirectory, and the @source
attribute should include the complete relative path with the subdirectory. Files generated by the pretext
script will be specified in the output using the relative directory images
, which can be changed using the directory.images
stringparam. There is no reason author-provided files cannot also be placed in this same directory (presuming no duplicate names). [This table is presently more readable in HTML, the PDF version will improve.]
MBX Element | Specification | LaTeX/Print | HTML | Notes |
image/@source |
full relative path, w/ extension | directly included | directly included | author-provided PNG, JPEG |
image/@source |
full relative path, w/o extension | presumes PDF | presumes SVG | author-provided |
image/latex-image-code |
LaTeX-compatible source | directly included |
SVG via pretext
|
e.g. tikz, pgfplots, xypic |
image/sageplot |
Sage code |
PDF via pretext
|
SVG via pretext
|
PNG for 3-D |
image/asymptote |
Asymptote code |
PDF via pretext
|
SVG via pretext
|
pretext
under version control, and just regenerate them periodically (see the -r
option for pretext
). As a project matures, then it makes sense to put stable files under version control for collaborators and others. In every case, managing graphics files (and other aspects of production), is much more pleasurable with a script (shell, Makefile, etc.)Subsection 9.11 Experimental Tactile Graphics
This subsection is a work-in-progress which will eventually allow some limited markup within the code for a TikZ diagram and allow the production of an SVG that can be embossed as a braille page that may be explored by a blind reader. Until that work is completed, this diagram should render nicely for other formats, such as HTML and LaTeX. In other words, right now these images are being used for development and to test that existing routines have been modified in ways that preserve the creation of this image in the usual ways. It is possible that images may be missing in HTML output or may not be consistent with current code (document or processing). The LaTeX version should be accurate, but may be meaningless. Some preliminary documentation follows the examples, none of which is guaranteed.<m>
element.
General Advice.
It is best to design your diagram without using an overall scale factor later to compensate for not doing it carefully first. The default units in TikZ are centimeters. Labels are discussed next. Scaling (magnification) as a tactile image works best if the bounding box of your diagram is determined by the bounding box of just the graphics elements. Rather than having labels extend outside the graphics bounding box to define a larger overall bounding box. This is a consequence of how TikZ scales an image (graphics scale, text does not).Accessible Labels.
In a TikZ diagram, name locations of interest explicitly, with the\coordinate
macro, such as
\coordinate (positive-y-axis) at (4,6);Both Cartesian and polar coordinates are supported by TikZ using different syntax. These names will not be seen by your reader, they are just used in the TikZ code. Then use the names of these locations for the placement of labels. A large filled circle is a good shape to use. A radius that will scale to a radius of about 3 millimeters is a good choice. You will want to move your label away from the shape so there is no overlap, and thus the radius of your circle would be a good offset. The label can move in one of eight directions:
south
, southwest
, west
, etc. Try to arrange the direction of your label so that it does not overwrite other graphics elements of your diagram—this will be confusing to a blind reader. So an example (spread over two lines) is
<label xml:id="pos-y-axis" location="positive-y-axis" direction="northeast" offset="3mm"><m>y</m>-axis</label>The
@xml:id
is not strictly necessary, but can be useful for debugging.
When producing a tactile version of this diagram, the graphics elements of the diagram will be scaled up as much as possible to fit a whole 11.5 inch by 11 inch embossable page. The content will be replaced by braille cells (which are not scaled). The braille cells will get a 4 millimeter margin all around them, which will be a no-emboss zone. Finally, the offset will be scaled along with the graphics so the label should stay off of the shape being labeled.Section 10 Demonstrations
A Simple DemonstrationSection 11 Further Reading
Subsection 11.1 Specialized Subdivisions
In a longer work you might wish to have some references on a per-chapter basis, or similar. You can make a “references” subdivision anywhere to hold bibliographic items, and you can reference the items like any other item. For example, we can cite the article below [11.4.2, Chapter R], included an indication that a specific chapter may be relevant.Exercises 11.2 Exercises
1.
No problem here, but the next two are in an “exercise group” with an introduction and a conclusion, along with an optional title. The two problems of the exercise group should be indented some to indicate the grouping.
N.B. An <exercisegroup>
is meant to hold a collection of (short) exercises with common, shared, instructions. Do not use this structure to subdivide an <exercises>
division, as you will eventually be disappointed. Instead, use the available, but under development as of 2019-11-02, <subexercises>
, which requires a <title>
.
Two Derivative Problems.
In the next two problems compute the indicated derivative.

You could “connect” the image above with the exercises following as part of this introduction
for the exercisegroup
.
2.
We cross-reference the next problem in this exercise group. For the phrase-global
form, the common element of the cross-reference and the target should be the exercises
division, and not the enclosing exercisegroup
: Exercise 3 of Exercises 11.2.
3.
Note that the previous two problems used very different notation for the function and the resulting derivative.
4.
This isn't really an exercise, but an explanation that the next <exercisegroup>
has a title and no <introduction>
, which once resulted in some aberrant formatting in LaTeX output.
Two More Derivative Problems.
Some common instructions would go here in the <introduction>
5.
We cross-reference the next problem in this exercise group. For the phrase-global
form, the common element of the cross-reference and the target should be the exercises
division, and not the enclosing exercisegroup
: Exercise 3 of Exercises 11.2.
6.
7.
Compute
8.
One of the few things you can place inside of mathematics is a “fill-in” blank. We demonstrate a few scenarios here. See details on syntax in Subsection 4.7–the use is identical within mathematics.
Inside inline math (short, 4 characters):
Inside inline math (default, 10 characters):
Inside exponents and subscripts (2 characters each). In this case, be sure to wrap your exponents and subscripts in braces, as would be good LaTeX practice anyway:
Inside inline math (too long for this line probably, 40 characters long):
-
So use inside a displayed equation
like this one.
-
Inside the second line of a multi-line display:
Exercises 11.3 More Exercises
1.
This is not a real exercise, we just want to explain that this is another subsection of exercises, which has two consecutive exercise groups.
Exercise Group.
Introduction to first exercise group.
2.
Only exercise of first group.
Conclusion to first exercise group.
Exercise Group.
Introduction to second exercise group.
Conclusion to second exercise group.
Exercise Group.
An <exercisegroup>
can have a cols
attribute taking a value from 2–6. Exercises will progress by row, in so many columns. On a small screen, the HTML exercises may reorganize into fewer columns.
5.
6.
7.
8.
Add seven to eight.
\(15\)
9.
10.
11.
12.
13.
Add seven to eight.
\(15\)
14.
15.
16.
17.
18.
Add seven to eight.
\(15\)
19.
20.
21.
22.
23.
Add seven to eight.
\(15\)
24.
This feature was designed with short “drill” exercises in mind. With long exercises, or exercises with long hints, answers, or solutions, there is a risk that the LaTeX output will have bad page breaks in the vicinity (just before) such an exercise that occupies too much vertical space. Edit, rearrange, or use fewer columns to see if the situation improves.
References 11.4 References
An online, open-source offering.
Section 12 List Calisthenics
Subsection 12.1 Lists, Generally
Useol
to make an ordered list, and ul
to make an unordered (bulleted) list. In both cases, use li
for each entry. If an entry contains more than one paragraph, then each must be wrapped in p
.
This section contains nested lists, to demonstrate how they get assigned labels (numbering, symbols). But we begin with two simple lists, demonstrating an ordered list and an unordered list. See the end of section for an example of a description list. Note in the source the optional use of a paragraph (p
) for the list items of the list of colors.
First.
Second 1 .
Third.
Red 2
Green
Yellow
Purple
<p>
element.
-
A title on a top-level item.
Level 1, first.
-
Level 1, second.
Level 2, first.
-
Level 2, second.
Level 3, first.
-
Level 3, second.
Level 4, first.
Level 4, second.
-
Title on xref'ed list item.
Level 4, third.
Level 3, third.
-
A title on a nested item.
Level 2, third.
Level 1, third.
xml:id
and then may be the target of an xref
. We test three here, referencing down into the hierarchy above. Level 1, second: 2. Level 3, second: 2.b.ii. Level 4, third: 2.b.ii.C. Note that if a list item of an ordered list is contained within a list item of an unordered list, then its number will not be defined.
And now a four-level deep unordered list with the default labels supplied by MBX (disc, circle, square, disc). Again, the defalt order for Markdown/Jupyter (disc, square, circle, circle) is different than for LaTeX and HTML (disc, circle, square, disc)
-
A title on a top-level item.
Level 1, first.
-
Level 1, second.
Level 2, first.
-
Level 2, second.
Level 3, first.
-
Level 3, second.
Level 4, first.
Level 4, second.
Level 4, third.
-
A title on a nested item.
Level 2, third.
Level 2, third.
Level 1, third.
Level 1, first.
-
Level 1, second.
Level 2, first.
-
Level 2, second.
Level 3, first.
-
Level 3, second.
Level 4, first.
-
Level 4, second.
Level 5, first.
-
Level 5, second.
Level 6, first.
Level 6, second.
Level 6, third.
Level 5, third.
Level 4, third.
Level 3, third.
Level 2, third.
Level 1, third.
Level 1, first.
-
Level 1, second.
Level 2, first.
-
Level 2, second.
Level 3, first.
Level 3, second.
Level 3, third.
Level 2, third.
Level 1, third.
Level 1, first.
-
Level 1, second.
Level 2, first.
Level 2, second.
Level 1, third.
Level 1, first.
-
Level 1, second.
Level 2, first.
Level 2, second.
Level 1, third. With a cross-reference to second list item, 2.
Level 1, fourth. Whose number should not change when the knowl just prior is opened.
@label
attribute, instead of numeral one.
First
-
Second
Uno
Dos
Tres
Third
Definition 12.1. Group.
There is a binary operation, denoted “
”.The operation is associative.
There is an identity element,
-
For every element
there is an element (the inverse), such that
If these conditions are met for a set
Subsection 12.2 List Spacing, I
This is a short list that ends a subsection, so can be used to address the necessary spacing. We also test two XML elements separated by a space (which should not go missing).One item.
Two ducks.
Three items. Plus a few more words to check that long entries in a two column list look good.
Four items.
Another long entry that simultaneously tests that long entries look good in a list, and also tests an odd number of entries in a two column list.
Subsection 12.3 List Spacing, II
This is another short list that ends a subsection, so can be used to address the necessary spacing.Uno item.
Dos items.
Tres item.
Quattro items.
Subsection 12.4 List items containing only inline math
Testing list items containing only math.
There are many places where it makes sense to have a list of mathematical terms, or possibly equations. For example, one might wish to provide a list of derivative formulas. With such lists, the author may wish to have display mathematics, but almost certainly they don't want it centered. One can work around this by using the LaTeX \displaystyle
command. However, it would be nice if a list item containing only math used display mode by default.
A list item containing some text in a paragraph, as well as some inline math:
A list item with text and math
not in a paragraph.
Now, a p
that isn't in a list, followed by a list that's in a p
.
A list item starting with some math, followed by text, all in ap
list
.
A first list item, containing some text. The next list item will contain only math, with the
m
tag inline with theli
tag.A list item with text and math
not in a paragraph.The next two list items will contain, respectively, a list item containing only math, where the math is on a new line, then the same again, but with two new lines, and a list item containing math within a
p
, first inline, and then after a line break.
-
A paragraph that begins with text, then some math:
And now some more text. The next two list items contain:Math only, inline.
Math only, with a newline.
Math only, but in a paragraph. Also the next item on this list has math, just to see what happens in a nested list.
-
With
\displaystyle
added automatically. -
Two paragraphs.
-
One paragraph, extra text.
So,
-
Two elements (only).
LaTeX
Subsection 12.5 Description Lists
Usedl
to make a description list. Inside of those tags, use li
for each entry. Then, use title
to specify the term being described and p
to specify the description.
A “description” list has a short term or phrase that is prominent, followed by a short description. It is modeled on the lists of similar structure in both LaTeX and HTML. It makes for a nice medium-weight way to define terms, somewhere in-between the term
tag which just makes a term prominent in a sentence, and a definition
, which is set off, has a heading, a number, and a title. Do not try to manage the separation between the title and the description by employing punctuation (but you can include a question-mark or exclamation-point if necessary). For example, do not include a colon to the end of the title. This example is from Bob Plantz.
- Central Processing Unit (CPU)
Controls most of the activities of the computer, performs the arithmetic and logical operations, and contains a small amount of very fast memory.
- Memory
Provides storage for the instructions for the CPU and the data they manipulate.
- Input/Output (I/O)
Communicates with the outside world and with mass storage devices (e.g., disks).
- Bus!
A communication pathway with a protocol specifying exactly how the pathway is used. (The punctuation is just for testing.)
width
attribute on a dl
element with possible values narrow
, medium
, and wide
. Conversion to LaTeX ignores this attribute, and conversion to HTML only reacts to narrow
(medium
is the default, and wide
behaves identically).
- Red
The color of the sun at sunset.
- Blue
The color of a clear sky.
- Aqua
The color of shallow tropical waters.
- Math
Sorry, not a color but testing titles with math in them.
Subsection 12.6 Named Lists
A list can be wrapped with a<list>
element, so that it earns a number, can be given a title and have an introduction and conclusion. Cross-references to individual list items get a bit involved as they are prefixed with the number of the list and then the number of the item, so conceivably you could get a number like 4.5.3:2.a.ii
. The colon is used to indicate the transition from the number of the list within divisions and the numbers coming from the list hierarchy, since it has two small dots.
Because the colors are always in the same order, an ordered list is natural here. The colors change continuously, but are often divided up into large ranges that human perception can easily distinguish.
Red
Orange
Yellow
Green
Blue
Indigo
Violet
So some people use the acronym ROY-G-BIV to remember this sequence.
This is the introduction to this named list, which references an item within, via the hybrid @text
attribute: Item B.c. At one time this paragraph was inadvertently centered—that bug has been fixed.
A and i
A and ii
A and iii
B and a
B and b
B and c (target of some cross-references)
The next three cross-references point to a list item, just above. It is interesting because the list is named, hence numbered. The global reference uses the full number, while the local reference uses the number from within the list. The hybrid reference recognizes that the target is within the same named list, so the number can be shorter. An identical hybrid cross-reference appears within the
<introduction>
to this list, an immediately following, but outside the<list>
.Cross-reference within named list (
global
): Item 12.4:B.cCross-reference within named list (
hybrid
): Item B.cCross-reference within named list (
local
): Item B.cC and bullet and 1
C and bullet and 2
C and bullet and 3
C and bullet
C and bullet
@text
attribute: Item 12.4:B.c.
This is a paragraph with three lists contained within it. For HTML output we have to “inside-out” the lists.
A one item ordered list.
p
element of its own.
A one item unordered list.
- Define Me
A one item definition list.
-
Introductory text.
First item, first list.
Intermediate text.
First item, second list.
Concluding text.
Subsection 12.7 Testing List Decompositions
A list in a paragraph is a construction in HTML that browsers try to correct, which leads to unpredictable results, so we have to decompose an author's paragraph with lists into a sequence of HTML paragraphs, interrupted by lists. This subsection is only relevant to HTML output, and only for testing.This paragraph opens with an ordered list.
Testing the id, and other info that should be at the top of the paragraph.
Exercises 12.8 Exercises (with lists)
1.
This exercise should have several parts, and labels should follow the defaults for second-level lists (since the exercise is numbered according to the top-level default).
Exercise 1, first part.
-
Exercise 1, second part.
Exercise 1, second part, first refinement.
Exercise 1, third part.
2.
1111, 2222 | 3333 | |
aaaa | bbbb,cccc | |
AAAA | BBBB | CCCC |
This exercise (a list item really) has a table
first. Default LaTeX aligns it vertically above the exercise number. Placement here tests correcting that alignment.
References 12.9 References (with lists in Annotations)
Here is the annotation and an ordered list as part of that annotation.
Book 1, first part.
Book 1, second part.
Book 1, third part.
Section 13 Table Calisthenics
A very minimal table, hence with left-justified cells, no borders. We do wrap the tabular element in a table element to get centering, numbering and a caption. Footnotes inside cells are tested here.latex-tables.com
and then exported in PreTeXt syntax.
Tables can be used and abused many ways. We describe long division of polynomials by using vertical and horizontal borders on individual entries of a <tabular>
. The division lines are slightly thicker than the subtraction lines. This is a good example of the typical abuse of tables for horizontal and vertical layout. At least we have called it a “Figure,” not a “Table”.
tabular
element. The table
element may be used to enclose the raw table, so as to associate a caption and get vertical separation with horizontal centering.
The tabular
element contains a sequence of row
elements, and must contain at least one. Each row
contains a sequence of cell
elements and must have the same number in each row (acccounting for the use of the colspan
attribute). The contents of the cell
elements are the text to appear in entries of the table.
A sequence of col
elements may optionally be used. But if one appears, then there must be the right number for the width of the table. They are empty elements always, and just carry information about their respective column.
Where the body of the table below has an entry, it means the attribute may be used on the element, and affects the range of the tabular described by the element. Employment of an attribute on elements to the right in the table will supersede use on elements to the left. Generally, every cell has right and bottom borders, but only cells at the left side of the table have a left border and only cells across the top have a top border. Only one cell has four borders.
Attributes | Elements | Values | |||
tabular |
col |
row |
cell |
* = default | |
top |
none*, minor, medium, major | ||||
left |
none*, minor, medium, major | ||||
bottom |
none*, minor, medium, major | ||||
right |
none*, minor, medium, major | ||||
halign |
left*, center, right, justify | ||||
halign |
p | decimal, character | |||
header |
p | yes/vertical/no* | |||
valign |
top, middle, bottom | ||||
colspan |
1*, integer | ||||
rowspan |
p | 1*, integer | |||
width |
percentage | ||||
colors | p | p | p | p |
Bully Pulpit: Vertical Rules in Tables.
One of the goals of PreTeXt is to gently guide authors towards good choices in the design of their documents, even if we do not claim to know it all ourselves. Take a close look at that table about tables. What's missing? No vertical rules. Try living without them, you will not really miss them. If you think you need to divide a table into two halves, maybe you really need two tables (and then see the “side-by-side” capabilities, Section 23). In the documentation for his excellent LaTeX package, booktabs, Simon Fear gives two rules for what he calls “formal tables”: (1) Never, ever use vertical rules, and (2) Never use double rules. We have resisted the temptation to enforce the former and have provided an alternative to the second (three thicknesses). He refers to using tables for layout as creating “tableau.” If you are finicky about the look of your work, the first three pages of the documentation is recommended reading. That all said, we now give several examples in order to stress and demonstrate our code.1234567890 | 1234567890 | 1234567890 | 1234567890 |
[First | Second | Third | Fourth |
A | B | C | D |
1 | 2 | 3 | 4 |
1234567890 | 1234567890 | 1234567890 | 1234567890 |
First | Second | Third | Fourth |
A | B | C | D |
1 | 2 | 3 | 4 |
1 | 2 | 3 | 4 |
<tabular>
and place it directly within the current division. This will allow control over the horizontal placment, but without a caption, there is no number, and the tabular cannot be cross-referenced.
One |
1234567890 | 1234567890 | 1234567890 | 1234567890 |
First | Second | Third | Fourth |
A | B | C | D |
1 | 2 | 3 | 4 |
1 | 2 | 3 | 4 |
\leavevmode
is necessary to keep this organized (item number, then table as content).
Table 13.9. Table Alignment Example 1111, 2222 3333 aaaa bbbb,cccc AAAA BBBB CCCC
Example 13.10. Example Environment with Leading Table.
col
Elements, Nine Columns1 | 2+3 | 4 | 5+6+7 | 8+9 | ||||
1 | 2 | 3 | 4 | 5 | 6 | 7+8 | 9 | |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
This example tests several things. In LaTeX output, figures, tables, listings and side-by-sides are “floats” whose placement can migrate, but we have tries to supress this behavior. However, a float that is the first item of an “environment” (like a theorem or an example) can still float to a position before its title. If that does not happen here, then our additional defenses are working.
This example also checks that the total number of columns is correctly computed from the first row, which features several colspan
attributes.
<p>
children. And such cells should only have <p>
children. The width of a paragraph cell is determined by a width
attribute on the corresponding <col>
(as a percentage). If no width
is specified (or there isn't even a <col>
in the first place) then xsltproc
will abort. If the column has a non-paragraph cell with contents that are wider than the paragraph cells, results will be undesirable. There is presently no implementation for a paragraph cell that has a colspan
greater than colspan
greater than width
on a <col>
that has no paragraph cells may produce unexpected results. A valign
for the parent <row>
(or the ambient <tabular>
) can control vertical alignment (top, middle, or bottom). A paragraph cell's halign
attribute (left, center, right, or justify) controls how the text is justfied. Cells inherit halign
from <row>
, <col>
, and <tabular>
in that order of preference. In a non-paragraph cell where halign='justify'
, the horizontal alignment will match the behavior of halign='left'
.
Unit | Stands For | Definition | Roughly |
s | second |
the duration of 9192631770 periods of the radiation corresponding to the transition between the two hyperfine levels of the ground state of the cesium-133 atom an extraneous paragraph just to demonstrate the inter-paragraph formatting. |
the time it takes you to say the phrase “differential calculus” |
min | minute | exactly |
how long it takes to microwave a full dinner plate from the refrigerator |
h | hour | exactly |
the length of one episode of a premium cable television show |
<line>
elements. This is not the same thing as a paragraph cell—line breaking will happen precisely where the author tells it to. A <line>
will not break, even on a narrow screen. If a cell uses a <line>
, it must only use a sequence of <line>
s and no other content. As with paragraph cells, you can use a valign
attribute for the row.
One Fish Two Fish Red Fish Blue Fish |
I am the Lorax. I speak for the trees. Self-referential: Table 13.14 |
Look at me! Look at me! Look at me NOW! It is fun to have fun. But you have to know how. |
halign
, valign
, colspan
, <p>
children, and <line>
children.
Cell too wide | ||||||||
Lf md | Lef mid par cel |
Rt md | Rig mid par cel |
Cn md | Cen mid par cel |
Js md | Jus mid par cel jus mid par cel |
|
Colspan=2 lef mid with lines |
Colspan=3 rig mid | Lines Between Par |
Lines Between No Par |
Par in row with lines |
|
|||
L t | Lef top par cel |
R t | Rig top par cel |
C t | Cen top par cel |
J t | Jus top par cel jus top par cel |
|
L b | Lef bot par cel |
R b | Rig bot par cel |
C b | Cen bot par cel |
J b | Jus bot par cel jus bot par cel |
|
Colspan=3 lef bot | Colspan=2 rig bot with lines |
Lines Under Par |
Lines Under No Par |
Par in row with lines |
|
<sidebyside>
with a <table>
and a <tabular>
to check that width is scaled appropriately. See Section 23 to learn about <sidebyside>
s.
A1.S1 |
All legislative Powers herein granted shall be vested in a Congress of the United States, which shall consist of a Senate and House of Representatives. Should be 50% of 45% except perhaps on small screens. |
A1.S2.C1 |
The House of Representatives shall be composed of Members chosen every second Year by the People of the several States, and the Electors in each State shall have the Qualifications requisite for Electors of the most numerous Branch of the State Legislature. Should be 50% of 55% except perhaps on small screens. |
\multicolumn
macro to override more global alignment settings, and to spread the content of one cell across several columns. However, sometimes LaTeX's special characters have behaved badly in this situation. So the table below, two items per row, is just designed for LaTeX testing. But of course, it should still render fine in other formats. The three test cases are from 8.8, but without 50 alphabetic characters and 8 digits, which should not be problems in this context. In order to test the use of a percent sign (%
) in a URL, we follow it by two hex digits, specifically, 58
, which is a way to represent the character X
in a URL. The first column's entries are forced to be wrapped in a \multicolumn
by specifying their horizontal alignment. The second column's entries will not be wrapped in a \multicolumn
.So the two columns will look identical, other than the first having a left alignment, and the second has the default center alignment. (This table is known to render poorly in a Jupyter notebook. The cause is four dollar signs present in rows 1 and 3, and is explained in Subsection 8.12.)
1 | 09az%-._~:/?#[]@!$&'()*+,;= |
09az%-._~:/?#[]@!$&'()*+,;= |
2 | http://example.com/09az%58-._~:/?#[]@!$&'()*+,;= | http://example.com/09az%58-._~:/?#[]@!$&'()*+,;= |
3 | http://example.com/09az%58-._~:/?#[]@!$&'()*+,;= |
http://example.com/09az%58-._~:/?#[]@!$&'()*+,;= |
State | Population | Area (sq. mi.) | Statehood (Year) |
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area | Statehood |
---|---|---|---|
(sq. mi.) | (Year) | ||
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area | Statehood |
---|---|---|---|
(sq. mi.) | (Year) | ||
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area | Statehood |
---|---|---|---|
(sq. mi.) | (Year) | ||
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
Section 14 Interactive Elements, Authored in Javascript
Subsection 14.1 HTML5 Canvas
HTML5 introduced the<canvas>
element, which can be thought of a blank slate, a place to draw or write on. So PreTeXt has the <slate>
element for a similar purpose. Generally, but not exclusively, HTML5 writes on a <canvas>
using the Javascript language. We demonstrate this approach to interactive diagrams in this subsection.
The following examples are from David Austin's excellent Understanding Linear Algebra textbook, which can be found at
merganser.math.gvsu.edu/david/linear.algebra/ula/index.htmlDavid's contribution of examples, and assistance designing the PreTeXt elements is greatly appreciated. Alright, let's learn some linear algebra. Yes, there are some learning opportunities in this subsection.
Let
Checkpoint 14.2.
The interactive in Figure 14.1 shows a vector \(\vec{x}\) in red, and the matrix-vector product \(A\vec{x}\) in grey, for a particular \(2\times 2\) matrix \(A\text{.}\) The four entries of the matrix \(A\) are coded into the interactive. Can you deduce \(A\) simply by using the interactive? Which theorem is the key?
Let
<slate>
elements communicating with each other, and arranged with the layout features of a <sidebyside>
(see Section 23).
Parameters
Warning 14.5.
If your <interactive>
employs a <slate>
with a @surface
attribute whose value is html
, then you are advised to augment each top-level (HTML) element within the <slate>
with the attribute:
xmlns="http://www.w3.org/1999/xhtml"
This will identify all of the elements within the <slate>
as HTML elements and not as PreTeXt elements. The danger is that elements with the same name in both languages, such as <li>
and <table>
, will be mis-identified. This could be harmless, but could also create chaos, such as disrupting numbering of PreTeXt elements.
See the source code of this document for examples: Figure 14.4 Figure 14.11, Figure 14.15.
Note that the HTML that is output can vary slightly from your source in small, harmless ways, such as empty (self-closing) elements being output with both an opening and a closing tag. Please report any significant discrepancies. Soon this requirement will be enforced in the code.
<figure>
is comprised of four <stack>
elements within a <sidebyside>
. By varying the time in the top box, the reader can observe the displacement, velocity, and acceleration of a ball thrown upward with an initial velocity of 30 m/s.
Use the time slider in the top panel to vary the time from 0 sec to 6 sec. Observe how the displacement, velocity, and acceleration vary with time.
Subsection 14.2 D3.js
D3 is a Javascript library for “Data-Driven Documents”, which might greatly enhance some data you wish to display. In short, it uses the animation capabilities of SVG. Available examples seem sensitive to the version of the library, so we have examples using different versions. Use the@version
attribute on <interactive>
to specify the version number. The default is 5
.
The first example uses the force layout and collision detection from Version 3. (The necessary commands are very different in Version 4.) Pretend you are a working shepherding dog. Can you separate, and catch, one of the herd?
This is adapted from a block by Mike Bostock at 3231298
with a GPL license. A similar demonstration, only using an HTML5 canvas is at bl.ocks.org/mbostock/3231307
.
Place your mouse/pointer at the center of the interactive to repel the 200 circles.
We have changed the size of the nodes, and their number, to fit in a smaller space.
The Javascript script uses introspection to size itself, which would be a good general practice.
e6209de87cdddde38dadbb746feaf3a3
with a GPL license.
Drag a vertex to a new location to see the graph adjust its layout.
Checkpoint 14.9. Graph Planarity.
Can you move the vertices to new locations such that the resulting graph is planar? (In other words, no edges cross?)
7aa53c7bf3e411238ac8aef280bd6581
, provided with an MIT License.
Technical notes:This visualisation uses a D3 force simulation to show the Twitter relationships between the Assembly Members in the Welsh Assembly in terms of the number of times each assembly member has mentioned another assembly member in a tweet.
Twitter relationships were mined on 22/03/2017, and are representative of the conversational relationships on that date. Links between AMs represent a conversational relationship: one AM has mentioned the other. Party colour indicates the direction of the mention.
Hover over the nodes to fade out non-connected nodes.
Rather than using intermediate nodes to create curved links (as in Mike Bostock's block), this adds curves by adding a calculated control point for each edge.
Once the nodes organize themselves (automatically in the beginning), they cannot be moved.
We have adjusted the margins in an attempt to keep names visible on the right side, but without giving up too much space.
We have adjust the repelling force, and the collision buffer, to better fit the available space.
This example required its own CSS, which we have included as part of the
<interactive>
.The data collected from the Twitter analysis is contained in a JSON file,
mention_network.json
, and where the script loads that file, it has a hardcoded path. So this example is a bit brittle, should that file move.
Hover on the name of an Assembly Member to concentrate on their tweet mentions.
Subsection 14.3 SVG
Entirely similar to using an HTML5canvas
element (14.1), it is possible to control an SVG element with Javascript. This example is from Mark McClure.
Look carefully at the source and rendering of this example as HTML. The change in $...$
nor by \(...\)
, but instead by using <script>
tags that MathJax recognizes. So the employment of MathJax here is accomplished with
<script type="math/tex">h = </script>
Select a function with the radio buttons, then use the checkbox to add the secant line. The denominator of the difference quotient,
Checkpoint 14.12. Changing Secant Lines.
When discussing the derivative as a limit, we think of the point of tangency as being fixed (the green point in 14.11) and the “other” point defining the secant line as changing (the red point in 14.11). Switch it up! Fix a large value of \(h\) (positive or negative) and then change the point of tangency (the green point). Discuss what you observe.
Subsection 14.4 JSXGraph
JSXGraph is a “cross-browser JavaScript library for interactive geometry, function plotting, charting, and data visualization in the web browser.” Now a<slate>
will be what JSXGraph calls a board. Again, you use Javascript to write onto a <slate>
, but have some powerful shortcuts available from the JSXGraph library. For this reason, PreTeXt calls JSXGraph a “language”, similar in may respects to how Sage is a language, but is really a Python library. So realize that the syntax for using JSXGraph is that of Javascript.
Place Javascript inside a file that is specified with the @source
attribute of the <interactive>
element. Then just be certain that @xml:id
of the <interactive>
element is passed as the HTML id
in an (early) call to JSXGraph's initBoard()
method.
The plot below is the curve Drag the sliders to change the parameters
Drag the sliders to change the pattern, and drag any of the four red corners to change the overall shape.
sidebyside
layout element with equal widths (see Section 23) so they can be placed horizontally across the page. They are not wrapped as figures, so cannot be cross-referenced. These are again from the example wiki, the left being Fermat's Spiral and the right being a demonstration of B-splines.
Drag the slider to change the curve.
Any of the 8 red control points may be moved anywhere.
sidebyside
layout element.
The slider of the left panel will trace out the piecewise function. Simultaneously, the domain will be traced in the middle panel, and the range in the right panel.
iframe
to sandbox (isolate) it from other interactives. We does this for your own protection. So, for example, one interactive cannot talk to another. If two <slate>
need to communicate, then they are related, and should be placed into a single <interactive>
, allowed to layout themselves, or grouped within a <sidebyside>
allowing finer control. Even if we have this under control, you might still enjoy reading Your JS is a Mess at mikecavaliere.com/your-js-is-a-mess-javascript-namespacing/
.Subsection 14.5 JessieCode
JessieCode is a scripting language for JSXGraph. It provides the core geometric and graphing features of JSXGraph without accessing the underlying JavaScript. In order to use JessieCode, you simply create the HTML<div>
element as you would for any other JSXGraph interactive plot and then provide the JessieCode script, which focuses on the geometric elements.
Because JessieCode is provided by JSXGraph, the interactive platform is jsxgraph
. The <slate>
, however, uses @surface="jessiecode"
. The script can be embedded directly in your code. As usual, you would need to remember to escape the special characters. JessieCode uses <
and >
for inequalities as well as for declaring objects used to style geometric elements, and &&
is the boolean AND operator. Alternatively, you can provide the file as a separate resource, providing the URL with a @source
attribute. Attributes defining the JSXBoard at the time it is created should be included as attributes of the <slate>
, including @boundingbox
, @axis
, and @grid
.
For this first example, the JessieCode was included directly in the XML source as the contents of the associated slate.
Use the sliders to set the parameters of the quadratic
Drag the point
Subsection 14.6 Sage Interacts
Sage, and the Sage Cell Server, support interactive demonstrations, called interacts.The interactive elements are nearly trivial to construct.
An interact is simply a single Python function (acted on by a decorator).
You have the full mathematical power of Sage at your disposal, so can do some very powerful computations with high precision (or exactly).
The interface is not as polished as what you can achieve with Javascript libraries.
Graphics refresh with a round-trip to the server, so are not nearly as fluid as with other tools.
wiki.sagemath.org/interact/calculus
, specifically here.
Subsection 14.7 Geogebra
To embed a GeoGebra applet as-is from GeoGebra's Classroom Resources site (by material ID), see Subsection 15.1. To design your own applet (either from scratch, or modifying something that already exists in one of those three forms) you may use one of Geogebra's “Apps” to embed the material in your document. (But note, use of the App comes with licensing restrictions.) PreTeXt will handle most of the technical details for you. Do one of the following:Identify a material ID from GeoGebra's Classroom Resources site. You might even make the material yourself on that site.
Obtain a
.ggb
file from GeoGebra. You might construct something on a desktop installation of GeoGebra and save it. If you have a base64-encoded string for a GeoGebra applet, but you don't have a.ggb
file, you can decode the string and save the result. For example, at www.opinionatedgeek.com/codecs/base64decoder.Obtain a base64 encoded string for a GeoGebra applet. You might first open a
.ggb
file in a desktop installation of GeoGebra, and push ctrl-shift-B (command-shift-B on a Mac) and then the string will be in your clipboard.None of the above, with the intention to make an applet from scratch.
ggbApplet.
or applet.
used in examples to prefix the functions—that part of the code will be provided automatically by PreTeXt.
Jack Green created an applet on the Classroom Resources site with ID D4s2v4ft
, which you may view at geogebra.org/m/D4s2v4ft. Suppose you would like to use this in your project, but change something about it. We will change something trivial, making the @width
and @aspect
attributes to resize the viewing window using the top left corner as an anchor. This does not rescale axes and that may leave you with important elements missing from the viewing window. So here we reset the viewing window to return to values that are in the original. Lastly, we disable zooming, which is not helpful for this applet. To do each of these things, we rely on the GeoGebra API manual at wiki.geogebra.org/en/Reference:GeoGebra_Apps_API. It is important to use one command per line.
.ggb
file. Here we use two provided by David Rosoff, and one provided by Tevian Dray. The path to the file needs to be relative. First, David's original.
.ggb
file.ggb
file.ggb
fileDrag some of the points and some of the circles to change them, and watch the remainder react.
.ggb
file. You might come across such a string somewhere, or you might generate one by opening a .ggb
file in a desktop installation of GeoGebra, and pushing ctrl-shift-B (command-shift-B on a Mac) to get the string in your clipboard. If you do this, you could use a @base64
attribute in place of the @source
attribute in the previous example. We don't do that here because such a string is generally over 5000 characters long and we are keeping the sample article source a bit cleaner.
Lastly, you may just wish to build something from scratch using GeoGebra API. Note that for accessibilty reasons, some objects are rendered unselectable with the setFixed
command. Perhaps this should have been done with the previous examples, but that is more difficult when you do not know all of their names.
Subsection 14.8 threejs
An example using thethreejs
3D Javascript library. This is one of the project's examples 1 , licensed with an MIT License, with minimal modifications. We get several of the necessary libraries from the threejs.org
site.
threejs.org/examples/#webgl_geometry_extrude_splines
threejs
webgl_geometry_extrude_splines exampleSection 15 Interactive Elements, Server
Subsection 15.1 GeoGebra
A Geogebra material is something you might use in a class. It could also be called an interactive demonstration. Go browsing at www.geogebra.org/materials and find something appropriate for your project. Or make an account and create your own. Once you find a material that looks instructive, it will be at a URL such ashttps://www.geogebra.org/m/KGn2d4Qdand you want to pick off the identifier on the end, in this case
KGn2d4Qd
. Then author
<interactive geogebra="KGn2d4Qd" />At this writing (2018-02-04) you will want to place this inside a
figure
, with a caption, as we do right now with material KGn2d4Qd
.
The shape of the material will be fixed, so guess (or measure with an on-screen ruler), the aspect ratio and use that in the <interactive>
element.
geogebra.org
have a non-standard, non-commercial license you must agree to before you can download them as source code. Perhaps you must forfeit your copyright when you upload a material? We have not investigated this thoroughly.Subsection 15.2 Desmos Graphs
Desmos provides interactive graphing applications. The following example was created by Ann Cary and made available via the “Share” function of Desmos. You can make your own Desmos graph, choose the “Share” icon, and the “Embed” option, to get a URL such ashttps://www.desmos.com/calculator/ttox1bvxkuYou want to pick off the identifier on the end, in this case
ttox1bvxku
, then author
<interactive desmos="ttox1bvxku" width="60%" aspect="2:3" />as we have done here. The static image employed in the LaTeX version of this article was obtained by viewing the graph at the Desmos site (i.e., not the embedded version in the PreTeXt HTML version), and using the Share button to export a PNG image. In this case, we used a “Medium Rectangle” and “Thick” lines.
Subsection 15.3 CalcPlot3D
CalcPlot3D is a Javascript application for creating, visualizing, and understanding plots of 3D surfaces. So it would be an ideal companion to a book on multivariate calculus, but should be useful in other courses of study. To use it, find the online app version athttp://www.monroecc.edu/faculty/paulseeburger/calcnsf/CalcPlot3D/Create a plot and adjust the image to a viewpoint and scale you like. Then, click the menu icon in the upper-left and choose
File
. From here you can save a PNG image for the static version, but you also want to select Encode View in URL
. Now your browser address bar is filled with a query string (all the stuff after the question-mark) that has all the information necessary to reproduce your plot (and view). Copy everything after the first question-mark to the interactive/code
element. Be sure to replace any ampersands by &
(see the Author's Guide for more about certain characters in URLs). Examine the source for the examples below to see how they are authored.
In Figure 15.3 grab the image with your mouse and rotate it in various directions. Then while the image has focus, press the 3
key (short for “3-D”), to get a 3D view, which will require some red-blue 3D glasses to fully appreciate. Press the key again to return to a regular view.
Subsection 15.4 Wolfram CDF
You can embed interactive demonstrations created in Wolfram's Computable Document Format so that they will be played with the Wolfram CDF Player™. Once you create and save a demonstration, you want to determine the UUID that is the identifier of your demonstration. For example, Figure 15.7 is identified by9fa2acff-c809-4b7f-a73b-c59ace36affc
. This identifier is enough to create the PreTeXt to embed the demonstration. See https://reference.wolfram.com/language/howto/DeployInteractiveContentInTheWolframCloud.html
for information about creating your demonstration.
http://www.wolfram.com/cdf/adopting-cdf/deploying-cdf/web-delivery-cloud.html
explains hosting CDF files at the Wolfram Cloud, and is the source of Figure 15.7. You can learn about powering your CDF with Wolfram Cloud Credits at https://www.wolfram.com/cloud-credits/
. CDF is a public format, and the FreeCDF™ license is a variant of a Creative Commons BY-SA license, see http://www.wolfram.com/cdf/adopting-cdf/licensing-options.html
.
The first example here (Figure 15.6) was developed by Itai Seggev, a Senior Kernel Developer at Wolfram.
(2018-04-02) These behave as expected in Chrome, but perhaps not in Firefox. Testing welcome.
Section 16 Audio
2019-05-24: this is preliminary, and mostly based on the code for<video>
so read the next section and mimic the style from there. But use an <audio>
element and have the @source
attribute point to an OGG, MP3, or WAV file. Plus, an @aspect
attribute will be ignored.
We have not entirely decided how to handle the static version present in a PDF.
First in a <figure>
, so it can be cross-referenced.
www.kozco.com/tech/soundtests.html
)<sidebyside>
with an “Organ Finale” WAV file on the left, and on the right, Bach in OGG format at a very low bit rate (32 kps). From http://www.music.helsinki.fi/tmt/opetus/uusmedia/esim/index-e.html
.
Section 17 Video
Subsection 17.1 Video Files
Embedded videos can make sense for a web version of your document. This is a video promoting the University of Puget Sound to potential new students, in WebM format. Support is limited to HTML5-capable browsers. The file format can be MP4, Ogg, or WebM, though this may vary depending upon the browser. Use a<video>
element, within either a <figure>
(numbered, captioned) or a <sidebyside>
for more precise control. The @source
attribute in this first example does not include an extension, and so three possibilities above will be searched for preferentially (you need only provide the video in one format, but providing additional versions will increase the chances every browser will find a compatible format).
https://github.com/rbeezer/mathbook/issues/853
.) On the <video>
tag, include a @preview
attribute which is the name of an image file, including a relative path. (JPEG or PNG formats are best. JPEG may be smaller for video screenshots, while PNG is lossless and so may work better for diagrams.) The next video has a preview/poster that is a fram part way into the introduction.
preview = "generic"
.
<source>
attribute. Note that if the URL has a query string (parameters following a question-mark), then any ampersands (&) will need to be escaped, so as to not confuse the XML processor (i.e. use &
). Also, the question-mark character needs to not be URL-encoded (%3F
), so presumably edit the URL to be the character. Here are several examples, the second one uses the @start
and @stop
attributes to limit the video to just the time between the 16-second and 30-second locations, and has asymmetric margins.
camendesign.com/code/video_for_everybody/test.htm
*.ogv
extensionSubsection 17.2 YouTube
YouTube videos may be embedded with only knowledge of a video's “ID” or a “playlist ID”. A single video's YouTube ID is a string of eleven seemingly random characters that show up in the URL when you watch a video. For the Led Zeppelin performance below, the ID ishAzdgU_kpGo
, which you might normally watch directly from the URL https://www.youtube.com/watch?v=hAzdgU_kpGo
. As described just above, you need to specify a different aspect ratio if the video does not have a 16:9 aspect ratio.
Note: some of these videos may not play if viewed locally, and maybe not even if you start up a local web server (such as can be easily done with Python). So if you are testing new features, be careful about assuming videos from cloud services are not working properly.
If you have ever owned a drone, you sympathize with this guy. Way funnier than a cat video.
start
and end
attributes in seconds. You might make those times clear in the caption for readers getting the link out of a PDF. Some videos may not respect these parameters.

figure
with a title
(which is distinct from a caption
). But you can just place a video “naked” inbetween a couple of paragraphs. This is nice if you don't want the clutter of numbers, and/or if you plan to exclude videos from some edition of your document.

sidebyside
element. We have simply chosen here to not provide a caption (overall, or separately) as an illustration. The sizes are purposely a bit odd. See Section 23 for much more on side-by-side panels. These videos come from the “Topic” and “VEVO” areas of YouTube (respectively) and both have start/end times.
youtube
attribute to be a space-separated list of several video IDs. Alternatively, you may set the youtubeplaylist
attribute to a YouTube playlist ID.
<sidebyside>
with a few variations.
<sidebyside>
with a few variations, and now contained in a <figure>
.
<sidebyside>
with a few variations.
<sidebyside>
with a few variations, and now contained in a <figure>
.
Subsection 17.3 Vimeo
We support videos from Vimeo 1 in much the same way as YouTube videos. Now the identifier is a long integer. For example, the video up next would normally be found athttps://vimeo.com/27246366
. But instead, you can embed the video with as little as <video vimeo="27246366"/>
. As of 2019-05-18, we intend to support as many of the options described above as possible. Widths and heights (via the aspect ratio) will perform as expected. We have not investigated start and end times.
vimeo.com

vimeo.com/rickmereki

vimeo.com/rickmereki
Subsection 17.4 Captions and Subtitles
Experimental support for captions and subtitles first. Look at the source, which mimics the actual HTML. The words of the titles and/or subcaptions (there is a difference!) come from a file in Web Video Text Tracks 2 (WEBVVT) format.wikipedia.org/wiki/WebVTT
https://sites.google.com/site/chrisfoo/subtitles
<track>
. The @default
attribute on <track>
can be set to the value yes
to make one set of captions the default (and only one!). Test is a bit lame, the two <track>
use the same file, but just have different labels for the player's menu. Track named US English Two
will show as in-use at start-up.
Section 18 Cross-Referencing
Cross-references are easy, since that is a key reason for having a highly structured document. Here is a useful feature if you elect to use it. Any<xref>
will “know” what it points to, so you can let it provide the “naming” part of the cross-reference text. You can turn this on globally with the command-line parameter autoname
set to 'yes'
. If you do that, you will see most of the names in this document doubled, since the names are written into the source already in most places outside of this section. Try it and see: use --stringparam autoname 'yes'
as an argument to xsltproc
.
Moreover, the names themselves will change with the use of the one language dependent file. And another bonus is that with an autoname, you automatically get a non-breaking space between the name and the reference. The autoname switch makes no sense for “provisional” cross-references, since there is no information about what they point to.
Here is a reference that has no indication of its type in the source: 2.1. So by default you will just see a number that you can click on. If you use the text="type-global"
switch then you should see “Theorem” prepended. Note that if you changed the theorem to a lemma, then that change would be reflected here automatically when autonaming is in effect.
If you set the autonaming behavior globally, or accept the default behavior, there will still be instances where you want to override that choice. Simple: just say text="type-global"
or text="global"
as part of the xref
. Each example below should look the same each time this article is processed, no matter how the global autoname
is set.
No name ever: 4.1
Always named: Corollary 4.1
xref
with some content, then that content will prefix the cross-reference within the clickable/pokeable text and be attached with a non-breaking space. This xref
content totally overrides any prefix that might happen otherwise. So the name of an item (e.g. “corollary”) could be replaced, and if you make a cross-reference with custom text, that will be the clickable also. An example:
A grand result: Major Corollary 4.1
A grand result: a nice corollary
Theorem
by providing the content Theorems
on the first xref
and text="global"
on the second xref
. (With global autonaming off, you will also get what you want/expect.) Here is the test, which should look correct no matter what the global switch is: Sections 18 and 19. (But notice that it is up to you to be certain the types of these targets do not change without you changing the content of the first xref
. The “author-tools” mode and careful choices of xml:id
strings can help avoid this trap.)
If you set the value of @text
to title
, then the title you assigned to the theorem will be used as the link for a cross-reference. Here is a the final example, which refers to a fundamental theorem by name The Fundamental Theorem of Calculus.
Cross-references to exercises with hard-coded numbers should respect the supplied number. Exercise 35.42a should reference problem 42a.
Here we form a list to test pointing at various structures. Each of the following should open a knowl in the HTML version, otherwise it will be a traditional hyperlink (if possible). Note that if a knowl opens, there will always be an “in-context” link which will take you to the actual location, should you have wished instead to just go there.
Footnotes: Fermat allusion at 2.1.
Citations: Judson's AATA with annotation at [1]
Citations: Judson's AATA with autoname that should have zero effect [1]
Citations: In a
<references>
division inside an appendix [J.2.1]Note: just the annotation of previous citation at 1.1
Definition-like: A mathematical statement with no proof 4.13.
A numbered Note: 4.9
A link to a
proposition
element, while this document has globally renamedproposition
s as “Conundrum”s, so this link should use the new name: Conundrum 28.1Theorems: Fundamental Theorem of Calculus, with proof at 2.1
Proof: of second version of FTC at 4.1.1
Figures: A plot with a derivative at 5.2.
A Figure within a side-by-side panel, with its own number: 23.5
A Table within a side-by-side panel, with a subnumber: 23.14.(a)
A Figure, containing a side-by-side with two sub-captioned images: 23.1
Display Mathematics: single, first with no name: (4.1). Then with an autoname: (4.1).
Display Mathematics: multi-row, first with no name: (4.2). Then with an autoname: (4.2). And two, with a plural form: Equations (4.1) and (4.2).
You can cross-reference The Fundamental Theorem of Calculus via custom text of your choice.
Display mathematics: an equation with “local” tag, which should not be used so very far away: (
).You can author a cross-reference to a displayed equation with no number, but it will not be very satisfying. You should get a warning if you try.
Exercises (divisional), a range, with plural form provided to override autonaming: Exercises 11.2.1–11.2.3.
Exercise (inline): with enclosed hint at 4.4
A group of two exercises, with introduction, conclusion: Exercise Group 11.2.2–3
Solution: An autonamed portion of an exercise: Solution 35.42a.1
Parts of a complicated exercise: Hint 35.12.2 Answer 35.12.1
A subsidary part of an exercise: 12.8.1.b.i
Three cross-references to individual exercises, but due to their location, they should have different “type names” in the cross-reference: in an
<exercises>
division, Exercise 32.2; in the narrative, Checkpoint 4.4; and in a<worksheet>
, Worksheet Exercise 31.2.2.An item buried in nested ordered lists: Item 2.b.ii.C
List item as knowls in HTML, including nested lists: 2, Item 2.b.ii
A titled list: 12.3
List item inside a named list, second color in rainbow list: Item 12.3:2
Second color in rainbow list, but now as a local reference: Item 2
An item in ordered list, but contained in an unordered list, hence without a number, so a cross-reference by number would be ambiguous. So we use a cross-reference which relies on custom text: No Number List Item
Several examples of hybrid cross-references to list items within a named list can be found in, and adjacent to, List 12.4.
An assemblage, which never has a number. A cross-reference now requires content in the
xref
element, withtext='custom'
: text to xref an assemblageA cross-reference to a list item in a description list, which has a title, but never a number: Central Processing Unit (CPU). Note that you need to include the attribute
text="title"
even if that is obvious from the situation. This requirement may be relaxed in a future refactoring of the cross-reference system.A very similar cross-reference to the previous one, but testing how final punctuation of titles is handled: Bus!.
A cross-reference to a “paragraphs” subdivision, which never has a number (so comments above about description list items and titles applies here too): Structure
A case within the proof of Claim 4.3: Case 3b: The inductive step
A cross-reference to a description list item with a title containing math: Math
A cross-reference to an aside, by title necessarily: An Aside
A cross-reference to an
objectives
block, with an autoname. This demonstrates the number of the Objectives here, which is not shown in the original version since it is implicit: Objectives 4A cross-reference to an individual objective. This is authored as a list item, but displayed as an objective (singular) via an autoname: Objective 4.1
A cross-reference to the top-level element (e.g.
book
) will point to a summary page similar to a Table of Contents in HTML. For LaTeX output it will behave similarly, unless there is no Table of Contents, then it will go to the main title page: ToC or Title“Cross-references inside quotations previously lost track of their target, so this tests correcting that, not so much the cross-reference itself: Theorem 2.1”
An activity with full details following: 4.3
An interactive program inside a program listing, to test if the Javascript will execute properly within a knowl: 21.8
A
type-global
cross-reference to a second-leveltask
within a project: Task 4.4.c.iii, the encompassingproject
: 4.4, and alocal
reference c.iii.A subcaptioned named list: 23.23.(b)
This opens a knowl for an
example
. It has a solution, which is orginally presented as a hidden knowl. But since this version is a duplicate, the knowl for the solution is a file version, not an embedded version, and hence free from duplicating any unique identifaction like an HTML id. So we test its styling and function here: Example 4.5A cross-reference to a poem, where we need to use a title for the link text, since a
poem
is not numbered: The Charge of the Light BrigadeA cross-reference to a
<references>
division in a subsection, which should not be numbered where born, but which has the number of its parent division in a cross-reference: References 11.4. And a cross-reference to a<references>
division, which is the “main” bibliography in the back matter, and so is not numbered where born, nor in a cross-reference (which we must accomplish via it's title): References.A cross-reference to a
<solutions>
division in a subsection, which should not be numbered where born, but which has the number of its parent division in a cross-reference: Solutions 4.2.7. And a cross-reference to a<solutions>
division, which should appear as an appendix both where born and as a cross-reference: Appendix B.A cross-reference to an
<exercises>
division in a subsection, which is the only such division in that subsection and therefore should not be numbered where born, but which has the number of its parent division in a cross-reference: Exercises 4.2.4. In contrast we cross-reference an<exercises>
division which is one of two inside a section, and therefore is numbered, when born and when cross-referenced, in continuity with the preceding subsections: Exercises 11.3.A custom cross-reference: Custom
autoname
facility, you need to wrap non-math text in \text{}
and perhaps use a tilde (~
) as a non-breaking space (examine the source of this article).
xml:id
as the value of a single ref
attribute on an xref
, in the form of a comma-separated list. In this case, only the numbers are links/knowls and the autonaming attribute is based on the type of the first ref
. Wrapping with brackets (citations) or parentheses (equations) is also controlled by the type of the first ref
. And the detail
attribute for a bibliographic reference is silently ignored. So you can do silly things like have a reference to a theorem within a list of equation numbers and there will be no error message. Handle with care. Spaces after commas in the list will migrate to the output as spaces, so if you don't have any, you won't get any.
Four theorems, with spaces, autonamed: Theorem 2.1, Theorem 27.1, Theorem 27.2, Theorem 27.3
exercisegroup
, or perhaps several chapters), you can get a cross-reference that prints as a range by using xref
with two attributes first
and last
, which may contain a single xml:id
each. As with multiple references, first
will control autonaming and other features.
A range of exercises, autonamed (this range appears “out-of-order” since the two
exercise
are numbered under two different schemes): Checkpoint 4.4–4.2.4.1A range of equations: (4.2)–(4.3)
A system of equations, given as range from first to last: (7.1)–(7.2)
A range of sections, hand-named to be plural: Sections 3–18
A range of bibliographic items: [1–2]
url
element may be used to link to a data file, either externally, or internally, if you want to make such an object available to a reader. A good example use case is a spreadsheet that might be part of an exercise, or contain data relevant to some discussion. First let us suppose the data resides somewhere on the Internet, then just use the complete address. Here is one from Microsoft: Sample Excel Spreadsheet.
For a link like the previous one, you might want to provide advice appropriate for your audience about using a context menu to download a file, or how to configure helper/viewer applications.
You can also provide a file yourself, but now it is your obligation to distribute the file with your document (HTML, PDF, etc.) and provide a relative link. This creates some complications, such as making sure an electronic PDF has the associated file in the same place relative to the PDF file. Of course, if you make a print PDF, this becomes impossible. Here is a test example anyway, which is highly likely to be broken in a PDF (including at the PreTeXt project site) unless you build this example on your own computer, locally. Here is a template from the Apache OpenOffice project, provided via the Public Documentation License (PDL): Running Statistics Template.Section 19 Internationalization
Supporting a multitude of possible characters, across many languages and across many output formats can be a challenge. One of our goals is to make this much easier for authors. Fortunately, the Unicode standard has led to improvements from the 7-bit ASCII standard of old.Unicode Characters for HTML Output.
First, we discuss HTML output. If you include Unicode characters in your PreTeXt source, they should survive just fine en route to a web browser or e-reader. Here are the caveats for HTML output:So that you can continue to get the best results with print and PDF output, use available empty elements for obscure characters, even if targeting HTML output, before resorting to a Unicode character. For example, use
<copyright/>
for the copyright symbol in text before resorting to the Unicode characterU+00A9
. It is a bit more work, but you will get better results with other conversions, even if you initially are only fascinated by HTML.How you actually enter Unicode characters into your source file is dependent on your editor and operating system, and is therefore outside the scope of our documentation. You can cut-and-paste characters and text from the source of our examples for initial testing and experimentation.
Always, always identify your source as having Unicode characters by including the incantation
<?xml version="1.0" encoding="UTF-8" ?>
as the first line of your source file. (You may be able to accurately cut-and-paste this version here. But if the copy has non-standard characters in it, go back to the top of this source file for a copy.)Alan Wood’s Unicode Resources has a plethora of samples of various groups of Unicode characters. If you, or your readers, are “missing” characters in a web browser, this is a good place to start testing the local setup.
Characters in LaTeX, PDF, print.
The situation for LaTeX is a bit more complicated, since TeX pre-dates Unicode's widespread adoption. This sample article is intended to work well, out-of-the-box, for authors just starting with PreTeXt. So we only include here examples that we know are likely to convert to PDF without any errors. For more extensive examples and experiments, we provide the sample documentexamples/fonts/fonts-and-characters.xml
, so be aware of that example as you look to see what is possible.
Similarly, you should be able to process this sample article successfully with various LaTeX engines. We test regularly with pdflatex
and xelatex
and provide online sample PDF output of this document processed by pdflatex
. In principle, you should be able to use latex
(to produce a DVI), and possibly other (unsupported) engines, such as lualatex
.
Once you get beyond the Latin alphabet, with accents common in Western Europe and the Western Hemisphere, you will almost assuredly need to restrict your attention to producing PDF output with the xelatex
engine. This is discussed and tested in examples/fonts/fonts-and-characters.xml
.Basic Latin, U+0000
–U+007F
.
Unicode uses multiple 8-bit bytes to represent characters, and these are typically expressed in hexadecimal (base 16) notation. Using just a single byte, we can get 256 values, and the first 128 (hex 00
to 7F
) are the “usual” Latin characters with some values used as control codes. These 95 characters are the most basic, and will all render using pdflatex
or xelatex
with no special setup (and will render easily in HTML). U+0000
to U+001F
are control codes and not used here. U+007F
is also a control code and so is excluded, while U+0020
is a space, so appears invisible in the table. In the source we have authored each character by its escaped version using its Unicode number (in hexadecimal). So, for example, capital-B is authored as B
.
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
|
002_ |
! | " | # | $ | % | & | ' | ( | ) | * | + | , | - | . | / | |
003_ |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? |
004_ |
@ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O |
005_ |
P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ |
006_ |
` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o |
007_ |
p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ |
Latin-1 Supplement, U+0080
–U+00FF
.
Now we are interested in the next 128 possible bytes, (hex 80
to FF
). The first 32 are again control codes and U+00A0
is a non-breaking space, so is invisible, while U+00AD
is a soft hyphen (which we have not implemented and so is excluded). We have taken care to see that the remainder will render using pdflatex
or xelatex
with no special setup (and HTML). In the source we have authored each character by its escaped version using its Unicode number (in hexadecimal). So, for example, a copyright symbol is authored as ©
.
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
|
00A_ |
¡ | ¢ | £ | ¤ | ¥ | ¦ | § | ¨ | © | ª | « | ¬ | ® | ¯ | ||
00B_ |
° | ± | ² | ³ | ´ | µ | ¶ | · | ¸ | ¹ | º | » | ¼ | ½ | ¾ | ¿ |
00C_ |
À | Á | Â | Ã | Ä | Å | Æ | Ç | È | É | Ê | Ë | Ì | Í | Î | Ï |
00D_ |
Ð | Ñ | Ò | Ó | Ô | Õ | Ö | × | Ø | Ù | Ú | Û | Ü | Ý | Þ | ß |
00E_ |
à | á | â | ã | ä | å | æ | ç | è | é | ê | ë | ì | í | î | ï |
00F_ |
ð | ñ | ò | ó | ô | õ | ö | ÷ | ø | ù | ú | û | ü | ý | þ | ÿ |
Monospace, Basic Latin and Latin-1 Supplement, U+0000
–U+00FF
.
A monospace font is critical for samples of keyboard input and to distinguish exact technical input from running commentary. We list here all of the reasonable characters from the first 256 Unicode code points. (We skip the same 65 control characters from above, and the soft hyphen.) These should all render fine in HTML and when processed with xelatex
, however our focus with this sample article for PDF output is the capabilities when processed with pdflatex
. First, characters from U+0000
–U+007F
.
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
|
002_ |
|
! |
" |
# |
$ |
% |
& |
' |
( |
) |
* |
+ |
, |
- |
. |
/ |
003_ |
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
: |
; |
< |
= |
> |
? |
004_ |
@ |
A |
B |
C |
D |
E |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
005_ |
P |
Q |
R |
S |
T |
U |
V |
W |
X |
Y |
Z |
[ |
\ |
] |
^ |
_ |
006_ |
` |
a |
b |
c |
d |
e |
f |
g |
h |
i |
j |
k |
l |
m |
n |
o |
007_ |
p |
q |
r |
s |
t |
u |
v |
w |
x |
y |
z |
{ |
| |
} |
~ |
' " ' " ' "
. And a backtick is a backtick: ` ` `
. The zero is distinguished from the capital “oh”: 0 O 0 O 0 O
. And the numeral one is slightly different from the lower-case “ell”: 1 l 1 l 1 l
. The hyphen should be short and not expanded into some other kind of dash: - - -
. These characters should all cut/paste out of a PDF into a text editor with no conversion to other characters.
Now the remaining characters from U+0080
–U+00FF
. The program
tag is implemented in LaTeX via the listing
package and these characters require ad-hoc replacements for processing by pdflatex
. (You can see the replacements in the preamble of the LaTeX source for this document.) The replacement mechanism provided by the listing
package will cause the characters below to produce a LaTeX compilation error if processed by pdflatex
and in a table cell in certain situations (which we have avoided in the table below). The only workaround in this case is to switch to xelatex
.
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
|
00A_ |
¡ |
¢ |
£ |
¤ |
¥ |
¦ |
§ |
¨ |
© |
ª |
« |
¬ |
® |
¯ |
||
00B_ |
° |
± |
² |
³ |
´ |
µ |
¶ |
· |
¸ |
¹ |
º |
» |
¼ |
½ |
¾ |
¿ |
00C_ |
À |
Á |
 |
à |
Ä |
Å |
Æ |
Ç |
È |
É |
Ê |
Ë |
Ì |
Í |
Î |
Ï |
00D_ |
Ð |
Ñ |
Ò |
Ó |
Ô |
Õ |
Ö |
× |
Ø |
Ù |
Ú |
Û |
Ü |
Ý |
Þ |
ß |
00E_ |
à |
á |
â |
ã |
ä |
å |
æ |
ç |
è |
é |
ê |
ë |
ì |
í |
î |
ï |
00F_ |
ð |
ñ |
ò |
ó |
ô |
õ |
ö |
÷ |
ø |
ù |
ú |
û |
ü |
ý |
þ |
ÿ |
pre
tag is implemented in LaTeX with the fancyvrb
package. You can compare results here with the table above, lines here are rows above.
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿThe
console
tag is also implemented with fancyvrb
, with adjustments for the input lines. It will not look like it, but these are 8 such inputs, with similar results to above, but now bolded.
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à á â ã ä å æ ç è é ê ë ì í î ï ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ
U+0080
–U+00FF
characters in Sage cells. This would allow some flexibility in comments and strings employed. The following is just a test of these characters in the input
and output
of a sage
element. This is not functional code.
xxxxxxxxxx
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ® ¯
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß
à á â ã ä å æ ç è é ê ë ì í î ï
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ
c
element. It is meant to test if the font is monospace in this situation.
Again, more examples and more thorough explanations can be found in the sample: examples/fonts/fonts-and-characters.xml
. Be aware that the nature of the more advanced sample is that it will likely produce many errors when processed with pdflatex
. Adding -interaction batchmode
or -interaction nonstopmode
to the pdflatex
command-line will sometimes be less painless than acknowledging each error. The more advanced sample will perform well when processed with xelatex
.Section 20 Pre-Formatted Text
In Sage, if you wanted to build a matrix, then you would use thematrix()
constructor. Here is the matrix of second partials of SR
is the ring of symbolic expressions, Symbolic Ring
.
var('x', 'y') J = matrix(SR, [ [6*x + 16*y^3, 48*x*y^2], [48*x*y^2, 48*x^2*y + 12*y^2] ])That accomplished, Sage will easily and naturally provide a LaTeX representation of the matrix with the command
latex(J)
.
\left(\begin{array}{rr} 16 \, y^{3} + 6 \, x & -48 \, x y^{2} \\ 48 \, x y^{2} & 48 \, x^{2} y + 12 \, y^{2} \end{array}\right)The
pre
element surrounds text that should be preserved verbatim. It is like a special kind of paragraph, and can be used almost everywhere that a paragraph can be used. The realization of preformatted text should be robust enough that it can be cut from documents and pasted without any substitutions of “fancier” Unicode characters for generic ASCII characters. Try the “minus” sign on the A normal line An indented line An outdented lineSnippets should also be robust for cut/paste operations. For example, you should not get “curly” “smart” quote marks in verbatim text:
this should have "dumb" quote marks
. Here are a few characters that should migrate through LaTeX to a PDF unmolested: '"----"'
If you write a very long snippet of inline code (i.e. within a <c> element) it can impinge on the right margin, since very long words will not hypenate, unless you have a dash/hypen. Such as when you use words like pneumonoultramicroscopicsilicovolcanoconiosis, parastratiosphecomyia stratiosphecomyioides, floccinaucinihilipilification, or subdermatoglyphic. For output in LaTeX we get line-breaking, and perhaps word-spacing, but we do not get hyphenation and the font is fixed-width. So not always perfect. Consider other options like <cd> or <pre> below.
An intermediate type of verbatim text can be accomplished with the <cd>
tag, short for “code display.” It allows for larger chunks of verbatim text to show up in the middle of a paragraph, but with some vertical space above and below, and centered between the margins. It can be
authored as a single lineor if you wish to have multiple lines
there is the <cline> tag meant to model the line tag and short for "code line"and you may even
use a single clineif you like to have your source closely model the visual look of the output. The
<pre>
tag is meant for use outside of paragraphs, but is otherwise very similar. The source may also be structured as a sequence of <cline>
as in the next example, recycling content from above.
If you write a very long snippet of inline code (i.e. within a <c> element) it can impinge on the right margin, since very long words will not hypenate, unless you have a dash/hypen. Such as when you use words like pneumonoultramicroscopicsilicovolcanoconiosis, parastratiosphecomyia stratiosphecomyioides, floccinaucinihilipilification, or subdermatoglyphic. For output in LaTeX we get line-breaking, and perhaps word-spacing, but we do not get hyphenation and the font is fixed-width. So not always perfect. Consider other options like <cd> or <pre> below.
Section 21 Program Listings
Sage cells can be used for Python examples, but Sage uses a mild amount of pre-parsing, so that might not be a wise decision, especially in instructional settings. We might implement Skulpt or Brython (in-browser Python) or the Python language argument to the Sage Cell Server. To see examples of authoring Sage cells, have a look at Section 3. In the meantime, program listings, especially with syntax highlighting, is useful all by itself. The “R” language might not be a bad stand-in for pseudo-code, as it supports assignment with a left arrow and has fairly generic procedural syntax for control structures and data structures. Or maybe Pascal would be a good choice? Here is an example of R. Note in the source that the entire block of code is wrapped in a CDATA section due to the four left angle brackets. We do not recommend this technique for isolated problem characters, but it is a life-saver for situations like the XSLT code just following.n_loops <- 10
x.means <- numeric(n_loops) # create a vector of zeros for results
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7)) # 1 to 6, uniformly
x.means[i] <- mean(x)
}
x.means
<xsl:template match="biblio" mode="number">
<xsl:apply-templates select="." mode="structural-number" />
<xsl:text>.</xsl:text>
<xsl:number from="references" level="any" count="biblio" />
</xsl:template>
@language
values of matlab
and octave
are somewhat interchangeable. Following is a very slighlty edited version of an example from “50 Basic Examples for Matlab” 1 .
www.public.asu.edu/~hhuang38/hph_matlab_basic2013_1.pdf
a = [0:0.5:5]; % A Matlab comment here
b = 2*a.^2 + 3*a -5;
c = 1.2*a.^2+4*a-3;
subplot(1,2,1)
plot(a,b,'-or','MarkerFaceColor','g','LineWidth',2)
xlabel('X'); ylabel('Y'); legend('Curve ','Location','NorthWest')
subplot(1,2,2)
plot(a,c,'--ok','MarkerFaceColor','c','LineWidth',2)
xlabel('X'); ylabel('Y'); legend('Curve 2','Location','NorthWest')
input m, n and A
r := 0
for j := 1 to n
i := r+1
while i <= m and A[i,j] == 0
i := i+1
if i < m+1
r := r+1
swap rows i and r of A (row op 1)
scale A[r,j] to a leading 1 (row op 2)
for k := 1 to m, k <> r
make A[k,j] zero (row op 3, employing row r)
output r and A
pretext-common.xsl
file to see the strings to use to identify languages. Always all-lowercase, no symbols, no punctuation.
Note that the above examples all have slightly different widths (theser are very evident in print with the frames). As 2-D atomic objects, to place them in the narrative requires the layout features of a sidebyside
element. Then width
and/or margin
attributes will influence the width of the panel.
A program
may also be nested inside a listing
, which behaves similar to a figure
. You can provide a caption
, and the listing will be numbered along with tables and figures. This then makes it possible to cross-reference the listing, such as Listing 21.1. It also removes the requirement of wrapping the program
in a sidebyside
. For technical reasons, the three examples above will not split across a page break in PDF output, but the placement inside a listing
will allow splits, as you should see in at least one example following.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
Algorithm 21.2. Sieve of Eratosthenes.
On input of a positive integer n
this algorithm will compute all the prime numbers up to, and including, n
. It was named for Eratosthenes of Cyrene (ca. 276 BC–ca. 195/194 BC) by Nicomachus (ca. 60–ca. 120 CE) in Introduction to Arithmetic. (Wikipedia, 2015)
Input:
n
Form the list of all integers from
2
ton
Set
p = 2
-
While
p < sqrt(n)
If present, remove from the list multiples
2p, 3p, ...
If
p
is now the last element of the list, stopOtherwise, set
p
to the element of the list immediately after currentp
Output: the remaining elements of the list
Proof.
Any element removed is a non-trivial product of two integers and hence composite. So no prime is is ever removed from the list.
Each composite number is a multiple of some prime, and since no prime is ever removed, each composite will be removed. Hence the removed elements are precisely the set of composite numbers in the list and thus the remainder are precisely the primes on the list.
\texttt
for a monospace text font, and \;
for spacing/grouping the bits of the binary number.
Theorem 21.3.
This is a spurious theorem to break up the run of consecutive listing
so we might test the effect.
Proof.
This is a proof that is authored “detached.” It is not associated with the theorem above in a way other than simply following it.
console
session may be used by itself inside a sidebyside
, or it can be wrapped in a listing to get a number and a caption. As elsewhere, you will need to escape ampersands and angle brackets (such as if you have a command using redirection), using &
, <
, and >
in your source.
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
int
and float
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
int
and float
(multi-line input)(*
and *)
as sequences used to escape embedded LaTeX commands, so we test those also.
A backslash \ here A backslash \ here A backslash \ here A begin group { here A begin group { here A begin group { here An end group { here An end group } here An end group } here An open escape sequence (* here An open escape sequence (* here An open escape sequence (* here An end escape sequence *) here An end escape sequence *) here An end escape sequence *) here Some quotation marks ` ' " here Some quotation marks ` ' " here Some quotation marks ` ' " here The rest & % $ # _ ~ ^ of LaTeX The rest & % $ # _ ~ ^ of LaTeX The rest & % $ # _ ~ ^ of LaTeX Latin-1: ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß Latin-1: ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß Latin-1: ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞß
listing
breaking across pages in PDF output.
@ structPass2.s
@ Allocates two structs and assigns a value to each field
@ in each struct, then displays the values.
@ Bob Plantz - 6 July 2016
@ Constants for assembler
.include "theTag_struct.s" @ theTag struct defs.
.equ y,-28 @ y struct
.equ x,-16 @ x struct
.equ locals,28 @ space for the structs
@ Constant program data
.section .rodata
.align 2
displayX:
.asciz "x fields:\n"
displayY:
.asciz "y fields:\n"
dispAChar:
.asciz " aChar = "
dispAnInt:
.asciz " anInt = "
dispOtherChar:
.asciz " anotherChar = "
@ The program
.text
.align 2
.global main
.type main, %function
main:
stmfd sp!, {r4, fp, lr} @ save caller's info
add fp, sp, #8 @ our frame pointer
sub sp, sp, #locals @ for the structs
@ fill the x struct
add r0, fp, #x @ address of x struct
mov r1, #'1
mov r2, #456
mov r3, #'2
bl loadStruct
@ fill the y struct
add r0, fp, #y @ address of y struct
mov r1, #'a
mov r2, #123
mov r3, #'b
bl loadStruct
@ display x struct
add r4, fp, #x @ address of x struct
ldr r0, displayXaddr
bl writeStr
ldr r0, dispACharAddr @ display aChar
bl writeStr
ldrb r0, [r4, #aChar]
bl putChar
bl newLine
ldr r0, dispAnIntAddr @ display anInt
bl writeStr
ldr r0, [r4, #anInt]
bl putDecInt
bl newLine
ldr r0, dispOtherCharAddr @ display anotherChar
bl writeStr
ldrb r0, [r4, #anotherChar]
bl putChar
bl newLine
@ display y struct
add r4, fp, #y @ address of y struct
ldr r0, displayXaddr
bl writeStr
ldr r0, dispACharAddr @ display aChar
bl writeStr
ldrb r0, [r4, #aChar]
bl putChar
bl newLine
ldr r0, dispAnIntAddr @ display anInt
bl writeStr
ldr r0, [r4, #anInt]
bl putDecInt
bl newLine
ldr r0, dispOtherCharAddr @ display anotherChar
bl writeStr
ldrb r0, [r4, #anotherChar]
bl putChar
bl newLine
mov r0, #0 @ return 0;
sub sp, fp, #8 @ restore sp
ldmfd sp!, {r4, fp, pc} @ restore and return
.align 2
@ addresses of messages
displayXaddr:
.word displayX
displayYaddr:
.word displayY
dispACharAddr:
.word dispAChar
dispAnIntAddr:
.word dispAnInt
dispOtherCharAddr:
.word dispOtherChar
Checkpoint 21.9. Inline Coding Exercise, No Help.
An exercise might ask a reader to write a computer program, so you can also add a <program>
element after the <statement>
of an <exercise>
. The purpose is to make it a live coding environment for a version of your output that allows the reader to perhaps submit a solution, if the hosting enviromnment is capable of that. The <program>
element is necessary so you can specify a programming language. Here we place no code at all in the <program>
, so there may be noting at all to see.
We didn't really ask you to do anything.
Checkpoint 21.10. Inline Coding Exercise, Partial.
Similar to above, but we provide an incomplete start for the exercise, which is likely visible in all conversions.
#include
int main(void)
We're not really sure.
Section 22 Units of Measure
Units of measure can be given xml treatment too with thequantity
element. In LaTeX, the siunitx
package is loaded to achive unit handling. Since that package only offers SI units, some other common units will be added by MBX in the preamble. In HTML, the capabilities of siunitx
are simulated, weakly. Note that at present, you should not attempt to use the quantity
element within a math environment.
The value of gravitational constant \pi
is recognized within mag
in conversions to HTML, which is consistent with the behavior with a conversion to LaTeX, for example there are 2pretext-units.xsl
. If you have a need for more units, they need to be added to pretext-units.xsl
in the section that deals with units which are not part of siunitx
by default. Note that the mag
element should come first, followed by the unit
element, followed by the per
element.Section 23 Side-By-Side Panels
Introduction.
The flow of a page is almost universally top-to-bottom. But at times you would like to go across a page, perhaps to compare items (identical content in two different languages), or to make good use of a page real estate by grouping several small items together (e.g. images). So the<sidebyside>
tag is strictly a layout device, though it does convey some meaning by grouping certain objects together. A variety of different objects can be put side-by-side using the sidebyside
element. Specifically, figure
, image
, tabular
, p
, ol
, ul
, dl
, pre
, poem
, and more. The individual components of a <sidebyside>
are generically called panels.
As a layout device, the <sidebyside>
does not allow a <caption>
, is never numbered, and therefore cannot be cross-referenced. You may cross-reference whatever element holds the <sidebyside>
, and many of the panels may be cross-referenced individually.
As a first example, we have two single paragraphs, laid out with different widths, and slight margins on each side. The widths have been chosen experimentally to get roughly identical heights for the two paragraphs of varying length.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin lorem diam, convallis in nulla sed, accumsan fermentum urna. Pellentesque aliquet leo elit, ut consequat nunc dapibus ac. Sed lobortis leo tincidunt, vulputate nunc at, ultricies leo. Vivamus purus diam, tristique laoreet purus eget, mollis gravida sapien. Nunc vulputate nisl ac mauris hendrerit cursus. Sed vel molestie velit. Suspendisse sem sem, elementum at vehicula id, volutpat ac mi. Nullam ullamcorper fringilla purus in accumsan. Mauris at nunc accumsan orci dictum vulputate id id augue. Suspendisse at dignissim elit, non euismod nunc. Aliquam faucibus magna ac molestie semper. Aliquam hendrerit sem sit amet metus congue tempor. Donec laoreet laoreet metus, id interdum purus mattis vulputate. Proin condimentum vitae erat varius mollis. Donec venenatis libero sed turpis pretium tempor.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra. Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
Subsection 23.1 Figures with Numbers Side-By-Side
Figures, or other captioned items such as tables or listings, can be placed side-by-side using thesidebyside
element. The figures will be captioned and numbered as if they were part of the vertical flow of the document. For example, see Figure 23.4 and Figure 23.5
However, if the <sidebyside>
is placed inside another <figure>
, then the outer figure gets an overall caption and a “regular” number, while the captions of the interior items will be labelled as (a), (b), (c), etc; for example, see the subfigures in Figure 23.1. You can also cross-reference the subfigures individually, for example: Figure 23.1.(a).
The sidebyside
tag can have an attribute widths
that specifies a percentage width of the page for each panel of the layout. There are automatic margins by default, and any remaining width is divided evenly to space out the panels. When the margins
attribute is given as auto
, or in the default case, the margins provided each equal half of the inter-panel space.
With no attributes on the sidebyside
, each panel is the same width and there is no inter-panel space and no margin. For a sidebyside
with a single panel, with its width specified, the panel will be centered.










Subsection 23.2 Images
We can use thesidebyside
element to put images
next to each other. These will illustrate a text, but with no captions or numbers, cannot be cross-referenced. This next example has 10%
margins, and the panels have widths 25%
and 40%
, leaving 15%
computed as the one inter-panel space.


top middle bottom top middle
via the valigns
attribute.





<figure>
may be cross-referenced, as Figure 23.7


Subsection 23.3 Common Side-By-Side Constructions
We have now seen at least one example of each of the four most common constructions involvingsidebyside
. Working from the exterior inward, we can go figure
, sidebyside
, figure
, X
, where X
is some atomic (unnumbered) item we might use elsewhere in a PreTeXt document, the inner figure
may be repeated with different objects X
, and the figure
s have captions. Each figure
is independently optional, leading to the four combinations in this table. Note this applies to any captioned item used inside the sidebyside
, but a figure
is the most flexible.
sidebyside
and figure
interactionsOuter Figure | Inner Figure | Effect |
Absent | Absent | Layout only, no numbers nor captions |
Absent | Present | Numbers and captions on figure(s) |
Present | Absent | Number and overall caption |
Present | Present | Number and overall caption, sub-numbers and captions on figure(s) |
Subsection 23.4 Vertical Alignment
Vertical alignment can be specified using thevalign
attribute which admits a space-separated list of top
, middle
, and bottom
; the default is top
.



valign
, can provide the same alignment to each panel, here we use five different widths, but all with vertical alignment of middle
.





Subsection 23.5 Text Next to Text and Images
Text can be put next to other blocks of text using thestack
element, which can contain multiple paragraphs using the p
element (see Subsection 23.12). If only one paragraph is required, simply use the p
element on its own.
here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text cross reference: Figure 23.12 and math:

here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text here is some text; cross reference: Figure 23.12 and math:

Subsection 23.6 Image Formats, Side-by-Sides
Most of our demonstrations here use our square “blue cross” test image, which is provided as a PNG image. You may specify images by any of the methods described in the section on graphics, Section 9. The complete graph below is specified with no file extension, on the assumption that an SVG version exists for HTML output, and a PDF version exists for LaTeX output. The second is a JPEG image that we use elsewhere for a YouTube video, but recycle here as an image provided in that format. By default, they are aligned at their tops. Here are two TikZ images, authored side-by-side. The first has had its geometric portions of the original scaled down to 75%, with the effect of increasing the text, relatively, so the application in a side-by-side panel with 25% width has legible text. We caption only the second panel, which has no text adjustments. From TeXample.net.Subsection 23.7 Tables Side-By-Side
Tables can also be put side-by-side, as demonstrated below in Figure 23.14; naturally, subtables can be referenced as in Table 23.14.(a).1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
table
elements side-by-side without an enclosing <figure>
, then they will use regular numbering; see Tables 23.16–23.18.
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
Subsection 23.8 Tables Next to Figures
Tables and figures can go next to each other, as demonstrated in Table 23.19 and Figure 23.20, plus within an overall captioned figure, Figure 23.21.1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |

1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |

Subsection 23.9 Tables Next to Text
Tables can go next to blocks of text using the<stack>
element (see Subsection 23.12).
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
here is some text here is some text here is some text here is some text here
Subsection 23.10 Tabular Next to Each Other
Fourtabular
elements inside a single <sidebyside>
will result in no captions at all.
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
CCCC | DDDD |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |
Subsection 23.11 Lists in Side-by-Sides
A “regular” list normally belongs in ap
but it can be placed unadorned into a panel of a side-by-side, as demonstrated below in Subsection 23.13. You can also put “named” lists into a panel, and then the title, introduction, conclusion, and caption will behave as expected, along with a number that might be used in a cross-reference (23.23.(b)), or perhaps we might cross-reference by title, Color Shades.
<sidebyside>
, where vertical alignment on the top
aligns the titles.
sidebyside
in a list. The widths are now relative to the space given over to an indented item. Here we nest and nest and nest and nest to get a big, obvious indentation, and then include an image at 100% width and no margin. In your mind's eye, or with a ruler, check that the image spans all the way over to the right margin.
-
This is
-
a very
-
wide
-
rectangle
-
-
-
Subsection 23.12 Stacking: Back to Vertical Flow
You might wish to mix disparate items within a panel, returning to a vertical flow within a panel. For example, you might want a diagram to the left and some paragraphs of commentary to the right. Or perhaps a photograph on one side and a list of bullet points to the other side. A<stack>
is a container that can only be used to collect several items into a single panel of a <sidebyside>
. You cannot point to it, but you can point to its contents as usual. Contents may be anything you could otherwise put into a sidebyside
panel that does not have a <caption>
or a <title>
. In particular, these panels cannot be sub-numbered since the panel cannot be made into a <figure>
.
Similar items can also be stacked, of course. Most importantly, a normal panel will accept a single paragraph. If you want several paragraphs, simply collect them in a stack
.
A simple sentence inside a single <p>
as the first item in a stack.


A less simple sentence that will wrap inside the panel to make the right panel taller and allow us to experiment with sliding the left panel contents up and down, here it is placed in the middle
.
bottom
, just as a demonstration (it would likely look better with top
alignment).

Blue
Square
Geometric
The blue-ness of the border contrasts with the stark emptieness of the white interior, evoking images of blue skies and vast sandy deserts. The harsh black cross draws the viewer's attention to the exact center.
Paragraph one.

Paragraph two.
1111 | 2222 |
aaaa | bbbb |
AAAA | BBBB |

<sidebyside>
using a <stack>
to enable constructions like a table of data in one panel, and maybe a plot with some text next to it.
In the toy example next, the list of data is rigid, so we have set the first panel width to 40%
, a value obtained experimentally to just contain the list. This allow us to set the second panel to a width of 58%
, and we use no margins. If you try to balance the heights of the two panels, this can become a bit of a zero-sum game. A wider second column means the text occupies fewer lines, but the wider image also creates a taller image, consuming more vertical space.
0 | 0.00 | 0.0000 | 0.5000 |
1 | 0.20 | 0.1000 | 0.4800 |
2 | 0.40 | 0.1960 | 0.4560 |
3 | 0.60 | 0.2872 | 0.4295 |
4 | 0.80 | 0.3731 | 0.4027 |
5 | 1.00 | 0.4536 | 0.3783 |
6 | 1.20 | 0.5293 | 0.3591 |
7 | 1.40 | 0.6011 | 0.3480 |
8 | 1.60 | 0.6707 | 0.3474 |
9 | 1.80 | 0.7402 | 0.3603 |
10 | 2.00 | 0.8123 | 0.3900 |

This set of values and this plot have nothing to do with each other. You'll recognize that they've been liberated from earlier in this work.
Step back and simply examine how the pieces all fit together within a <figure>
.
Bully Pulpit.
Remember that<sidebyside>
has attributes that strongly influence layout. That is intentional. But to support a variety of output formats, it does not allow overly-precise control, and they be viewed as providing hints to an implementer of a conversion. So for example, do not expect <sidebyside>
to function like a LaTeX tabular
or an HTML table
.
In particular, elements of two consecutive <stack>
will not line up, unless perhaps you construct them identically. Consider a <sbsgroup>
for something closer to putting items into rows.Subsection 23.13 Other Panels
Other elements may be placed within asidebyside
element. Pure lists first.
sidebyside
element.
here is some text, and here is an equation that contains alignment.
here is some text, and here is an equation that contains alignment.
here is some text, and here is an equation that contains alignment.
pre
element. This content is horizontally-rigid, so as the author, you need to be sure to provide enough width for the panel to contain the content. It is easy to see the boundary of the panels when rendered in HTML since there is a background that fills the panel.
program HelloWorld; begin WriteLn('Hello, world!'); end.
#include int main() { std::cout << "Hello, world!"; return 0; }
Subsection 23.14 Poems as Side-By-Side Panels
Poems may be panels of a side-by-side layout. Here we place some commentary alongside. See Section 25 for general information about poetry.Fire and Ice
You might have several things to say about a poem and you could use a sequence of paragraphs immediately adjacent.
This is a second paragraph of commentary.
Sonnet to Liberty
Sonnet to Liberty
Subsection 23.15 Side-By-Side Groups
A “side-by-side group,”<sbsgroup>
, is still in development. (Notably, subcaptions do not behave as expected.) It is a sequence of sidebyside
, which may conceivably use the same margins, widths and vertical alignments for each horizontal run of panels. Attributes on the sbsgroup
are global to the group's enclosed sidebyside
, and will be used by each contained sidebyside
. If attributes are present on an individual sidebyside
, they override the global values. The next two examples demonstrate some of this behavior, in a limited way.
One.
Two.
Three.
Four.
Five.
Six.
sidebyside
will not fit onto a physical page and will not break across pages. With a sbsgroup
you can put each stanza (say) into its own sidebyside
and place something (commentary) next to it. We include the title
with the first stanza and the author
with the last stanza. This device can also be useful to attach commentary to specific stanzas.
The Stolen Child
Some commentary on Stanza One.
Some commentary on Stanza Two.
Some commentary on Stanza Three.
Some commentary on Stanza Four.
sbsgroup
is to layout a grid of items, and by placing the layout parameters on the sbsgroup
element, the items can line up across sidebyside
and subcaptioning can run across the whole group. So, for example, if you have images to compare by placing in a grid, then making them all the same size, or of the same aspect ratio, can help with the overall consistency.
This example has three sidebyside
, each with four figure
containing an identical image
. Since the images are identical and the width
is set to 20% they should all line up nicely with little effort. Since the default for margins is automatic, the remaining 20% of the overall width will be used for three inter-panel spaces of 5% and two margins of 2.5% each. Note the numbering of these as independent figures. We have left the captions empty for reasons of space, but you could add more information. Note that in print, a page break is allowed between any two of the sidebyside
and cannot be suppressed.












sbsgroup
but now put it in its own overall figure. That will allow a caption for the whole group, and will cause the twelve figures to be subcaptioned. Except the subcaptioning is not implemented. Soon.












sidebyside
. Note that it is easy to make a panel so skinny that even the smallest possible caption does not fit in the width.












Subsection 23.16 Testing a Side-By-Side First
A<sidebyside>
that appears first within some other container can wreak havoc in LaTeX output. Below we have this situation twice, once in an <activity>
, then in an <example>
, then in a <paragraphs>
.
Activity 23.1.
Here is text block 1
Here is text block 2
Example 23.55.
Here is text block 1
Here is text block 2
<sbsgroup>
in similar circumstances.
Example 23.56.
Here is text block 1
Here is text block 2
Here is text block 3
Here is text block 4
First Child of a Paragraphs.
A | B |
C | D |
Subsection 23.17 Testing Styling of Related Elements
This subsection has non-side-by-side structures, to aid with the effects of styling decisions across the range of possibilities. First afigure
with a caption
holding a scaled image and a cross-reference for knowl testing: Figure 23.57.

Section 24 Side-by-Side Gallery
This subsection attempts to survey all the possible items that can be placed into asidebyside
element, in various combinations. While intended to be exhaustive across contents, it does not test all possibilities, and is not meant to be instructive (see Section 23 for that). The layout is identical for each sidebyside
, 5% margins, panel widths of 40% and 45%, leaving 5% for the space between the panels. The vertical alignment is left at the default, top
.
We begin with “simpler” atomic items. If necessary, comments follow each.
Vestibulum sit amet est non lacus accumsan iaculis aliquam nec leo. Maecenas placerat consequat quam, a lobortis odio convallis vitae. Curabitur sagittis, risus non suscipit pulvinar, enim tortor posuere purus, id dignissim sapien sapien non dui. Vestibulum ultrices, enim a ornare consectetur, nisl est iaculis arcu, eget scelerisque nunc magna a nisl. Vestibulum vestibulum ante sit amet ex vulputate, eu facilisis sapien tempor.
Aliquam dui nisi, pharetra id enim vel, imperdiet laoreet risus. Nunc convallis elit eu erat imperdiet tincidunt. Sed eget augue et nunc mollis tempor. Suspendisse luctus elit non lorem scelerisque, nec lacinia lectus dictum.
Vivamus ut orci nisl. Donec eleifend ultricies tortor, a pellentesque neque dignissim in. Praesent maximus, augue eu pretium auctor, dolor quam feugiat augue, ut vulputate nunc eros vitae massa. Phasellus quis ante quis est venenatis dapibus eget luctus ipsum.
<p>
(left), <stack>
(right)Blue
Red
Green
Purple
Violet
Brown
-
Vestibulum sit amet est non lacus accumsan iaculis aliquam nec leo. Maecenas placerat consequat quam, a lobortis odio convallis vitae.
Curabitur sagittis, risus non suscipit pulvinar, enim tortor posuere purus, id dignissim sapien sapien non dui.
-
Vestibulum ultrices, enim a ornare consectetur, nisl est iaculis arcu, eget scelerisque nunc magna a nisl.
Vestibulum vestibulum ante sit amet ex vulputate, eu facilisis sapien tempor.
<ol>
with simple items, a <ul>
with items with paragraphsn_loops <- 10
x.means <- numeric(n_loops)
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7))
x.means[i] <- mean(x)
}
x.means
pi@rpi ~$ gcc -o intAndFloat intAndFloat.c pi@rpi ~$ ./intAndFloat 19088743 (integer) and 19088.742188 (float) pi@rpi ~$
<program>
and a <console>
To A Friend Whose Work Has Come To Nothing
Organism | Classification |
Trout | Fish |
Monkey | Mammal |
Crow | Bird |
Crimini | Fungus |
Bee | Insect |
<poem>
and a <tabular>
tabular
can exceed the width of its panel in print, while in HTML
it may reflow individual cells to stay within a panel, depending on their contents.
Vestibulum sit amet est non lacus accumsan iaculis aliquam nec leo. Maecenas placerat consequat quam, a lobortis odio convallis vitae.
Vestibulum sit amet est non lacus accumsan iaculis aliquam nec leo. Maecenas placerat consequat quam, a lobortis odio convallis vitae.
<pre>
, and a <pre>
employing <cline>
pre
can spill outside of its panel without any word-wrapping. So you may need to vary panel widths or rearrange line breaks manually. Page width is a scarce resource.


<image>
, twicefigure
, table
, listing
, and the anomalous “named list”, list
, whose future is uncertain. We test subcaptions here. Note that many different atomic items can go in a figure, and largely they will behave in a sidebyside
much as they do when placed in a panel all by themselves (i.e. captionless).

Organism | Classification |
Trout | Fish |
Monkey | Mammal |
Crow | Bird |
Crimini | Fungus |
Bee | Insect |
<figure>
and a <table>
n_loops <- 10
x.means <- numeric(n_loops)
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7))
x.means[i] <- mean(x)
}
x.means
We have named list of colors.
Blue
Red
Green
Purple
Violet
Brown
That was nice.
<listing>
and a <list>
figure
), and the bare amount which which is displayed in print. We could relax our common spacing to make it a bit better. Read about “side-by-side” groups (sbsgroup
) and experiment with stacking several sub-captioned videos into an overall captioned figure (Subsection 23.15). For other examples see Section 17 and Subsection 26.2.Section 25 Poetry
There is support for poems via thepoem
tag, which can contain a title
, author
and multiple stanza
, each containing multiple line
. See the source of the following poem for an example of the exact arrangement. Note how the first quote crosses two line
elements and how this is handled in the source. There are many very flexible options for horizontal alignment and indentation. Further extensive examples, constructed by Jahrme Risner, are available in the example Humanities document.
The Charge of the Light Brigade
Section 26 Atomic Objects
<image>
(next, 26.1). This section is arranged according to these objects and tests the various ways they can be employed.
We frequently include some nonsense text inside short intervening paragraphs to test spacing and establish margins.
Subsection 26.1 <image>
An <image>
can be placed in five different ways:
all by itself, as a peer of
<p>
typically, with layout control,inside a
<figure>
, earning a number and caption,inside a
<sidebyside>
, with size and layout configured,inside a
<figure>
inside a<sidebyside>
, with size and layout configured, with a number and caption, andinside a
<figure>
inside a<sidebyside>
inside a<figure>
, with size and layout configured, with a number and caption, but now sub-numbered ((a), (b), (c),…).



<sidebyside>
. Widths here are 20% and 30%, margins and gaps are automatic, default alignment on top edges. Nulla pharetra imperdiet elit, in sodales nibh blandit ultricies. Maecenas efficitur ac felis ut pharetra.


<figure>
with no adjustments, so default behavior. Note how a <figure>
occupies the entire width of the page, so then does the caption.

<figure>
with asymmetric (large) margins of 30% and 60%. Quisque finibus augue sit amet facilisis fringilla. Aenean faucibus augue tellus, et sollicitudin tortor finibus non.

<sidebyside>
. Same widths as previous <sidebyside>
but alignment on bottoms of the panels, to partially align captions. Note how the captions are constrained in width by the width of the panels of the side-by-side.


<figure>
, which has its own caption and number, leaving the interior figures to be sub-numbered. Cross-references use the full number: Figure 26.5.(b).


Subsection 26.2 <video>
An <video>
can be placed in five different ways:
all by itself, as a peer of
<p>
typically, with layout control,inside a
<figure>
, earning a number and caption,inside a
<sidebyside>
, with size and layout configured,inside a
<figure>
inside a<sidebyside>
, with size and layout configured, with a number and caption, andinside a
<figure>
inside a<sidebyside>
inside a<figure>
, with size and layout configured, with a number and caption, but now sub-numbered ((a), (b), (c),…).
<sidebyside>
. Widths here are 20% and 30%, margins and gaps are automatic, default alignment on top edges. Nulla pharetra imperdiet elit, in sodales nibh blandit ultricies. Maecenas efficitur ac felis ut pharetra.
<figure>
with no adjustments, so default behavior. Note how a <figure>
occupies the entire width of the page, so then does the caption.
<figure>
with asymmetric (large) margins of 30% and 60%. Quisque finibus augue sit amet facilisis fringilla. Aenean faucibus augue tellus, et sollicitudin tortor finibus non.
<sidebyside>
. Same widths as previous <sidebyside>
but alignment on bottoms of the panels, to partially align captions. Note how the captions are constrained in width by the width of the panels of the side-by-side.
<figure>
, which has its own caption and number, leaving the interior figures to be sub-numbered. Cross-references use the full number: Figure 26.12.(b).
Subsection 26.3 <program>
, <console>
A <program>
and/or <console>
can be placed in at least six different ways:
all by itself, as a peer of
<p>
typically, with layout controlinside a
<listing>
, earning a number and caption, with layout controlinside a
<sidebyside>
, with size and layout configuredinside a
<sidebyside>
, with size and layout configured, and inside a<figure>
inside a
<sidebyside>
, with size and layout configured, with each inside a<listing>
, earning different numbersinside a
<figure>
inside a<sidebyside>
inside a<listing>
, with size and layout configured, with a number and caption, but now sub-numbered ((a), (b), (c),…).
n_loops <- 10
x.means <- numeric(n_loops) # create a vector of zeros for results
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7)) # 1 to 6, uniformly
x.means[i] <- mean(x)
}
x.means
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
<console>
element, also with no layout control.
pi@raspberrypi ~/progs/chap02 $ gcc -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
<program>
with a @width
attribute, so centered and with equal margins. Note how the lines word wrap due to the smaller width.
n_loops <- 10
x.means <- numeric(n_loops) # create a vector of zeros for results
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7)) # 1 to 6, uniformly
x.means[i] <- mean(x)
}
x.means
<program>
with short lines, so significant, and asymmetric margins, which experimentally do not induce any word-wrapping.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
<console>
, with margins so significant the appearance is ill-advised.
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
<listing>
, with <caption>
, and no layout control.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
<listing>
, but now with layout control on the <program>
and <console>
.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
<sidebyside>
gives each panel a 30% width. The remaining 10% is apportioned for margins and separation.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
n_loops <- 10
x.means <- numeric(n_loops) # create a vector of zeros for results
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7)) # 1 to 6, uniformly
x.means[i] <- mean(x)
}
x.means
<sidebyside>
, but now inside of a <figure>
, earning a number and a <caption>
.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
pi@raspberrypi ~/progs/chap02 $ gcc -Wall -o intAndFloat intAndFloat.c pi@raspberrypi ~/progs/chap02 $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 pi@raspberrypi ~/progs/chap02 $
n_loops <- 10
x.means <- numeric(n_loops) # create a vector of zeros for results
for (i in 1:n_loops){
x <- as.integer(runif(100, 1, 7)) # 1 to 6, uniformly
x.means[i] <- mean(x)
}
x.means
<program>
and a smaller <console>
, each inside a <listing>
, as the two panels of a <sidebyside>
with no margins, and slightly different widths (to control word-wrapping). The panels have been aligned vertically so their captions align.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
$ gcc -Wall -o intAndFloat intAndFloat.c $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 $
<sidebyside>
of <listing>
, but now inside a <figure>
that has a number and a caption. And then the <listing>
are sub-numbered as (a) and (b).
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
$ gcc -Wall -o intAndFloat intAndFloat.c $ ./intAndFloat The integer is 19088743 and the float is 19088.742188 $
Subsection 26.4 <tabular>
A <tabular>
can be placed in six different ways:
all by itself, as a peer of
<p>
typically, with no layout control and hence with a “natural width,” and centeredall by itself, as a peer of
<p>
typically, with explicit layout control,inside a
<table>
, earning a number and title,inside a
<sidebyside>
, with size and layout configured,inside a
<table>
inside a<sidebyside>
, with size and layout configured, with a number and title, andinside a
<table>
inside a<sidebyside>
inside a<figure>
, with size and layout configured, with a number and title, but now sub-numbered ((a), (b), (c),…).
<tabular>
realized by LaTeX will normally be as wide as necessary to hold the content, without word-wrapping the content of any cell that is not explicitly authored that way. So for PreTeXt output as LaTeX, when you explicitly constrain the width (including use as a panel of a <sidebyside>
, or even setting margins) the table will be scaled, which can result in an apparent font size very different than the surrounding document. [NOT SURE HOW HTML WILL BEHAVE]
Data in a table form can be placed in amongst a series of paragraphs. With no layout control, it will occupy its “natural width” and be centered.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
@width
attribute have the value auto
, but do not specify any @margins
. We test multiple footnotes in a <tabular>
, not included in a <table>
.
State 1 | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 2 | 163,696 | 1850 |
<tabular>
can be placed with layout control. For LaTeX output, this will scale the table to fit within the explicit, or implicit, width. This can result in obvious differences in the apparent font size. We first have a @width
that is experimentally similar to the natural width, with asymetric margins. Then a narrow width, and a wide width, as an illustration.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
<tabular>
can be placed inside a <table>
, earning a number and a title.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
<sidebyside>
in various ways and with various sizes. First, two <tabular>
as panels with widths at 60% and 30%.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
3 | 9.734 |
5 | 2.175 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
3 | 9.734 |
5 | 2.175 |
<sidebyside>
with just a 2% gap, and no side margins.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
3 | 9.734 |
5 | 2.175 |
<table>
, grouped and laid out via a <sidebyside>
, and collected as a <figure>
. Which causes sub-numbering of the enclosed <table>
.
State | Population | Area (sq. mi.) | Statehood (Year) |
---|---|---|---|
Washington | 7,614,893 | 71,362 | 1889 |
Oregon | 4,217,737 | 98,381 | 1859 |
California | 39,512,223 | 163,696 | 1850 |
3 | 9.734 |
5 | 2.175 |
Section 27 Advanced Numbering
0
through 3
for the numbering.theorems.level
parameter to see how these numbers change accordingly. It is easiest to compare if you use chunk.level < 2
so the theorems all land on the same page if you are previewing in HTML.Subsection 27.1 One
A document leaf.Theorem 27.1 (Cauchy). First Theorem.
No statement.
Theorem 27.2 (Bunyakovsky). Second Theorem.
No statement.
Subsection 27.2 Two
Subsubsection 27.2.1 Uno
A document leaf.Theorem 27.3 (Schwarz). First Theorem!
No statement.
Theorem 27.4 (Inequality). Second Theorem?
No statement.
Subsubsection 27.2.2 Dos
A document leaf.Theorem 27.5. First Theorem?
No statement.
Theorem 27.6. Second Theorem!
No statement.
Subsection 27.3 Three
A document leaf.Theorem 27.7. First Theorem.
No statement.
Theorem 27.8. Second Theorem.
No statement.
Subsection 27.4 Four
Theorem 27.9. Good Numbered Theorem One.
No statement.
Theorem 27.10. Good Numbered Theorem Two.
No statement.
Subsubsection 27.4.1 Uno
A document leaf.Theorem 27.11. First Theorem.
No statement.
Theorem 27.12. Second Theorem.
No statement.
Subsubsection 27.4.2 Dos
A document leaf.Theorem 27.13. First Theorem.
No statement.
Theorem 27.14. Second Theorem.
No statement.
--stringparam numbering.theorems.level 3
in the xsltproc
invocation. See this GitHub issue for details.
Theorem 27.15. Bad Numbered Theorem One.
No statement.
Theorem 27.16. Bad Numbered Theorem Two.
No statement.
Subsection 27.5 Five
A document leaf.Theorem 27.17. First Theorem.
No statement.
Theorem 27.18. Second Theorem.
No statement.
Subsection 27.6 Theorems in This Section
We have a lot of theorems in this section, so we illustrate including an automatic list of these here. We use theelements
attribute to limit the list to theorem
elements, and we use the scope
attribute to limit the list to this section
. You can use an introductory p
like this one, or not. The list gets no title or visual separation, so use the usual subdivision elements to make that happen. The elements
attribute can be a space-delimited list of many different elements. This list should not include the Fundamental Theorem of Calculus, Theorem 2.1. See a slightly different example in Appendix F.
Subsection 27.7 A Title with ] a Right Bracket
LaTeX has trouble with brackets that end up inside optional arguments, so this subsection title is only a check on the defense against that. And now an<exercise>
with a title that could really be a problem.
Checkpoint 27.19. A Right Brace } and a Right Bracket].
The right brace is is used as a grouping character in LaTeX so this is just a test of its behavior in titles.
A faux hint to get this exercise to migrate into a <solutions>
.
Subsection 27.8 A Title with } a Right Brace
And now a right brace in a division title.
Subsection 27.9 A Title with a Math Right Bracket
And now a right bracket within math in a division title.
We do not test a right brace within math, since it should be escaped, as is normal LaTeX practice.Subsection 27.10 Just an Exercise
Checkpoint 27.20. An Extraneous Exercise.
This exercise is here just as a test of the <solutions>
division coming next. So it is serving a purpose, even if it is not apparent.
A hint, so this exercise looks identical in structure to the one in the previous subsection.
Solutions 27.11 Solutions
<solutions>
division, which will be a peer of the other <subsection>
in this <section>
. The default behavior is to look to the parent division (a <section>
here) and collect all the hints, answers, and solutions from every <exercise>
(and friends) inside this containing division. (There are just two, similar inline <exercise>
.)
But instead of the default, we employ a @scope
attribute to define the parent division of the exercises whose solutions will be shown. In this example we specify the <subsection>
that is two back, the one which tests brackets in titles.Checkpoint 27.19. A Right Brace } and a Right Bracket].
Section 28 Customizations
Subsection 28.1 Renaming Document Parts, Plus This Is A Really Long Title So That We Can Test How Well It Reacts To The Right Margin And Wraps Around To Form A Couple Of Lines, Plus How It Sits Relative To The Number Of The Subsection
“Names” for various parts of a document are determined exactly once for each language, ensuring consistency and saving you the bother of always typing them in. However, you may want to have “Conundrum”s in your document and you have no use for any “Proposition”s. So you can repurpose theproposition
tag to render a different name. Or you might have a Lab Manual and want to rename subsection
as “Activity”. See the docinfo
portion of this sample article to see how this is done, in concert with the example below. Note that you may provide versions for different languages by specifying a @xml:lang
attribute.
Conundrum 28.1 (Smith).
Aah, this is confusing!
Important Notes.
If you are renaming many parts of your document, then you may not understand the design philosophy of PreTeXt. In particular, you should not be doing a wholesale shuffle ofpart
, chapter
, section
, etc. This feature is intended for very limited use and is not considered best practice.
This feature could also be abused to provide a comprehensive suite of translations into a language not yet supported. If so, please contact us about moving your translations into PreTeXt for the benefit of all. Thanks.Subsection 28.2 Customizing Phrases
There is a facility for providing alternate text for small or short phrases, or other components of a paragraph. Here we just provide some tests. Each is inside of a block quote to identify it clearly. We have two auxiliary files of custom elements, so you need to adjust the publisher file to specify the second one during testing. First, a very simple string as the variation.Now a string which is partially text and partially simple markup.This is an article about [MISSING CUSTOM CONTENT HERE].
And a mildly more complicated structure (a list) as the variable text.We like to write with [MISSING CUSTOM CONTENT HERE].
A cross-reference to test, since context is critical.Some of our favorite colors are[MISSING CUSTOM CONTENT HERE]
The URLs used as a replacement have theSee also [MISSING CUSTOM CONTENT HERE].
@visual
attribute which is also managed by the assembly pre-processor to provide a footnote. So this is a good test of the organization of the multiple passes employed by the pre-processor.
A URL that should have a footnote: [MISSING CUSTOM CONTENT HERE].
Section 29 MyOpenMath Interactive Problems
This is a test with two inline exercises containing MyOpenMath (MOM) problems. None of this is in the schema, and all of it is subject to change.Checkpoint 29.1. Negative Numbers and Exponents.
This is an introduction, providing articulation between the MOM problem and the contents of the text. For example, you might cross-reference a result or example given previosly. (HTML Note: The resizer for the knowl is not functioning yet.)
Checkpoint 29.2. A Statistical Test.
This is an introduction, providing articulation between the MOM problem and the contents of the text. For example, you might cross-reference a result or example given previosly. (HTML Note: The resizer for the knowl is not functioning yet.)
Section 30 Ancillaries
Once your content is in place, you can begin thinking about various useful derivative works. A natural example for a textbook is an “Instructor's Version”. Various switches for hints, answers, and solutions to exercises would allow you to include more of these for the use of just an instructor. Here we also demonstrate the<commentary>
element. It is similar in many ways to a <paragraphs>
in that it can be placed within any division and must be titled. The main difference is that it is not displayed by default, so you must set a processing switch to enable its appearance:
xsltproc -stringparam commentary yes ...Other distinctions are:
Since it is elective, you need to be careful about cross-references to and from a
<commentary>
. It is highly likely that you will want to make cross-references within a<commentary>
pointing to other portions of your text, and this is always a good idea. You will want to avoid making cross-references to a<commentary>
from other parts of the text, with the exception of a cross-reference that originates within some<commentary>
.Numbered items are prohibited within a
<commentary>
, such as a<figure>
or a<theorem>
. Doing so would disrupt consecutive numbering in different versions, with or without,<commentary>
included. Numbered equations are not prohibited in the schema, but should definitely be avoided anyway.
<commentary>
with two paragraphs. For the online version of this sample article, we have enabled commentaries. But if you are experimenting yourself, you will want to be aware if you are enabling these or not.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam odio orci, ullamcorper eget quam et, viverra tristique magna. Integer auctor arcu a sapien pulvinar elementum. Mauris porta, nulla id molestie dignissim, urna dolor rutrum ligula, eu elementum odio nisl sed libero. Nulla nec libero sem.
Sed justo ex, efficitur dictum risus nec, eleifend consequat nibh. Proin rutrum mi id metus viverra blandit. In vel ligula a nibh aliquam pellentesque. Duis placerat purus et ligula sollicitudin, sodales consectetur ante viverra.
Mauris fringilla nulla arcu, sagittis ultrices quam malesuada eleifend. Proin tristique elit eu bibendum tincidunt. Donec commodo lorem in magna egestas, vitae malesuada velit ornare. Pellentesque finibus neque in venenatis tristique. In id blandit est, in euismod urna. Donec commodo sagittis ligula, in venenatis nulla porttitor in. Donec nec tortor sit amet felis posuere ultricies. Suspendisse euismod quis ex eu placerat.Section 31 Worksheets
Subsection 31.1 About Worksheets
This is a section full of worksheets. Each is a division of its own, via the<worksheet>
element. This is a necessary initial <subsection>
to the current <section>
, since we will have multiple worksheets. In practice you might want to rip out all the worksheets of an entire book and bundle them up as an “activity book.”
If you make PDF output you will notice an increased amount of control over layout. Also, with the command-line argument
-stringparam latex.draft yesthere will be visual indicators of prescribed whitespace.
Worksheet 31.2 A Geometric Prelude
Objectives
Practice visualizing vector addition
Use vectors without explicit coordinates
1.
What is the value of
2.
Show that
3.
To show that the point
4.
If you have time, try to devise a vector proof of Euclid's result presented at the beginning of the workshop. Recall that a parallelogram is a four-sided polygon whose opposite sides are parallel.
Wrap-up.
It's possible to do interesting things with vector arithmetic in a coordinate-free way: we didn't specify an origin, or any entries of any vectors in the examples.Worksheet 31.3 Networks Worksheet
Basic laws for electrical circuits.
This two-page worksheet was generously donated to the sample article by Virgil Pierce at a CuratedCourses workshop in August 2018. It has default (skinny) left and right margins, but we have specified longer top and bottom margins, with the top being the larger of the two.Theorem 31.5. Ohms Law.
The current through a resistor is proportional to the ratio of the Voltage to the Resistance
Or for our purposes
Theorem 31.6. Kirchoffs Current Law.
The sum of the currents in a network meeting at a point is zero.
Example 31.7. Kirchoff's Current Law.
For the circuit below \(I_1 + I_2 = I_3 \text{.}\)
Theorem 31.8. Kirchoffs Voltage Law.
The sum of the voltages around any closed circuit (or subcircuit) is zero.
1.
For the simple network pictured, calculuate the amperage in each part of the network by setting up a system of linear equations for the amperages.
2.
Compare it with a parallel circuit network. Calculate the amperage in each part of the network by setting up a system of linear equations for the amperages.
3.
Now for a more complicated network. Calculate the amperage in each part of the network by setting up a system of linear equations for the amperages.
4.
Now generalize these ideas to a context outside of electrical circuits. Consider the network of streets given in the diagram (with one-way directions as indicated).
A traffic engineer counts the hourly flow of cars into and out of this network at the entrances. They get (EB = East Bound; WB = West Bound):
EB Winooski | WB Winooski | Shelburne St | Willow | Jay | |
into | 50 | 400 | 0 | 10 | 50 |
out of | 55 | 390 | 20 | 15 | 30 |
Use a variable for each segment inside of the network and set up a system of linear equations restricting the flow. Solve the system. Note that you should not get a unique solution as traffic should be able to flow through the network in various ways.
Worksheet 31.4 Worksheet
1.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
2.
Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
3. A full-width exercise.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
4.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
5.
Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
6.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
Activity 31.1. A Mock Activity.
The problem, as we see it.
A worksheet could have hints, no? But no spacing. Note row below has widths set to balance the heights.
7.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
8.
Integer sagittis dictum turpis vel aliquet. Fusce ut suscipit dolor, nec tristique nisl. Aenean luctus, leo et ornare fermentum, nibh dui vulputate leo, nec tincidunt augue ipsum sed odio. Nunc non erat sollicitudin, iaculis eros consequat, dapibus eros.
9.
Praesent rutrum scelerisque felis sit amet adipiscing. Phasellus in mollis velit. Nunc malesuada felis sit amet massa cursus, eget elementum neque viverra.
Worksheet 31.5 Dot products and projection
1.
Let
(a)
(b)
(c)
(d)
(e)
Are any of these vectors perpendicular to each other?
2.
The vectors

3.
Consider the vector equation
(a)
Check that there is no solution
(b)
Use projection to find the best approximation
(c)
Compute
(d)
Compute the residual vector.
(e)
Compute the length of the residual vector and explain what it means.
Section 32 Exercises, One Subsection
This<section>
of the sample article demonstrates an “unstructured division.” There are no <subsection>
, you are just reading the first two paragraphs, followed by some nonsense text. Then there is a single <exercises>
division. Note that this division is not numbered (since it is unique within the <section>
). And a cross-reference to one of the contained <exercise>
will be numbered as a member of the <section>
, Exercise 32.4.
If you use the unstructured form of a division, and have both inline and divisional exercises, there is a potential to form ambiguous cross-references. To wit, check that 32.2 and 32.2 are really different exercises (which you are unable to do if you are reading this in print!). The solution is to include the type of exercise in the reference, which will assist everybody, but especially your print readers: Checkpoint 32.2 and Exercise 32.2.
Compare this section with the similar Section 34, next. The following text is mostly nonsense, just for testing purposes.
Checkpoint 32.1. Inline One.
Aliquam vitae risus placerat, pellentesque leo vitae, iaculis ante. Praesent ac odio eget mi bibendum eleifend ac eget metus. Morbi in dolor et diam accumsan mattis. Aenean elementum pulvinar efficitur. Etiam viverra ut tellus quis consequat. Phasellus sit amet nisl a ligula pharetra tempus id in elit. Maecenas congue quam eu purus fermentum pretium. Fusce pellentesque ultricies arcu, egestas sollicitudin erat condimentum non. Integer non velit at dolor dictum aliquam et rhoncus mauris. Sed nec nibh id nunc convallis tincidunt ut at ligula. Etiam elementum nisl eu erat dapibus rhoncus.
Checkpoint 32.2. Inline Two.
Ut porttitor neque a pharetra euismod. Vivamus ut metus pretium, placerat massa tempor, condimentum metus. Phasellus vestibulum iaculis turpis non posuere. Vestibulum quis aliquet neque. Donec nec metus iaculis, laoreet massa vitae, suscipit tellus. Etiam et ultrices quam, quis pretium ligula. In ut cursus metus. Aenean volutpat quam odio, quis tempus dolor egestas eget. Nunc fringilla lobortis nunc, ut interdum lorem posuere sed. Sed sodales risus a laoreet venenatis. Nunc sodales tempor mollis. Nam sollicitudin velit sed ex viverra feugiat. Nunc consectetur mi vitae urna sollicitudin malesuada. Fusce eget risus lectus. Mauris augue velit, vestibulum vitae tempus sit amet, porttitor eget turpis.
Theorem 32.3. Major Result.
Vivamus tortor tortor, lobortis et sem vel, accumsan placerat libero. Sed eget metus non magna accumsan efficitur a non turpis. Curabitur maximus arcu ipsum, eget vestibulum nulla mollis ac. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis vel eleifend risus. Morbi hendrerit tellus eget nibh imperdiet, ac mollis nisl sagittis. Ut commodo pharetra leo. Suspendisse consequat velit eget velit condimentum feugiat.
Checkpoint 32.4. Inline Three.
Suspendisse lacinia mattis risus, eget viverra urna dictum eu. Maecenas ut sem in turpis egestas varius nec at ipsum. Praesent bibendum nisi et turpis congue, a pellentesque felis tempor. Vivamus non dolor in risus interdum mattis. In tempus iaculis velit, sit amet rhoncus tellus aliquam convallis. Sed ut tellus id ipsum blandit convallis sed eget tortor. Nunc leo felis, scelerisque vel ante porta, volutpat rhoncus neque. Mauris convallis, felis at aliquam aliquet, felis ipsum semper mi, vitae auctor purus ante non erat. Ut nec felis mi.
Exercises Exercise Collection
1. Drill One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.

<exercise>
in an unstructured division to test that it is numbered as if the containing <exercises>
is not present

<exercise>
in an unstructured division to test that it is numbered as if the containing <exercises>
is not present and to test the numbering of the panels in a solutions manual

2. Drill Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.

<exercise>
in an un-numbered <exercises>
3. Drill Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
4. Challenging One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
Exercise Group.
An introduction to an exercisegroup
. This is here to attempt to interrupt the flow of the counting from this division to the next.
5. Challenging Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
6. Challenging Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
7. Impossible One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
8. Impossible Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
9. Impossible Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
References More Reading
Exercises 33 Exercise Section, Structured
<exercises>
division, structured with <subexercises>
.Easy Exercises
1. Arithmetic.
Compute
\(7\)
2. Trigonometry.
Compute
Hard Problems
3. Number Theory.
Prove Fermat's Last Theorem.
4. Millenial.
Find general solutions to the Navier-Stokes equation.
With an Exercise Group
Exercise Group.
This is an exercise group, and this is its introduction.
7. Outside exercisegroup, inside subexercises.
6+5
Section 34 Exercises, Multiple Subsections
<section>
of the sample article demonstrates a “structured division.” You are reading the introduction to the division, then there is a faux <subsection>
, followed by three <exercises>
divisions. Note that the three are numbered as if they are also fellow<subsection>
. And a cross-reference to one of the contained <exercise>
will be numbered use the number of the <subsection>
, Exercise 34.3.1.
Compare this section with the similar Section 32, previous. The following text is mostly nonsense, just for testing purposes.Subsection 34.1 Faux Subsection
Checkpoint 34.1. Inline One.
Aliquam vitae risus placerat, pellentesque leo vitae, iaculis ante. Praesent ac odio eget mi bibendum eleifend ac eget metus. Morbi in dolor et diam accumsan mattis. Aenean elementum pulvinar efficitur. Etiam viverra ut tellus quis consequat. Phasellus sit amet nisl a ligula pharetra tempus id in elit. Maecenas congue quam eu purus fermentum pretium. Fusce pellentesque ultricies arcu, egestas sollicitudin erat condimentum non. Integer non velit at dolor dictum aliquam et rhoncus mauris. Sed nec nibh id nunc convallis tincidunt ut at ligula. Etiam elementum nisl eu erat dapibus rhoncus.
Checkpoint 34.2. Inline Two.
Ut porttitor neque a pharetra euismod. Vivamus ut metus pretium, placerat massa tempor, condimentum metus. Phasellus vestibulum iaculis turpis non posuere. Vestibulum quis aliquet neque. Donec nec metus iaculis, laoreet massa vitae, suscipit tellus. Etiam et ultrices quam, quis pretium ligula. In ut cursus metus. Aenean volutpat quam odio, quis tempus dolor egestas eget. Nunc fringilla lobortis nunc, ut interdum lorem posuere sed. Sed sodales risus a laoreet venenatis. Nunc sodales tempor mollis. Nam sollicitudin velit sed ex viverra feugiat. Nunc consectetur mi vitae urna sollicitudin malesuada. Fusce eget risus lectus. Mauris augue velit, vestibulum vitae tempus sit amet, porttitor eget turpis.
Theorem 34.3. Major Result.
Vivamus tortor tortor, lobortis et sem vel, accumsan placerat libero. Sed eget metus non magna accumsan efficitur a non turpis. Curabitur maximus arcu ipsum, eget vestibulum nulla mollis ac. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis vel eleifend risus. Morbi hendrerit tellus eget nibh imperdiet, ac mollis nisl sagittis. Ut commodo pharetra leo. Suspendisse consequat velit eget velit condimentum feugiat.
Checkpoint 34.4. Inline Three.
Suspendisse lacinia mattis risus, eget viverra urna dictum eu. Maecenas ut sem in turpis egestas varius nec at ipsum. Praesent bibendum nisi et turpis congue, a pellentesque felis tempor. Vivamus non dolor in risus interdum mattis. In tempus iaculis velit, sit amet rhoncus tellus aliquam convallis. Sed ut tellus id ipsum blandit convallis sed eget tortor. Nunc leo felis, scelerisque vel ante porta, volutpat rhoncus neque. Mauris convallis, felis at aliquam aliquet, felis ipsum semper mi, vitae auctor purus ante non erat. Ut nec felis mi.
Exercises 34.2 Drill Exercises
1. Drill One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.

<exercise>
in a structured division to test that it is numbered with consideration of the containing <exercises>
2. Drill Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
3. Drill Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
Exercises 34.3 Challenging Exercises
1. Challenging One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
Exercise Group.
An introduction to an exercisegroup
. This is here to attempt to interrupt the flow of the counting from this division to the next.
2. Challenging Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
3. Challenging Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
Exercises 34.4 Impossible Exercises
1. Impossible One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
2. Impossible Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
3. Impossible Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
References 34.5 More Reading
Exercises 35 Exercises, Top-Level
<exercises>
of the sample article is a peer of all the preceding <section>
and is the only such <exercises>
. As such, it is not numbered, and contains only <exercise>
, but for this <introduction>
you are reading. The <exercises>
contained within will be numbered in cross-references according to the enclosing division, in this case the entire article and so without any qualification, to wit, Exercise 35.4.1. Drill One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
2. Drill Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.

<exercises>
without a number3. Drill Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
4. Challenging One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
Exercise Group.
An introduction to an exercisegroup
. This is here to attempt to interrupt the flow of the counting from this division to the next.
5. Challenging Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
6. Challenging Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
7. Impossible One.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras congue urna nulla. Aliquam eget euismod tellus. Maecenas nibh libero, venenatis a laoreet in, tempor sit amet sem. Morbi sit amet justo tempor velit auctor placerat. Maecenas nec lobortis orci. Aenean dictum enim lacus, ac blandit lacus elementum nec. Mauris porttitor neque volutpat tincidunt sollicitudin. Cras porta lectus ac facilisis tempor. Suspendisse in velit nisl. Sed convallis leo at nunc aliquet fermentum. Pellentesque feugiat at ex sed elementum. In porta vulputate ipsum sit amet consectetur.
8. Impossible Two.
Aliquam sagittis ex at magna porttitor, quis scelerisque ligula malesuada. Vestibulum vitae mauris id nisi pretium ornare a id lectus. Nam suscipit magna id sem ultricies vestibulum. Nulla facilisi. Duis venenatis lectus massa, ac mollis nisi suscipit non. Sed et sapien vulputate, imperdiet nibh vel, lobortis nisl. Curabitur sagittis justo nibh. Nulla vulputate sodales justo at efficitur. Cras justo augue, mollis vitae nulla sed, vestibulum tincidunt ante. Vestibulum et lorem lectus. Maecenas accumsan lacus a nisi euismod rutrum eu dapibus justo. Etiam scelerisque a odio a euismod. Pellentesque vestibulum pellentesque nisi, a tempus erat cursus ac. Morbi ut auctor lectus.
9. Impossible Three.
Nam congue ex nec justo iaculis maximus. Vestibulum lobortis magna sed urna auctor, vel dignissim massa posuere. In sed venenatis elit. Vivamus congue gravida tempus. Nunc quis fermentum nisi. Nullam hendrerit lorem et tellus semper, sit amet scelerisque purus lobortis. Quisque sollicitudin quis neque eu suscipit. Praesent volutpat justo quis magna vehicula molestie.
10. An Exercise in a Section.
Exercises can appear in a “section” of their own. You need to give the section a title, even if it seems obvious what to call it. Individual exercises may have titles, as you choose. Problem: How should we hide solutions?
Maybe a global switch should be used to suppress solutions, while a separate processing regime could use them as part of a solutions manual.
42a. An Exercise with a Hard-Coded Problem Number.
Compute the definite integral
An antiderivative of \(x^2\) is \(F(x)=x^3/3\text{,}\) so by the FTC,
This is indeed an exciting result, but we are mostly interested in seeing that the sentence-ending punctuation is absorbed properly into the displayed equation.
12.
Can you prove Corollary 4.1 directly? If not consider that a problem could have several parts, which should be formatted as a second-level list, since the problems normally get numbered at the top level.
Why is this result a Corollary?
Could you interchange the Theorem and Corollary?
Consider the definite integral as an area function and employ the Mean Value Theorem.
Think harder!
It follows easily.
Yes.
We could prove either result first, then obtain the other as an easy consequence.
Appendix A Notation
This is some notation introduced in the article. PreTeXt allows the “notation list” generator anywhere, so we have this paragraph to test spacing above and below the table. We'll say that again. This is some notation introduced in the article. PreTeXt allows the “notation list” generator anywhere, so we have this paragraph to test spacing above and below the table. We'll say that again.Symbol | Description | Location |
---|---|---|
definite integral of |
Paragraph | |
indefinite integral of |
Definition 2.2 | |
this symbol could be used for lots of things, but we are just trying to make a super-long description to get it to wrap within the column where it belongs, which is sometimes set to a fixed width to accomodate really complicated explanations | Paragraph | |
(ring of) integers modulo |
Paragraph | |
gradient operator | Paragraph |
Solutions B Solutions to Selected Exercises
Section 4 An Interesting Corollary
Subsection 4.2 A Pedagogical Note about Subsection 4.1
Subsubsection 4.2.1 Symbolic and Numerical Integrals
Checkpoint 4.4. Essay Question: Compare and Contrast.
Subsubsection 4.2.3 Advice
Checkpoint 4.7. An Inline Exercise.
Activity 4.3. Hints, Answers, Solutions.
Checkpoint 4.10. A very structured exercise.
(c) A title of a task that has a subtask with an <answer>
for the Solutions.
(i) A task with a title and an <answer>
for the Solutions.
(ii)
(d)
Project 4.4. A very structured project.
(c)
(i)
(ii)
(d)
Exercises 4.2.4 Exercises
4.2.4.1.
Section 11 Further Reading
Exercises 11.3 More Exercises
Section 21 Program Listings
Checkpoint 21.9. Inline Coding Exercise, No Help.
Checkpoint 21.10. Inline Coding Exercise, Partial.
Section 27 Advanced Numbering
Subsection 27.7 A Title with ] a Right Bracket
Checkpoint 27.19. A Right Brace } and a Right Bracket].
Subsection 27.10 Just an Exercise
Checkpoint 27.20. An Extraneous Exercise.
Section 31 Worksheets
Worksheet 31.2 A Geometric Prelude
31.2.2.
Exercises 33 Exercise Section, Structured
Easy Exercises
33.1. Arithmetic.
With an Exercise Group
33.5. One.
Exercises 35 Exercises, Top-Level
35.10. An Exercise in a Section.
35.42a. An Exercise with a Hard-Coded Problem Number.
35.12.
Solutions C Solutions to a Single Exercises Division
<exercises>
division (or similar, like a <worksheet>
). Default behavior in this situation can produce two titles, when just one would be sufficient. Here we have used the @scope
attribute to point to a specific <exercises>
, and provided a (single) very specific <title>
.Solutions D All Solutions that are Answers
<answer>
, and only <answer>
, of all types of exercises: inline, divisional, worksheet, reading questions, and projects. Now, as observed by Bruce Yoshiwara, it gets a bit tedious to see the “Answer” heading over and over in print, when every entry has that heading. So we squelch it for you in print/PDF output. (For HTML output we use knowls and need to have something to click on. But perhaps for EPUB we should be more careful?) Note that you might want to use a <title>
, or an <introduction>
, that explains which component of the exercises is being displayed, so there is no confusion.Section 4 An Interesting Corollary
Subsection 4.2 A Pedagogical Note about Subsection 4.1
Subsubsection 4.2.3 Advice
Checkpoint 4.7. An Inline Exercise.
Activity 4.3. Hints, Answers, Solutions.
Checkpoint 4.10. A very structured exercise.
(c) A title of a task that has a subtask with an <answer>
for the Solutions.
(i) A task with a title and an <answer>
for the Solutions.
(ii)
(d)
Project 4.4. A very structured project.
(c)
(i)
(ii)
(d)
Section 11 Further Reading
Exercises 11.3 More Exercises
Section 21 Program Listings
Checkpoint 21.10. Inline Coding Exercise, Partial.
Exercises 33 Exercise Section, Structured
Easy Exercises
33.1. Arithmetic.
Exercises 35 Exercises, Top-Level
35.12.
Solutions E All Solutions that are Answers to Odd Exercises
@admit
attribute).Section 4 An Interesting Corollary
Subsection 4.2 A Pedagogical Note about Subsection 4.1
Subsubsection 4.2.3 Advice
Checkpoint 4.7. An Inline Exercise.
Activity 4.3. Hints, Answers, Solutions.
Section 11 Further Reading
Exercises 11.3 More Exercises
Exercises 33 Exercise Section, Structured
Easy Exercises
33.1. Arithmetic.
Appendix F List of Results
We had an automatic list of theorems for just one section, back in Subsection 27.6. Here we expand to includecorollary
in our space-delimited list of elements
and we request divisions
(headings) at each subsection
and section
. The default scope
is the entire document, which is appropriate here in the backmatter. There are many subsections with no results, so we set the empty
attribute to no
to suppress them, though this is the default behavior (yes
being the other option to see divisions with no list items). These lists are most valuable if you are in the practice of giving items titles.
Section 2 The Fundamental Theorem
Section 4 An Interesting Corollary
Subsection 4.1 Second Version of FTC
Section 21 Program Listings
Section 27 Advanced Numbering
Subsection 27.1 One
Subsection 27.2 Two
Subsection 27.3 Three
Subsection 27.4 Four
Subsection 27.5 Five
Section 31 Worksheets
Section 32 Exercises, One Subsection
Section 34 Exercises, Multiple Subsections
Subsection 34.1 Faux Subsection
Appendix G Lists of Exercises
Since<exercise>
come in several flavors, we use pseudo-elements to specify the distinct types. There are not many reading questions—but here is a list of all of them, by section, using a readingquestion
pseudo-element.
Section 4 An Interesting Corollary
And now a list of all the inline exercises, and including the title of every<section>
, even if there is no inline exercise contained inside it. The pseudo-element is inlineexercise
.
Section 1 Introduction
Section 2 The Fundamental Theorem
Section 3 Computing Integrals with Sage ( )
Section 4 An Interesting Corollary
Section 5 Some Facts and Figures
Section 6 Some Advanced Ideas
Section 7 Mathematics
Section 8 Entering Text in Paragraphs, Titles, Captions
Section 9 Graphics
Section 10 Demonstrations
Section 11 Further Reading
Section 12 List Calisthenics
Section 13 Table Calisthenics
Section 14 Interactive Elements, Authored in Javascript
Section 15 Interactive Elements, Server
Section 16 Audio
Section 17 Video
Section 18 Cross-Referencing
Section 19 Internationalization
Section 20 Pre-Formatted Text
Section 21 Program Listings
Section 22 Units of Measure
Section 23 Side-By-Side Panels
Section 24 Side-by-Side Gallery
Section 25 Poetry
Section 26 Atomic Objects
Section 27 Advanced Numbering
Section 28 Customizations
Section 29 MyOpenMath Interactive Problems
Section 30 Ancillaries
Section 31 Worksheets
Section 32 Exercises, One Subsection
Section 34 Exercises, Multiple Subsections
Appendix H A Structured Appendix
Subsection H.1 A Subsection in an Appendix
Subsubsection H.1.1 A Subsubsection in a Subsection in an Appendix
Nearly terminal.Paragraphs in a Subsubsection in a Subsection in an Appendix.
Theparagraphs
element can go in any division, but does not get a number.Appendix I Index
There is an index manufactured at the end of the back matter. So we are talking about it here, rather than within the index, which is an impossibility. It contains some sample entries, and is not meant to be comprehensive. Look at the source of this XML file, searching on<idx>
, to see how they are written. They may be placed inside of a a variety of structures, and their location greatly influences the cross-references produced in the HTML version of the index.
The LaTeX version of the index is more traditional, using page numbers to reference locations. A newer package is used to create the index, and so there is no extra intermediate step required to process the index. The one downside of this convenience is that index entries may not be placed in the back colophon (which is the only subdivision that may follow the index).
There is an index entry about multicolumn lists which spans more than one page. This requires doubly-linked index entries, the first has the index content and points to the xml:id
of the second. The second is an empty element, but points back to the xml:id
of the first entry. So each has a marker and a reference, which allows the span of the index topic to cut across XML boundaries in the source. This is the mechanism to produce a page range in the LaTeX index. See the source of this article for syntax details.
Bully Pulpit: Index Headings.
Professionals do not capitalize the headings (entries) of an index, unless it is a proper noun (name, place, etc.). We do not provide any enforcement of this advice, nor any assistance. It is your responsibility to provide quality source material in this regard.Note.
Most all of the index entries below to page 2 (PDF output) are just from a suite of non-sensical tests. These are harder to recognize in the HTML output.Appendix J Multiple References
Subsection J.1 Multiple Specialized References
You might want to have lists of references, in the back, but with multiple such lists. Make an<appendix>
to hold them, give it some structure (for an <article>
, a leading <subsection>
, such as the one you are reading right now), then follow with multiple <references>
divisions. A typical citation will then look like: [J.3.2].References J.2 General References
References J.3 Specialized References
References References
Another online, open-source offering.
Index Index
cancelto
macro, Paragraph