Summary
This lesson opens the fifth unit of the course, devoted to tables and figures. It explains what the unit is for: to set the data, images and drawings of an academic work so that they read as clearly as its text, are numbered and referred to like its sections and equations, and find their place on the page without the author fixing it by hand; it presents its five lessons and the thread that joins them, from the simplest table to the first drawing with TikZ; it states what is taken for granted from the previous units; it recalls where scientific tables and charts come from and the rule of economy that governs them; it formulates the problem the unit solves, namely that a table or a figure made according to the habits of the word processor compiles without complaint and reads badly; and it shows that the same tools serve the laboratory, the statistical study, the historical archive and the commentary on texts.
Learning objectives
- Describe the sequence of contents of the unit and explain what each lesson contributes to the next.
- Recognise what the unit takes for granted from the previous ones and review it if necessary.
- Explain, with an example, why a table with a full grid reads worse than one set with a few horizontal rules.
- Recognise in one's own discipline the tables, images and drawings that the unit teaches how to set.
Entry assessment
Before working through the unit, it is worth measuring the starting point. This assessment is a self-assessment: it is not graded, and its only purpose is to guide your study. Its first two questions review what the unit takes for granted from the previous ones; the next ten cover, two by two and in order, the five lessons of the unit. Anyone who has never set a table or inserted an image in LaTeX should not expect to get them right: every answer, right or wrong, explains the point and names the lesson that deals with it. The same skills are measured again at the end, in the synthesis lesson.
Before starting the unit, measure your starting point. It is a short self-assessment: it is not graded and its result is stored only in your browser.
Question 1From earlier unitsAn author adds a figure with a caption to a document that has
\listoffigures, compiles only once, and the figure does not appear in the list, although it does in the text. What is happening?\listoffiguresbelongs to the LaTeX kernel.It is precisely the caption that writes the entry in the list.Deleting it achieves nothing: the next run writes it again.Like the table of contents, the lists of figures and tables are written in one run and read in the next, with no warning when they are out of date.Question 2From earlier unitsThe text of a report says “according to Smith & Jones”, and compilation stops with “
Misplaced alignment tab character &”. Why?The sign can be printed; what fails is that it was written without a backslash.The sign is reserved in the kernel, with or without amsmath.The error is in the sign, not in the citation.An alignment is a table:&separates cells and\\ends rows. The same rule governs the tables of this unit.Review: Multi-line equations
Question 3A table with
\begin{tabular}{lr}gives “Extra alignment tab has been changed to\cr” on a line that has exactly one&. Where is the error most likely to be?The line reported has the cells it should; widening the specification hides the slip and leaves a mixed row.A single&is what two columns need; the message refers to the row, not to the line of the source.The error comes from the engine and appears the same without booktabs.Without an end of row, the previous row carries on into the one reported, which adds a second&to a two-column row.Review: Readable tables
Question 4A column declared
S[table-format=2.2]receives the cells 3.5, 12.25 and 140.8. What happens?That error is produced by characters that are not numbers, such as a heading without braces.siunitx neither rounds by default nor cuts off digits.The format fixes the space; what does not fit is shifted.siunitx does not warn when a number exceeds the reserved space: it sets it outside that space, and the engine only records a box that is too wide.Review: Readable tables
Question 5In a
{lrrrr}table, the first row is\multicolumn{2}{c}{Control} & \multicolumn{2}{c}{Treatment} \\and below it come\cmidrule(lr){2-3} \cmidrule(lr){4-5}. It compiles without errors or warnings. What is seen?That error is produced by a row with more cells than columns; here there are four out of five.LaTeX does not know that the first column belongs to no group; each\multicolumnstarts where the previous cell ends.\cmidruledraws a rule; it does not move text.The initial&is missing. A row with fewer cells than columns is valid, so the engine does not warn; the rules depend only on the numbers written.Review: Complex and long tables
Question 6A ninety-row table is written with
longtableinside atableenvironment, to centre it. What happens?Inside a float it cannot be broken.The installed version gives no error; that is precisely the danger.Nothing scales it; it runs off the bottom of the page.A float is a box that is not broken, and longtable does not flag this as an error. Thetableis removed: longtable already centres itself and has its own\caption.Review: Complex and long tables
Question 7One writes
\includegraphics[angle=90,width=4cm]{sample}for a photograph with a 4:3 aspect ratio, wider than it is tall. With what dimensions does it appear?That would be the result of[width=4cm,angle=90]: fixing the width before rotating.It forgets that the image was rotated: the width is fixed after the rotation.It is only distorted if width and height are fixed together withoutkeepaspectratio.graphicx applies the options in the order written: first it rotates, and the image becomes 3:4, and then it fixes the width of the image already rotated.Review: Images in the document
Question 8The
figuresfolder containschart.pdf, old, andchart.png, updated, and the source says\includegraphics{figures/chart}. What happens?The engine does not look at dates, but at a fixed order of extensions.There is no such error: the ambiguity is resolved silently.That error appears with extensions the engine cannot embed, such as.svg.Without an extension, the engine tries.pdfbefore.pngand uses the first one it finds.Review: Images in the document
Question 9A report says “as can be seen in the figure below” next to a
\begin{figure}[htbp]. What is wrong with it?The letters are permitted places, not an order; if it does not fit here, it will go elsewhere.[H]would fix it at the cost of leaving gaps on the pages; the solution is to refer to it by number.It precisely can: that is what floating is.A figure cannot be split across pages, and the engine places it where it fits; the number is the only thing that does not change meaning when it moves.Review: Figures and floating tables
Question 10With
\usepackage[english]{babel},\setlocalecaption{english}{figure}{Fig.}and cleveref loaded, the caption says “Fig. 1”. What does\cref{fig:spectrum}write?That would be expected, but it does not happen: cleveref has its own vocabulary in English.That is what\Crefwrites, at the start of a sentence;\crefabbreviates.That would only happen if the label recorded a section number.What is told to babel changes the caption and leaves the title of the list as it was, but it does not reach cleveref.Review: Figures and floating tables
Question 11A document in Spanish, with
\usepackage[spanish]{babel}and\usepackage{tikz}, fails on its first drawing line,\draw[->] (0,0) -- (1,0);, with “Argument of \language@active@arg> has an extra }”. What is missing?The error is the same in either order: the shorthand is still active inside the drawing.->is a basic tip; without arrows.meta the message would be “Unknown arrow tip kind”.The line has one; the message speaks of an active argument of the language, not of an unfinished path.TikZ's babel library gives the signs back their normal value inside drawings; the order of the packages does not fix it.Review: Drawings with TikZ
Question 12What does
\draw (0,0) -- ++(2,0) -- +(0,1) -- +(-1,0);draw?That would happen with++in every step.Nothing closes the path; for that one writes-- cycle.They mix without trouble; they differ in whether they update the reference point.+is measured from the last point fixed with++, here (2,0), and does not change it.Review: Drawings with TikZ
Loading the content…
Completed
Sign in to save your progress