Added chapter «An Introduction to LaTeX»

This commit is contained in:
Kenneth John Odle 2023-06-25 14:39:11 -04:00
parent e118528a3d
commit fc25b77fb4

View File

@ -51,10 +51,6 @@
% https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions % https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
\usepackage{wrapfig} \usepackage{wrapfig}
% Do we want to include URLs?
% Yes, but we also want to hide the big red box it puts around them in the pdf. Thanks /u/0b0101011001001011
\usepackage[hidelinks]{hyperref}
% Use tab stops when we need to (especially in footnotes) % Use tab stops when we need to (especially in footnotes)
\usepackage{tabto} \usepackage{tabto}
% Define 18 tab stops (at 1/4" intervals) % Define 18 tab stops (at 1/4" intervals)
@ -105,8 +101,11 @@
\usepackage[generate,ps2eps]{abc} \usepackage[generate,ps2eps]{abc}
\usepackage{mathptmx} %Necessary for abc package to work? \usepackage{mathptmx} %Necessary for abc package to work?
% Do we want to include URLs?
% Yes, but we also want to hide the big red box it puts around them in the pdf. Thanks /u/0b0101011001001011
\usepackage[hidelinks]{hyperref}
%%%% Document Information %%%%%
\author{Kenneth John Odle} \author{Kenneth John Odle}
\title{ \title{
{\Huge the codex} \\ {\Huge the codex} \\
@ -117,6 +116,9 @@
} }
\date{\begin{small}\today{}\end{small}} \date{\begin{small}\today{}\end{small}}
% Change the name of the TOC
\renewcommand*\contentsname{In This Issue…}
\begin{document} \begin{document}
\maketitle \maketitle
@ -139,7 +141,7 @@ You can just skip over all the diversions in here if you want. It's just how my
\noindent \textbf{Credit where credit is due:} A lot of people have come forth (mostly from Reddit) to help me out in various ways. See the preamble to this document in the source code to see them. One aspect of our society is that nobody \textit{has} to help you. It is wonderful when it happens, and I am grateful for their help. \noindent \textbf{Credit where credit is due:} A lot of people have come forth (mostly from Reddit) to help me out in various ways. See the preamble to this document in the source code to see them. One aspect of our society is that nobody \textit{has} to help you. It is wonderful when it happens, and I am grateful for their help.
The picture of a VT100 terminal is courtesy of Jason Scott. It was published at \href{https://en.wikipedia.org/wiki/VT100\#/media/File:DEC_VT100_terminal.jpg}{\texttt{https://en.wikipedia.org/wiki/VT100\#/media/File:DEC\_VT \\ 100\_terminal.jpg}} where you can also find the Creative Commons 2.0 license it was licensed under. (By Jason Scott - Flickr: IMG\_9976, CC BY 2.0, https://commons.wikimedia.org/w/index.php?curid=29457452) The picture of a VT100 terminal is courtesy of Jason Scott. It was published at \href{https://en.wikipedia.org/wiki/VT100\#/media/File:DEC_VT100_terminal.jpg}{\texttt{https://en.wikipedia.org/wiki/VT100\#/media/File:DEC\_VT100\_term \\ inal.jpg}} where you can also find the Creative Commons 2.0 license it was licensed under. (By Jason Scott - Flickr: IMG\_9976, CC BY 2.0, https://commons\\.wikimedia.org/w/index.php?curid=29457452)
\tableofcontents \tableofcontents
@ -343,6 +345,246 @@ Obviously, I have a lot more research to do.
Tablature is a way of indicating which strings to play on stringed instruments like guitars and basses. (There are arguments about whether it's worth using tabs, as they do leave out some information, but I won't get into that here. Suffice it to say that everything has its divisive issues. Personally, I find that if you already know the tune, tabs are generally enough.) Tablature is a way of indicating which strings to play on stringed instruments like guitars and basses. (There are arguments about whether it's worth using tabs, as they do leave out some information, but I won't get into that here. Suffice it to say that everything has its divisive issues. Personally, I find that if you already know the tune, tabs are generally enough.)
\chapter{An Introduction to \LaTeX{}}
I realized that even though I've mentioned that the reason I created this zine was to learn how to use LaTeX, and even though I've mentioned the things I've learned about LaTeX while writing it, I've never really provided a basic guide for others who might be interested in learning \LaTeX{}. So here goes…
\paragraph{A Caveat} First, I am far from an expert in these matters. What follows is pretty much a listing of what I've gleaned from hours spent searching the internet and trying things out myself. Second, some things will look differently and behave differently for you depending on variables such as the document class (see below) you are using and which other packages you have loaded. As I always say in such matters, \textit{your mileage may vary} \textit{practice doesn't make perfect, but it does make it less shitty}. A willingness to experiment is your best guide.
\section{Files}
\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{Paragraphs and White Space}
To start a new paragraph, simply skip a line. \LaTeX{} compresses white space, so if you are importing text from a text document, any lines that are adjacent to each other will be in the same paragraph. Additionally, multiple spaces will appear as a single space. For example, this code:
\begin{Verbatim}[frame=lines, numbers=left, label=White Space Example, breaklines=true, framesep=3mm]
This is the first paragraph.
This text, although it is on a separate line, is also part of the first paragraph.
We have skipped a line, so this starts a new paragraph.
This line is also in the second paragraph.
Readers will not see
all of these
spaces.
\end{Verbatim}
\noindent{} renders like this: \\
\hrule
\vspace{2mm}
This is the first paragraph.
This text, although it is on a separate line, is also part of the first paragraph.
We have skipped a line, so this starts a new paragraph.
This line is also in the second paragraph.
Readers will not see
all of these
spaces.
\vspace{2mm}
\hrule
\section{Document Structure}
Every \LaTeX{} document has two parts:
\begin{enumerate}
\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.
\item A \textbf{document} environment which contains the actual text of the document.
\end{enumerate}
(If you are familiar with \texttt{html}, these correspond roughly to the \texttt{<head>} and \texttt{body} elements.)
\subsection{The Preamble}
Within the preamble, you can declare the document's \textit{class}, which is a description of the type of document you are creating. The most common ones are \texttt{article}, \texttt{report}, \texttt{book}, \texttt{memoir}, and \texttt{beamer} (for presentations). A typical class declaration looks like:
\begin{Verbatim}
\documentclass[twoside]{report}
\end{Verbatim}
The class is described between curly brackets, but you can also include several \textit{options} in square brackets. The above document class is a two-sided report. ``Two-sided'' means that it may have different margins, headers, and footers on right and left handed pages. Other options, such as paper size and font size, are available.
\subsection{The \texttt{document} Environment}
Anything not in the preamble goes in the document environment, which looks like this:
\begin{Verbatim}[commandchars=\+\(\)]
\begin{document}
+textit(…your stuff…)
\end{document}
\end{Verbatim}
\subsection{Document Sections}
Each \LaTeX{} document can be divided into a hierarchical structure consisting of the following sections:
\begin{verbatim}
Part
Chapter
Section
Subsection
Subsubsection
Paragraph
Subparagraph
\end{verbatim}
\noindent{} To add one, use:
\begin{verbatim}
\chapter[Books]{Books I Have Read}
\end{verbatim}
Notice that we have the option \texttt{[Books]} which describes how this chapter will appear in the table of contents. To prevent a section from being numbered or appearing in the table of contents, replace this entire option with an asterisk:
\begin{verbatim}
\chapter*{Books I Have Read}
\end{verbatim}
For best results, stick to the hierarchical structure shown above, as this is also how each section will be numbered. See the table of contents of this zine.
\subsection{Environments}
\noindent{} This is where \LaTeX{} shows its power, as environments are used to to take care of typesetting tasks. Every environment begins with \verb+\begin{<environment>}+ and ends with \verb+\end{<environment>}+. In fact, we've already seen one environment: the \texttt{document} environment, which encompasses our entire document. Here are a few other useful ones:
\subsubsection{Enumerate}
\texttt{enumerate} is used to create numbered lists. They can be nested to create an outline. To prevent \LaTeX{} from adding a lot of space between the item numbers, pass the \texttt{[noitemsep]} to the environment.
For example, this code:
\begin{Verbatim}[frame=lines, numbers=left, label=Enumerate Example, framesep=3mm]
\paragraph{The First Punic War}
\begin{enumerate}[noitemsep]
\item Carthage and Rome
\begin{enumerate}
\item Beginning of Foreign Conquests
\item The Origin of Carthage
\item Government of Carthage
\end{enumerate}
\item Operations in the First Punic War
\begin{enumerate}
\item Outbreak of the War in Sicily
\item Capture of Messana and Agrigentum
\end{enumerate}
\item Events Following the War
\end{enumerate}
\end{Verbatim}
\noindent{} produces this output:
\vspace{2mm} \hrule \vspace{2mm}
\paragraph{The First Punic War}
\begin{enumerate}[noitemsep]
\item Carthage and Rome
\begin{enumerate}
\item Beginning of Foreign Conquests
\item The Origin of Carthage
\item Government of Carthage
\end{enumerate}
\item Operations in the First Punic War
\begin{enumerate}
\item Outbreak of the War in Sicily
\item Capture of Messana and Agrigentum
\end{enumerate}
\item Events Following the War
\end{enumerate}
\vspace{2mm} \hrule
\subsubsection{Itemize}
Similar to the \texttt{enumerate} environment, the \texttt{itemize} environment creates bulleted lists, which can also be indented.
As an example, we'll use the above example, but in a bulleted list:
\begin{Verbatim}[frame=lines, numbers=left, label=Itemize Example, framesep=3mm]
\paragraph{The First Punic War}
\begin{itemize}[noitemsep]
\item Carthage and Rome
\begin{enumerate}
\item Beginning of Foreign Conquests
\item The Origin of Carthage
\item Government of Carthage
\end{enumerate}
\item Operations in the First Punic War
\begin{enumerate}
\item Outbreak of the War in Sicily
\item Capture of Messana and Agrigentum
\end{enumerate}
\item Events Following the War
\end{itemize}
\end{Verbatim}
\noindent{} produces this output:
\vspace{2mm} \hrule \vspace{2mm}
\paragraph{The First Punic War}
\begin{itemize}[noitemsep]
\item Carthage and Rome
\begin{itemize}
\item Beginning of Foreign Conquests
\item The Origin of Carthage
\item Government of Carthage
\end{itemize}
\item Operations in the First Punic War
\begin{itemize}
\item Outbreak of the War in Sicily
\item Capture of Messana and Agrigentum
\end{itemize}
\item Events Following the War
\end{itemize}
\vspace{2mm} \hrule
\noindent{} You can also replace the bullets with any math symbol availabe in \LaTeX{} like this:
\begin{Verbatim}[frame=lines, numbers=left, label=Bullets Example, framesep=3mm]
\begin{itemize}[noitemsep]
\item[$\otimes$] First item
\item[$\oplus$] Second item
\item[$\triangle$] Third item
\end{itemize}
\end{Verbatim}
\noindent{} which produces this output:
\begin{itemize}[noitemsep]
\item[$\otimes$] First item
\item[$\oplus$] Second item
\item[$\triangle$] Third item
\end{itemize}
\subsection{Math in \LaTeX{}}
\LaTeX{} has a couple of different environments that are useful for typesetting math (\texttt{align} and \texttt{array}, but they get a little beyond what I want to cover here.\footnote{Maybe in a later issue? I can, if there is interest.}
There are two types of \textit{entry modes} for math in LaTeX. The first is in-line mode, which begins and ends with a dollar sign, and renders the math in the same line of text as the rest of the paragraph.
\begin{Verbatim}[frame=lines, label=In-Line Math Example, framesep=3mm]
The Pythagorean Theorem is $x^2 + y^2 = z^2$.
\end{Verbatim}
\noindent{} which renders as \\
\noindent{} The Pythagorean Theorem is $x^2 + y^2 = z^2$. \\
Math in \LaTeX{} can also be shown in display mode, which renders the mathematics on a separate line. The entry mode begins with \verb+\[+ and ends with \verb+\]+. If we change our example up above to this:
\begin{Verbatim}[frame=lines, label=Display Mode Math Example, framesep=3mm]
The Pythagorean Theorem is \[x^2 + y^2 = z^2\]
\end{Verbatim}
\noindent{} we get this: \\
The Pythagorean Theorem is \[x^2 + y^2 = z^2\]
\paragraph{Installing \LaTeX{}} I realize that I haven't talked about how to install LaTeX, but that really depends on what system you are running. Trying to include every possible operating system could easily turn this from a zine into a book. The best approach is to search for your operating system + ``install latex''.
\chapter{What's to Like About Linux} \chapter{What's to Like About Linux}
\section{Open Source} \section{Open Source}