Summary
This lesson closes the fifth unit of the course, devoted to tables and figures. It rebuilds the chain of principles and mechanisms that runs from the simplest table to a TikZ drawing placed in a figure, pointing out at each link which principle is used and in which lesson it is established; it places what has been achieved within the plan of the course and specifies which questions, merely anticipated, are left for the following units; it repeats in its exit assessment the skills of the entry assessment; and it ends with six challenges, harder than the problems of the lessons, which require combining several of them to typeset the table of a laboratory report according to the rules of a department, to diagnose a document that compiles without a warning and shows six defects, to compose a figure with a photograph and a drawn diagram, to generate a table from a data file, to rebuild a diagram that does not survive the move to two columns and to choose the environment of three different tables.
Learning objectives
- Rebuild the order of the mechanisms of the unit, identifying the principle on which each one rests.
- Explain why so many defects of tables, images and floats compile without a warning, and where to look for their trace in the output.
- Distinguish what the unit established from what it only anticipated and the following units will develop.
- Typeset tables and figures that combine aligned figures, captions, names, references, subfigures and drawings, and predict what a source that combines them produces.
- Choose, for each table, image or drawing, the environment, the measurement and the place that withstand the changes of the document.
What the unit achieved
The unit set out to have the data, images and drawings of a piece of work read with the same clarity as its text, numbered and referred to like its sections and equations, and finding their place on the page without the author fixing it by hand. The purpose has been fulfilled by relying on what the introduction declared known from the previous units: cross-references, which depend on what a label records; alignment, from the previous unit, in which each \\ opens a row and each & separates a cell; and the preamble with its commands of one’s own, where decisions are taken once. With that, the path travelled can be read as a single chain in five stretches.
Readable tables
The lesson on readable tables applied the principle of alignment to text: tabular builds one row for each \\ and one cell between each pair of &, with one column letter per cell, and the whole is a box that the engine places in one piece. From the counting rule it deduced its two kinds of errors: the noisy one, “Extra alignment tab”, which, when a \\ is missing, is reported on the following line, and the silent one, the row with fewer cells, which the engine accepts. It replaced the grid with the three rules of booktabs, with trimmed \cmidrule and \addlinespace; it aligned figures on the decimal marker with the S column of siunitx, whose table-format reserves a space that a wider number exceeds with no trace but an “Overfull \hbox” in the log, which does not name the cell, and whose output marker is the point of English unless \sisetup declares another, whatever babel says; it moved the units to the headings, in braces in the S columns; and it set ragged-right text with \raggedright\arraybackslash.
Complex and long tables
The lesson on complex and long tables extended the counting rule to \multicolumn, which takes the place of several cells, and showed that a forgotten initial & shifts a grouped heading without the engine noticing, because the partial rules depend only on their numbers. It gave tables the width of the line with tabularx or with tabular* and \extracolsep{\fill}, and discarded \resizebox, which changes the size of the type; it split long tables over several pages with longtable, which repeats its headings, numbers once if the continuation carries \caption[], needs another run to settle its widths and loses rows if enclosed in table; and it generated tables from a single source, the data file, with csvsimple and pgfplotstable, warning that filecontents* without overwrite does not rewrite the file.
Images in the document
The lesson on images in the document established that \includegraphics produces a box that the engine places on the line like a large letter, and from this it deduced the indentation that makes an image stick out of the width of the line, the way to center it and the way to set two side by side. It expressed sizes relative to \linewidth, which adjusts to the place; it showed that width and height without keepaspectratio distort without a warning and that the options are applied in the order written; it distinguished vector graphics, which are exported as PDF, from photographs, whose resolution the engine does not check; and it studied how files are found: without an extension, the PDF is preferred to the PNG without a warning, and \graphicspath requires double braces.
Figures and floating tables
The lesson on figures and floating tables deduced floating from the indivisible box: what does not split and does not fit is carried to where it fits, and that is why it is referred to by its number. It explained the specifiers as permitted places, the widening of [h] into [ht], the gaps left by [H] and the figure with no possible place that holds back all the others; it composed the caption, which numbers, makes an entry in the list and goes above tables, with the spacing of the caption package; it changed “Figure” into “Fig.” with \setlocalecaption, because babel undoes \renewcommand, and corrected cleveref with \crefname; it checked that caption gives away a label placed before the caption; and it composed subfigures, independent figures in a single figure and table notes with threeparttable, after showing that \footnote loses its text in a float.
Drawings with TikZ
The lesson on drawings with TikZ moved from the image that is inserted to the image that is written. It began with the preamble: babel modules such as the Spanish one make the sign > of arrows active, and without \usetikzlibrary{babel} the first arrow produces a cascade of errors. It went through Cartesian, polar and relative coordinates, with the difference between + and ++; paths, stroke options and the tips of arrows.meta; named nodes with anchors, placed relative to one another with positioning; the styles of \tikzset and the repetitions of \foreach; diagrams from several disciplines, the graph of a function, whose sine is measured in degrees without a warning, and pgfplots; and it ended by putting the drawing in a figure and comparing the three ways of scaling it down.
The following figure gathers the five stretches into a single chain. Each node of the column is a mechanism or a rule, numbered according to the order in which they rest on one another and joined by an arc to the earlier links it uses; around them float the supports, that is, the principles to which the chain turns again and again, each joined by a solid line to the links that rest on it and by a dotted one to the link where it is established, except those established in previous units, which are drawn as rings. Clicking a support highlights all the links that use it, and each link refers to the lesson in which it is studied.
Supports of the chain
- AWhat a label records. A label records the last number assigned before it, within its environment, without knowing what it is attached to. Established in the third unit. Admitted without proof in this unit.
- BAn alignment is a table. An alignment environment builds one row for each
\\and one cell for each stretch between two&, even if the row is left incomplete. Established in the previous unit. Admitted without proof in this unit. - CDeciding once. What is decided in a single place (a command or a format in the preamble, a style, a data file) changes throughout the document when it is changed there; what is copied by hand stops agreeing. Established in the previous units. Admitted without proof in this unit.
- DRuns. The engine writes in the auxiliary files what it computes in one run, and uses it in the next. Established in the first unit. Admitted without proof in this unit.
- EWhat babel does. babel sets the names of its language when the document begins; the English module leaves signs and the decimal point alone, but other modules make some signs active, such as
<and>in Spanish or"in German and Portuguese. Partly established in the previous unit. Admitted without proof in this unit. - FA box does not split. A table, an image or a drawing is a box that the engine places in one piece, like a large letter, and that is not cut between two pages. Established in: 1. Rows and cells.
- GWhat is valid gives no warning. The engine only warns of what it cannot typeset; a valid source that does not say what the author meant compiles without a warning, and the defect is only seen in the output. Established in: 1. Rows and cells.
- HFloating and referring. What does not split and does not fit where it was written is carried to where it fits; that is why a float is referred to by its number, and never by its place. Established in: 13. Why they float.
Segment 1 Readable tables
- Choose between table, list and figure according to the way the data will be consulted.
- Typeset a table with
tabularand the rules of booktabs, without a grid. - Align figures on the decimal marker with the
Scolumn. - Diagnose the errors of a table, including those that give no warning.
Rows and cells.
tabularbrings the rule of alignment to text: one letter per column,&between cells and\\at the end of the row; a row with more cells gives “Extra alignment tab”, on the following line if the\\is missing, one with fewer is valid, and the whole is a box that does not split.Rests on: B (An alignment is a table), F (A box does not split), G (What is valid gives no warning). Proved in: Readable tables.
Rules instead of a grid. No vertical or double lines:
\toprule,\midruleand\bottomrule,\cmidrulewith its trims and\addlinespace;\hlinemixed with them gives no warning and leaves two systems of lines.Uses: 1. Rows and cells. Rests on: G (What is valid gives no warning). Proved in: Readable tables.
Figures on the decimal marker. The
Scolumn aligns on the marker;table-formatreserves the space, and a wider number sticks out with no trace but an “Overfull\hbox” in the log, which does not name the cell; the output marker is the point whatever babel says, and\sisetupchanges it in one place; a thousands comma copied from a text is read as a decimal one.Uses: 1. Rows and cells. Rests on: E (What babel does), G (What is valid gives no warning), C (Deciding once). Proved in: Readable tables.
Headings and text. The unit goes once in the heading, which in an
Scolumn goes in braces;\makecellbreaks a long heading; the ragged-right paragraph column carries\raggedright\arraybackslash, and without\arraybackslash“Misplaced\noalign” appears.Uses: 3. Figures on the decimal marker, 2. Rules instead of a grid. Rests on: B (An alignment is a table). Proved in: Readable tables.
Segment 2 Complex and long tables
- Group columns and count the cells of each row.
- Give a table the width of the line without scaling it.
- Split a long table over several pages.
- Generate a table from its data file.
Cells that span columns.
\multicolumntakes the place of several cells, and the count of a row must not exceed the preamble; a forgotten initial&shifts the group without a warning, because\cmidruledepends only on its numbers; the surplus width goes to the last column of the group.Uses: 1. Rows and cells, 2. Rules instead of a grid. Rests on: B (An alignment is a table), G (What is valid gives no warning). Proved in: Complex and long tables.
The width of the line. tabularx widens its
Xcolumns, or anLdeclared with\newcolumntype;tabular*shares out the white space between columns with\extracolsep{\fill};\resizeboxis discarded, because it gives each table a different type size.Uses: 4. Headings and text. Rests on: F (A box does not split), C (Deciding once). Proved in: Complex and long tables.
Tables of several pages. longtable is cut and repeats its headings with
\endfirstheadand\endhead; it numbers with\captionand continues with\caption[]; it records its widths and asks for another run; insidetableit becomes a box again and loses rows.Uses: 5. Cells that span columns. Rests on: F (A box does not split), D (Runs). Proved in: Complex and long tables.
Tables from the data. Data have a single source, the file: csvsimple copies its text and pgfplotstable formats its numbers;
filecontents*withoutoverwritedoes not rewrite an existing file and only reports it.Uses: 3. Figures on the decimal marker, 7. Tables of several pages. Rests on: C (Deciding once), G (What is valid gives no warning). Proved in: Complex and long tables.
Segment 3 Images in the document
- Size an image relative to the line and predict its dimensions.
- Choose the format of each image and check its resolution.
- Name, place and find the image files.
- Place an image on the line like a character.
The image is a large letter.
\includegraphicsproduces a box resting on the baseline: after the indentation, an image ofwidth=\linewidthsticks out; to center it, the line is centered, and two images go side by side if they fit on it.Rests on: F (A box does not split). Proved in: Images in the document.
Size and order of the options. Measurements relative to
\linewidthadjust to the place; width and height withoutkeepaspectratiodistort without a warning; the options are applied in the order written;trimasks forclip, and a page that does not exist stops the compilation.Uses: 9. The image is a large letter. Rests on: G (What is valid gives no warning). Proved in: Images in the document.
Formats and resolution. Charts are vector graphics and are exported as PDF at the size of use; photographs are bitmaps and ask for some 300 pixels per inch, which the engine does not check; an SVG is converted beforehand, and an EPS is converted by graphicx.
Uses: 10. Size and order of the options. Rests on: G (What is valid gives no warning). Proved in: Images in the document.
Names and paths. Without an extension, the engine tries a fixed order and uses the PDF before the PNG, without a warning;
\graphicspathasks for double braces, and with single ones each letter is a folder; draft mode shows which file was used.Uses: 11. Formats and resolution. Rests on: G (What is valid gives no warning). Proved in: Images in the document.
Segment 4 Figures and floating tables
- Explain why a figure floats and refer to it by its number.
- Steer and contain the place of floats.
- Give each float its caption, its name and its label.
- Compose subfigures and notes inside a table.
Why they float.
figureandtablecarry the box to where it fits, and it is referred to by number; the letters are permitted places,[h]is only widened to[ht],[H]leaves gaps, and a figure with no possible place holds back those of its kind.Uses: 1. Rows and cells, 9. The image is a large letter. Rests on: F (A box does not split), H (Floating and referring). Proved in: Figures and floating tables.
The caption.
\captionnumbers, typesets and makes an entry in the list, which needs another run, and accepts a short title; it goes above tables and below figures, and the caption package fixes its spacing and its format for the whole document.Uses: 13. Why they float. Rests on: D (Runs), C (Deciding once). Proved in: Figures and floating tables.
Name and reference.
\setlocalecaption{english}{figure}{Fig.}gives “Fig.” to the caption, and babel undoes\renewcommand{\figurename}; cleveref asks for\crefname{figure}{Fig.}{Figs.}; the label goes after the caption, and with caption a misplaced one gives a warning and two question marks.Uses: 14. The caption. Rests on: A (What a label records), E (What babel does). Proved in: Figures and floating tables.
Subfigures and notes. subcaption gives letters to the parts of a figure, which cleveref calls “fig. 1b”; independent figures go in minipages inside a single
figure, never the other way round;\footnotein a float loses its text without a warning, and threeparttable binds the note to the table.Uses: 15. Name and reference, 9. The image is a large letter. Rests on: H (Floating and referring), G (What is valid gives no warning). Proved in: Figures and floating tables.
Segment 5 Drawings with TikZ
- Prepare the preamble of a document for drawing.
- Place points with absolute, polar and relative coordinates.
- Compose diagrams with named nodes and styles of one’s own.
- Put a drawing in a figure and scale it without losing the type of the text.
TikZ and babel’s shorthands. A module that makes the
>of arrows active, like the Spanish one, gives a cascade of errors at the first arrow, in any loading order;\usetikzlibrary{babel}corrects it; without arrows.meta or without positioning, the messages are “Unknown arrow tip kind” and “Unknown function of”.Rests on: E (What babel does). Proved in: Drawings with TikZ.
Coordinates and paths. Coordinates are Cartesian, polar or relative:
++moves the reference point and+does not; a forgotten semicolon is reported on the following line, andsin(\x)measures the angle in degrees without a warning.Uses: 17. TikZ and babel’s shorthands. Rests on: G (What is valid gives no warning). Proved in: Drawings with TikZ.
Nodes and styles. A node is a box with a name and anchors; positioning places it relative to another by the distance between borders, so that the diagram rearranges itself;
\tikzsetfixes the styles and\foreachrepeats.Uses: 18. Coordinates and paths. Rests on: F (A box does not split), C (Deciding once). Proved in: Drawings with TikZ.
The drawing in the figure. The drawing is a box and goes in
figurewith its caption and its label;scalekeeps the type,transform shapereduces it and\resizeboxreduces everything; pgfplots, withcompat, writes the decimal point of English, and a comma is asked for withuse comma, since babel does not give it.Uses: 19. Nodes and styles, 15. Name and reference, 6. The width of the line. Rests on: H (Floating and referring), E (What babel does). Proved in: Drawings with TikZ.
Towards the bibliography. The chain stops where tables, images and drawings are typeset, numbered and referred to: the provenance of data and of other people’s images, which here was stated by hand in a credit line, will be cited in the next unit from a bibliographic database, in the style of each discipline.
Loading the content…
Completed
Sign in to save your progress