Typofixes in chapter 5 (tables)

This commit is contained in:
Kenneth John Odle 2023-10-30 14:11:02 -04:00
parent 7b744342d2
commit 65e519bb12

View File

@ -555,7 +555,7 @@ Tables in \LaTeX{} are often confusing to beginners, because there are two envir
\section{Built-in Table Environments}
For example, the following code will produce the table seen in \ref{tb:sampletable}:
For example, the following code will produce the result see in table \ref{tb:sampletable}:
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{Sample of a Basic Table}]
\begin{table}
@ -587,7 +587,7 @@ For example, the following code will produce the table seen in \ref{tb:sampletab
\end{tabular}
\end{table}
Note that I did not say ``in the table below'' because the \texttt{table} container is a float. That is, it allows \LaTeX{} to find the best location for the table in your document. This is often a point of confusion for beginners, because they assume that the table will appear where in their document where it appears in their file.
Note that I did not say ``in the table below'' because the \texttt{table} container is a float. That is, it allows \LaTeX{} to find what it thinks is the best location for the table in your document. This is often a point of confusion for beginners, because they assume that the table will appear where in their document where it appears in their file.
The code is fairly straightforward:
@ -599,7 +599,7 @@ The code is fairly straightforward:
\item \verb+\\+ ends a row.
\end{itemize}
Typesetting tables in \LaTeX{} is straightforward, but it is not without its issues. In particular, tables that float can cause a lot of issues for users, and controlling the width of both the table and individual columns can be a challenge. However, if you do not wrap your table in a \texttt{table}, you cannot add a caption, as \LaTeX{} will give a ``caption outside float'' error. As you can see in our sample table, \LaTeX{} has automatically sized the columns and table to fit our content, but that does not always make for an aesthetically pleasing table. It can also be difficult to easily break lines in a table cell, for which you would need to use \verb+\newline+ or add the \texttt{makecell} package.
Typesetting tables in \LaTeX{} is straightforward, but it is not without its issues. In particular, tables that float can cause a lot of issues for users, and controlling the width of both the table and individual columns can be a challenge. However, if you do not wrap your table in a \texttt{table}, you cannot add a caption, as \LaTeX{} will give you a ``caption outside float'' error. As you can see in our sample table, \LaTeX{} has automatically sized the columns and table to fit our content, but that does not always make for an aesthetically pleasing table. It can also be difficult to easily break lines in a table cell, for which you would need to use \verb+\newline+ or add the \texttt{makecell} package.
There are solutions to this, and Klaus Höppner pointed out many of them in his ``Typesetting tables with \LaTeX{}'' article, which I recommend reading. (You can find it at \kref{https://tug.org/TUGboat/tb28-3/tb90hoeppner.pdf}{https://tug.org/TUGboat/tb28-3/tb90hoeppner.pdf}.)
@ -655,7 +655,7 @@ To specify horizontal lines between each row, I only need to add \verb+hlines =
To specify vertical lines, I added \verb+vline{1,3} = {0.75pt,solid}+. Note that this is singular (\texttt{vline}) rather than plural (\texttt{hlines}). That's because I only want the first and third vertical lines to appear in my table. (The \texttt{booktabs} package recommends against using vertical lines inside your table, and I tend to agree in most cases. This document certainly contains some exceptions.) If I had five columns, and only wanted to have vertical lines on the outside of the table, I would specify \verb+vline{1,6}+.
You can also specify line colors by using the color codes specified in the \texttt{ninecolors} package. To specify blue horizontal lines, you would use something like \verb+hlines = {0.75pg,solid,blue7}+.
You can also specify line colors by using the color codes listed in the \texttt{ninecolors} package documentation. To specify blue horizontal lines, you would use something like \verb+hlines = {0.75pg,solid,blue7}+.
The rows are specified with \verb+rows = {5mm, m, rowsep=1.5pt}+. \texttt{5mm} specifies a minimum height of 5 millimeters for each row. \texttt{m} specifies that the content should be centered vertically in each row. (Other options are \texttt{t} to put everything at the top and \texttt{b} to put everything at the bottom.) \texttt{rowsep} specifies vertical padding for each row. (Columns have a similar feature called, naturally enough, \texttt{colspec}.)
@ -709,7 +709,7 @@ The disadvantage of using \texttt{rowspec} is that we must include every row in
If you want to break text in a cell, you can surround the cell contents with curly braces and use \Verb+\\+ where you want the break.
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=tabularray Example with multiline cells]
\begin{Verbatim}[frame=lines, numbers=left, xleftmargin=5mm, framesep=3mm, breaklines=true, label=\fbox{tabularray Example with multiline cells}]
\begin{longtblr}
[
caption = {\texttt{tabularray} Table with Multiline Cells},
@ -772,7 +772,7 @@ Fish & Chips & Mushy Peas \\
Fish & Chips & Mushy Peas \\
\end{longtblr}
The typical way of doing this requires use of the \Verb+\multicolmn+ command (which requires you to load the \texttt{multirow} package), and it requires that omitted cells must be empty. This is not the case with \texttt{tabularray}, however. As you can see from the source code, the words ``Meatballs'' and ``Fish'' have simply been omitted from the resulting table. We were also able to change the horizontal alignment by specifying it after we specify how many rows or columns to span.
The typical way of doing this requires use of the \Verb+\multicolmn+ command (which requires you to load the \texttt{multirow} package), and it requires that omitted cells must be empty. This is not the case with \texttt{tabularray}, however. As you can see from the source code, the words ``Meatballs'' and ``Fish'' have simply been omitted from the resulting table. We are also able to change the horizontal alignment by specifying it after we specify how many rows or columns to span.
\chapter{Formatting Pages}