Some PreTeXt objects are relatively indivisable and are used as components of other structures. We call them atomic, even if the term is not perfect. A good example is <image> (next, 30.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.
Subsection30.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, and
inside 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),…).
Examples of each, and more.
All by itsef, with no layout specified, so showing the default size and placement. Vivamus in congue massa. Morbi condimentum ac magna at accumsan. Vestibulum ac augue eu lorem semper gravida.
Width set at 40%, so equal margins and thus centered. Aenean faucibus augue tellus, et sollicitudin tortor finibus non. Maecenas semper dolor quis diam placerat, iaculis sollicitudin augue finibus. Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non.
Asymmetric margins of 20% and 40% given, implying 40% width, equal to previous instance. Vivamus suscipit diam eget mi cursus viverra.
As a plain component of a <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.
Inside a <figure> with no adjustments, so default behavior. Note how a <figure> occupies the entire width of the page, so then does the caption.
Figure30.1.New Zealand Landscape
Inside a <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.
Figure30.2.New Zealand Landscape
Inside figures inside a <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.
Figure30.3.NZ Landscape
Figure30.4.New Zealand Terrascape
Identical code to previous example, but now wrapped in an overall <figure>, which has its own caption and number, leaving the interior figures to be sub-numbered. Cross-references use the full number: Figure 30.5.(b).
(a)NZ Landscape
(b)New Zealand Terrascape
Figure30.5.Amalgamation of Scapes
For LaTeX, in some circumstances it is desirable to print the image on the next line, but backed up by some amount. This “top-aligns” the image with a number of some sort off to the left. The following are tests for this behavior. Here is a list.
A rotation="n" attribute applied to a bare image will rotate the image by n°. The vertical space adjusts to accomodate the rotated image in the latex version but not in the html version.
(a)rotate="180"
(b)rotate="15"
Figure30.6.Rotated Images
For pdf output destined for print, i.e. when the publication file entry latex/@print="yes", a @landscape="yes" attribute applied to a <figure>, <table>, <list> or <listing> will cause the object to be rotated 90° and presented on its own page. Placement of the float is determined by LaTeX and multipage objects are not supported.
Figure30.7.This landscape figure will be rotated so the long edge is vertical, and will appear on its own page in print PDF output.
(a)Quack
(b)Propulsion System
Figure30.8.Wide figure containing a sidebyside containing a rotated image. This will be rotated and appear on its own page in print PDF output.
Checkpoint30.9.
(a)
(b)
ExercisesExercises
1.
(a)
(b)
Exercise Group.
2.
3.
Subsection30.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, and
inside 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),…).
Examples of each, and more.
Videos can be realized in many forms, and can come from a variety of sources. See Section 20 for tests of some of that variety. Here we are testing placement within surroundings and testing the schema for location. But we do have two videos in each test, one provided as a local file and one embedded from a service.
All by itsef, with no layout specified, so showing the default size and placement. Vivamus in congue massa. Morbi condimentum ac magna at accumsan. Vestibulum ac augue eu lorem semper gravida.
Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non. Quisque ornare felis arcu. Vivamus suscipit diam eget mi cursus viverra.
Width set at 40%, so equal margins and thus centered. Aenean faucibus augue tellus, et sollicitudin tortor finibus non. Maecenas semper dolor quis diam placerat, iaculis sollicitudin augue finibus. Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non.
Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non. Quisque ornare felis arcu. Vivamus suscipit diam eget mi cursus viverra.
Asymmetric margins of 20% and 40% given, implying 40% width, equal to previous instance. Vivamus suscipit diam eget mi cursus viverra.
Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non. Quisque ornare felis arcu. Vivamus suscipit diam eget mi cursus viverra.
As a plain component of a <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.
Inside a <figure> with no adjustments, so default behavior. Note how a <figure> occupies the entire width of the page, so then does the caption.
Figure30.10.University of Puget Sound Promotional Video
Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non. Quisque ornare felis arcu. Vivamus suscipit diam eget mi cursus viverra.
Figure30.11.Pre-Roll Countdown
Inside a <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.
Figure30.12.University of Puget Sound Promotional Video
Vestibulum facilisis ligula lectus, ac tristique nisl aliquet non. Quisque ornare felis arcu. Vivamus suscipit diam eget mi cursus viverra.
Figure30.13.Pre-Roll Countdown
Inside figures inside a <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.
Figure30.14.Pre-Roll Countdown
Figure30.15.University of Puget Sound Promotional Video
Identical code to previous example, but now wrapped in an overall <figure>, which has its own caption and number, leaving the interior figures to be sub-numbered. Cross-references use the full number: Figure 30.16.(b).
(a)Pre-Roll Countdown
(b)University of Puget Sound Promotional Video
Figure30.16.Amalgamation of Videos
Subsection30.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 control
inside a <listing>, earning a number and caption, with layout control
inside a <sidebyside>, with size and layout configured
inside 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 numbers
inside 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),…).
Examples of each, and more.
Programs can be realized in many forms, and can come from a variety of sources. See Section 20 for tests of some of that variety. Here we are testing placement within surroundings and testing the schema for location. But we do have two videos in each test, one provided as a local file and one embedded from a service.
All by itsef, with no layout specified, so showing the default size and placement. Vivamus in congue massa. Morbi condimentum ac magna at accumsan. Vestibulum ac augue eu lorem semper gravida.
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
Now a program with shorter lines, with no layout control.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
And a <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 $
Now similar examples, but with layout control: margins and width.
A <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
A <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!");
}
A longer <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 $
Two <listing>, with <caption>, and no layout control.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
Listing30.17.Hello, World! in C
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 $
Listing30.18.A console session on a Raspberry Pi
Same two <listing>, but now with layout control on the <program> and <console>.
/* Hello World program */
#include<stdio.h>
main()
{
printf("Hello, World!");
}
Listing30.19.Hello, World! in C
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 $
Listing30.20.A console session on a Raspberry Pi
This <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
This is the same three-panel <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
Figure30.21.Some Code Samples
Finally, a smaller <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!");
}
Listing30.22.Hello!
$ gcc -Wall -o intAndFloat intAndFloat.c
$ ./intAndFloat
The integer is 19088743 and the float is 19088.742188
$
Listing30.23.Raspberry Pi
And again, the two-panel <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!");
}
(a)Hello!
$ gcc -Wall -o intAndFloat intAndFloat.c
$ ./intAndFloat
The integer is 19088743 and the float is 19088.742188
$
(b)Raspberry Pi
Figure30.24.Two Code Listings
Subsection30.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 centered
all 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, and
inside 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),…).
Examples of each, and more.
A <tabular> realized by LaTeX for PDF/print 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. This is the most rigid of the content types we call “planar.” So for PreTeXt output as LaTeX, when you explicitly constrain the width to be less than the “natural width” (including use as a panel of a <sidebyside>, or even setting margins) the table will be scaled down in width, which can result in an apparent font size very much smaller than that of the surrounding text. Note that we do not ever scale a tabular up to be wider with a larger font size. Note also that if there is no attempt to control the space for the table (no layout control, not in a <sidebyside>) then no scaling is attempted at all and the table may be wider than the text and protrude into the right margin. For more, see the three examples at: Table 30.29 , Table 30.30, Table 30.31. Generally, much of the commentary and testing here is about LaTeX/PDF/print. While for HTML output the cells will usually automatically word-wrap to fit in the available space, without adjusting the font size. Some might like this behavior and some might not.
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
The same effect can be had by specifying that the @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
Only from the West Coast.
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
Wow! That is as big as many countries.
163,696
1850
In amongst a run of paragraphs (or similar) a <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.
Naturally, a <tabular> can be placed inside a <table>, earning a number and a title.
Table30.25.Natural Width
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
A little narrower, but still centered by default.
Table30.26.Width of 60%, automatic centering
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
Very narrow, asymmetric margins.
Table30.27.Width of 30%, 30% left margin, 40% right margin
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
Wider than necessary, asymmetric margins.
Table30.28.Width of 90%, 8% left margin, 2% right margin
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
The next table is purposely much too wide. In Table 30.29 we make no attempt to control the width, and so it will extend into the margins. In Table 30.30 we have simple added the attribute width="auto". This attempt to use layout control will cause an automatic reduction in width and a smaller apparent font size. Adjusting margins providing an explicit percentage width, or placing the tabular as a panel of <sidebyside> will have the same effect. In Table 30.31 we have set the width explicity to 100% and so it should be identical to the automatic width case just prior.
Table30.29.Tabular too wide, no layout control
State
Population
Area (sq. mi.)
Statehood (Year)
Capitol City
Largest City
Washington
7,614,893
71,362
1889
Olympia
Seattle
Oregon
4,217,737
98,381
1859
Salem
Portland
California
39,512,223
163,696
1850
Sacremento
Los Angeles
Table30.30.Tabular too wide, scale to automatic width
State
Population
Area (sq. mi.)
Statehood (Year)
Capitol City
Largest City
Washington
7,614,893
71,362
1889
Olympia
Seattle
Oregon
4,217,737
98,381
1859
Salem
Portland
California
39,512,223
163,696
1850
Sacremento
Los Angeles
Table30.31.Tabular too wide, scale to 100% width
State
Population
Area (sq. mi.)
Statehood (Year)
Capitol City
Largest City
Washington
7,614,893
71,362
1889
Olympia
Seattle
Oregon
4,217,737
98,381
1859
Salem
Portland
California
39,512,223
163,696
1850
Sacremento
Los Angeles
Now into <sidebyside> in various ways and with various sizes. First, two <tabular> as panels with widths at 60% and 30%. Note that in LaTeX/PDF/print the tabular of functional values does not need the full 30% width, so it is at its natural size and centered within its panel.
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
\(x\)
\(f(x)\)
3
9.734
5
2.175
Let’s do that again, but with widths experimentally set to make font sizes match (approximately).
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
\(x\)
\(f(x)\)
3
9.734
5
2.175
Same tabular, which fills roughly 80% by itself, packed into a single <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
Natural widths, but now as a pair of tables.
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
Table30.32.West Coast
\(x\)
\(f(x)\)
3
9.734
5
2.175
Table30.33.Function Values
Finally, as two individual <table>, grouped and laid out via a <sidebyside>, and collected as a <figure>. Which causes sub-numbering of the two enclosed <table>.