Added section on line spacing to paragraphs chapter

This commit is contained in:
Kenneth John Odle 2023-07-10 09:29:12 -04:00
parent 8029d134eb
commit 52c9d78357

127
lbol.tex
View File

@ -164,9 +164,9 @@ In this book, I use the word \textit{file} to refer to the \texttt{.tex} file yo
\LaTeX{} uses plain files with a file extension of \texttt{.tex}. That's it! They contain plain text only and no binary codes or hidden formatting extensions. (Try opening any word processing document in a text editor and see what I mean here.) You can use any text editor, although a GUI is available for most operating systems.
\section{Document Structure}
\section{File Structure}
Every \LaTeX{} document has two parts:
Every \LaTeX{} file has two parts:
\begin{enumerate}[noitemsep]
\item A \textbf{preamble} in which you declare the class and add any packages you may need, as well as set other variables such as the title and author.
@ -340,10 +340,51 @@ Sometimes you need to insert a blank space that is the width of a particular cha
\textit{height} is the length above the baseline and \textit{depth} is the length below the baseline. A character such as ``w'' will have a height but zero depth, and ``y'' has height as well as depth.
\section{Line Spacing}
\LaTeX{} was designed to write documents; as such, its ability to fine-tune certain document parameters, such as line-spacing, is fairly limited out of the box. You can fine-tune this with the \texttt{setspace} package. Add that to your preamble, and you can adjust the line spacing of your document by adding either \texttt{singlespacing}, \texttt{onehalfspacing}, or the \texttt{doublespacing} command to your preamble.
That gives you the versatility that you had with a typewriter. To set more precise line spacing, you can use the \texttt{setstretch} command in your preamble:
\begin{verbatim}
\setstretch{1.1}
\end{verbatim}
\noindent which sets a line spacing equivalent to 1.1 lines. If you want to change the line spacing for just a portion of your document, use the \texttt{spacing} environment:
\begin{verbatim}
\begin{spacing}{2.5}
Your widely spaced text goes here.
\end{spacing}
\end{verbatim}
\chapter{Formatting Pages}
\section{Customizing Pages}
\subsection{Removing Page Numbers from ``Part'' Pages}
Chapters that are grouped into parts will have a ``Part'' page at the front of them. Surprisingly, these pages still have page numbers. You can remove them by adding the \texttt{nonumonpart} package.
\subsection{Adding Additional Text to ``Part'' Pages}
In actual books, a ``part'' pages often contain some sort of epigraph. You can make the text an optional argument to the \verb|\part| command by adding this to the preamble:\footnote{As described by \href{https://tex.stackexchange.com/users/1090/david-carlisle}{David Carlisle} at \kref{https://tex.stackexchange.com/questions/336361/how-to-write-text-after-part}{https://tex.stackexchange.com/questions/336361/\\how-to-write-text-after-part}.}
\begin{verbatim}
\makeatletter
\let\old@endpart\@endpart
\renewcommand\@endpart[1][]{%
\begin{quote}#1\end{quote}%
\old@endpart}
\makeatother
\end{verbatim}
\texttt{makeatletter} changes the \texttt{@} to the ``letter'' category code so that the current document has access to package internal macros. \texttt{makeatother} changes it back to a letter so you can use it in your document.\footnote{This gets into the internal workings of LaTeX and so is far beyond the scope of this zine. However, there is some good information at \href{https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do}{\texttt{https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do}} and at \href{https://www.tug.org/pipermail/tugindia/2002-January/000178.html}{\texttt{https://www.tug.org/pipermail/tugindi \\ a/2002-January/000178.html}} if you are interested. A complete list of category codes can be found at \href{https://en.wikibooks.org/wiki/TeX/catcode}{\texttt{https://en.wikibooks.org/wiki/TeX/catcode}}}
\verb|\let\old@endpart\@endpart| says ``take the old value for \texttt{endpart} (which is part of the \texttt{part} function) and give it this new value that I'm about to describe''.
The rest of it (that is, the \texttt{renewcommand} part) redefines the \texttt{endpart} to now include a \verb|\quote| environment, which is quite appropriate for an epigraph.
\chapter{List Environments}
\section{Enumerate}
@ -505,6 +546,38 @@ The Pythagorean Theorem is \[x^2 + y^2 = z^2\]
\chapter{Referencing}
\chapter{Macros}
\section{New Commands}
If there is a group of commands that you often use together, you can group them into a single command by using the \verb+\newcommand[]{}+ command in the preamble.
The square brackets contains a number that indicates the number of variables you are going to pass to the new command. The curved brackets contain the new command. For example, this code in the preamble:
\begin{verbatim}
\newcommand\krule[2]{\vspace{#1}\hrule\vspace{#2}}
\end{verbatim}
\noindent{}defines a new rule ``krule'' that places a horizontal line (\verb+\hrule+) with a vertical space (\verb+\vspace+) above and below it. It contains two variables, one for the height of the first vertical space and one for the height of the second vertical space. In practice, this rule would be used like this:
\begin{verbatim}
\krule{12pt}{6pt}
\end{verbatim}
\paragraph{Note:} In this format, you must always pass the units to the new command when you execute it. You can also define this rule to have the units built into the new command like this:
\begin{verbatim}
\newcommand\krule[2]{\vspace{#1pt}\hrule\vspace{#2pt}}
\end{verbatim}
and to use it, you would enter
\begin{verbatim}
\krule{12}{6}
\end{verbatim}
This means less typing, but you are always restricted to using the same units.
\chapter{Miscellaneous}
\section{What I Learned About \LaTeX{} While Creating This Issue}
@ -621,57 +694,7 @@ For reasons I don't understand I went down an internet rabbit hole reading about
So I downloaded it, and decided to play around with it to see how much I could make it look like an actual book. My original purpose for starting this zine was to learn how to typeset things in \LaTeX{}, but it can be limiting since I've already figured out the format. Since I learn best from projects, another project was in order. This one fell into my lap at the perfect time.
\subsection{Removing Page Numbers from ``Part'' Pages}
In the \texttt{report} document class, chapters can be grouped into ``parts'' using
\begin{verbatim}
part[]{}
\end{verbatim}
\noindent wherever you want a new part. The argument between the square brackets is optional and determines what goes in the table of contents. The argument in the curly brackets is required and is what is sent to the page. (If the first argument is omitted, this is also what goes in the table of contents.) Surprisingly, these pages still have page numbers, which I just find odd. You can remove them by adding the \texttt{nonumonpart} package.
\subsection{Adding Additional Text to ``Part'' Pages}
It's fairly easy to \textit{remove} page numbers from the ``Part'' pages, but it not nearly as easy as it is to \textit{add} text to them. And it should be! In actual books, these pages often contain some sort of epigraph.
As it turns out, you can make the text an optional argument to the \verb|\part| command by adding this to the preamble:\footnote{As described by \href{https://tex.stackexchange.com/users/1090/david-carlisle}{David Carlisle} at \href{https://tex.stackexchange.com/questions/336361/how-to-write-text-after-part}{\texttt{https://tex.stackexchange.com/questions/336361/how-to-write-text-after-part}}.}
\begin{verbatim}
\makeatletter
\let\old@endpart\@endpart
\renewcommand\@endpart[1][]{%
\begin{quote}#1\end{quote}%
\old@endpart}
\makeatother
\end{verbatim}
\texttt{makeatletter} changes the \texttt{@} to the ``letter'' category code so that the current document has access to package internal macros. \texttt{makeatother} changes it back to a letter so you can use it in your document.\footnote{This gets into the internal workings of LaTeX and so is far beyond the scope of this zine. However, there is some good information at \href{https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do}{\texttt{https://tex.stackexchange.com/questions/8351/what-do-makeatletter-and-makeatother-do}} and at \href{https://www.tug.org/pipermail/tugindia/2002-January/000178.html}{\texttt{https://www.tug.org/pipermail/tugindi \\ a/2002-January/000178.html}} if you are interested. A complete list of category codes can be found at \href{https://en.wikibooks.org/wiki/TeX/catcode}{\texttt{https://en.wikibooks.org/wiki/TeX/catcode}}}
\verb|\let\old@endpart\@endpart| says ``take the old value for \texttt{endpart} (which is part of the \texttt{part} function) and give it this new value that I'm about to describe''.
The rest of it (that is, the \texttt{renewcommand} part) redefines the \texttt{endpart} to now include a \verb|\quote| environment, which is quite appropriate for an epigraph.
\subsection{Adjusting the Line Spacing}
\LaTeX{} was designed to write documents; as such, its ability to fine-tune certain document parameters, such as line-spacing, is fairly limited out of the box.\footnote{As it should be! Remember, the Unix Principle is to do one thing and do it well, not to be a Swiss army knife.} But if you need something, chances are that someone else has needed it before you and created a package that will do just that. In this case, the package you need is the \texttt{setspace} package.
Add that to your preamble, and you can adjust the line spacing of your document by adding either \texttt{singlespacing}, \texttt{onehalfspacing}, or the \texttt{doublespacing} command to your preamble.
That gives you the versatility that you had with a typewriter. To set more precise line spacing, you can use the \texttt{setstretch} command in your preamble:
\begin{verbatim}
\setstretch{1.1}
\end{verbatim}
\noindent which sets a line spacing equivalent to 1.1 lines. If you want to change the line spacing for just a portion of your document, use the \texttt{spacing} environment:
\begin{verbatim}
\begin{spacing}{2.5}
Your widely spaced text goes here.
\end{spacing}
\end{verbatim}
This is a small, simple package, but one that I am sure I'll have a lot of use for down the road.
\subsection{Include Page Numbers on ``Chapter'' Pages}