A zine about Linux. That's all.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

548 lines
34 KiB

\documentclass[twoside]{report}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{makeidx}
%\makeindex
\usepackage{graphicx}
\usepackage{kpfonts}
\usepackage{float}
\raggedbottom
% Where are our images?
\graphicspath{{images/}}
% Let's set this as a half-letter sized sheet
% https://tex.stackexchange.com/questions/338789/how-to-set-paper-size-to-half-letter-5-5-x-8-5-in-in-amsbook
\usepackage{geometry}
\geometry{
paperheight=8.5in,
paperwidth=5.5in,
% heightrounded,
margin=0.5in
}
% Adjust the top and bottom margins
% http://kb.mit.edu/confluence/pages/viewpage.action?pageId=3907057
\addtolength{\topmargin}{0.4in}
\addtolength{\textheight}{-0.75in}
% Set the header style
% https://www.overleaf.com/learn/latex/Headers_and_footers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\textit{the codex} -- Advanced Reading Copy}
\fancyhead[RE,LO]{Issue \#002}
\cfoot{Page \thepage}
\renewcommand{\footrulewidth}{0.5pt}
% Include sections and subsections in the TOC
% https://latex-tutorial.com/tutorials/table-of-contents/
% \setcounter{tocdepth}{2}
% We will probably want some two- or three-column sections
\usepackage{multicol}
% Stop resetting the footnote count after each chapter
\counterwithout{footnote}{chapter}
% Let's wrap some images
\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)
\usepackage{tabto}
% Define 18 tab stops (at 1/4" intervals)
\NumTabs{18}
% Use strikethrough
\usepackage{ulem}
% Style a blockquote
% 2021.11.22 -- Not really sure I need this anymore.
% See https://tex.stackexchange.com/questions/325695/how-to-style-blockquote
% \usepackage{etoolbox}
% \usepackage{setspace} % for \onehalfspacing and \singlespacing macros
% See also https://www.overleaf.com/learn/latex/Typesetting_quotations
% Make things neater. Thanks /u/-LeopardShark-
\usepackage{microtype}
% Put a horizontal rule in an align environment
\usepackage{booktabs}
% Use line numbers with code samples
\usepackage{fancyvrb}
% Pictures!
\usepackage{tikz}
\author{Kenneth John Odle}
\title{
{\Huge the codex} \\
{\footnotesize Life with Linux — A Zine \\
\bigskip
Typeset in \LaTeX{} \\
Issue \#002}
}
\date{\begin{small}\today{}\end{small}}
\begin{document}
\maketitle
\section*{Impressum}
All contents \copyright2021 Kenneth John Odle
Although this is now in your hands, and it's also on the web, so if you really wanted to steal this, I've made it pretty darn easy. I can't imagine why anyone would want to, though. You don't need to, however, since this is licenced under a CC BY-NA-SA 4.0 Creative Commons license. More information is at \href{https://creativecommons.org/licenses/by-nc-sa/4.0/}{https://creativecommons.org/licenses/by-nc-sa/4.0/}. \includegraphics[scale=0.35]{ncsa4-0}
FYI, this is made in \LaTeX \,using the report document class. It then gets exported to a letterhalf (5.5 in x 8.5 in) pdf, which then gets made into a booklet using PDF Booklet (\href{https://pdfbooklet.sourceforge.io/wordpress/}{\texttt{https://pdfbooklet.sourceforge.io/wordp \\ ress/}}).
I'm pushing this to my own git server as I write this. You can find it \href{https://git.kjodle.net/kjodle/the-codex}{here}: \texttt{https://git.kjodle.net/kjodle/the-codex}. New issues will be pushed after they are complete.
You can just skip over all the diversions in here if you want. It's just how my mind works. (And yes, there will be politics in this. \textit{You have been warned.}) Also, I use a lot of em-dashes, parentheses, and footnotes because that is also how my mind works. It's just one big long stream of consciousness up in here most days.
The buttons are from the Button Optimizer website, which is here: \href{https://buttonoptimizer.com/}{\texttt{https://buttonoptimizer.com/}}. I'm not sure if I like this concept or not. We'll have to see.
\tableofcontents
\chapter{The Later Salad Days}
Boring, early life stuff when my world smelled like sweat and disinfectant and room temperature bologna. Feel free to skip this. I wish I could.
\section{The Joy of Commodore 64}
\section{High School Computer Class}
\chapter{A Scanner Clearly, or More Thoughts on Being an Archivist}
In the first issue of this zine, I wrote about a basic workflow for archiving books through scanning them into pdf files. While I covered about everything I wanted to cover on the computer end of things, I barely talked at all about the physical labor that goes into scanning a book. For those who are interested, here's what happens behind the scenes before you even get to the computer.
\section{The Non-Computer Stuff}
First, you have to cut the book apart, and then separate the pages from the bindings. Older books are generally signature bound, and so it's simply a matter of cutting the backing off the signatures, cutting any strings holding them together, and then separating the signatures. This sounds easy, but it's a lot of work. If the book is perfect bound (i.e., individual pages are glued together, rather than signatures), it's just a matter of separating the pages very carefully a few pages at a time.
Second, you then have to trim the bound edges, so that the pages are separate. Perfectly bound books tend to have glue creeping up between each page, whereas signature bound books tend to have glue only creeping up between the signatures. I have a paper trimmer that allows me to clamp the pages down so that they don't move as I cut them, and I highly recommend something similar. It also has a measured grid to the left, so that I can ensure I'm cutting all the pages to the same width. (\textbf{Protip:} Put a piece of painter's tape on the grid to make this even easier.)
\begin{center}
\includegraphics[scale=0.5]{paper_cutter}
\end{center}
After that, separate your pages into groups of equal numbers of pages that you will scan. This should be however many sheets your scanner can handle easily at one time, and will depend largely on the kind of paper the book was printed on. I generally find ten sheets (i.e., 20 pages) work well, and make it easier for me to count. Smaller groups means more work up front, but it also means that it is easier to fix things when (not \textit{if}) something goes wrong.
Number all of your groups with the filename they will eventually have. I use a pencil and mark this lightly (or not so lightly, depending on the day) in the lower right corner of the first page:
\begin{center}
\includegraphics[scale=0.5]{number_your_sections}
\end{center}
This is all about workflow for me. Since my scanner (a Brother MFC-J8050DW) scans whatever is facing \textit{down} in the document feeder, after I scan the first (i.e., odd-numbered) side, I should see odd numbers facing up in the ADF. I then know that I need to scan the side that is now facing down, which means that I don't turn them over, I just rotate them 180\textdegree{} in the \textit{xy}-plane.
Most books have unnumbered pages. This should go without saying, but it's one of those things that you don't think about until after it becomes an issue: \textit{number all the blank pages}. Again, I just use a pencil:
\begin{center}
\includegraphics[scale=0.5]{number_blank_pages}
\end{center}
Once you do all of this, you're ready to scan. You should have a pile of stuff that looks something like this:
\begin{center}
\includegraphics[scale=0.5]{ready_to_scan}
\end{center}
As it turns out, if you have a couple of pages that bleed to the middle\footnote{Generally because of a photograph or illustration that continues across both the left and right pages.}, you can pretend that they don't and simply trim those pages the same size as all your other pages. Or, if you want to preserve that bleed, you'll have to remove those sheets \textit{before} you trim the edges, and separate them very carefully down the middle. If you are lucky, they are in the middle of a signature, and you can separate them with a sharp knife. If you are not lucky, they will be somewhere else, and may have glue holding them together, meaning you have to very carefully prise them apart. No matter how carefully you do this, you will inevitably lose some data.
You will end up with two sheets (i.e., four pages) that are a different size, and which will need to be scanned separately. In which case, it's good to use a cheat sheet to keep track of which groups are which sizes and how many pages are contained in each. I like to just jot this down on an index card, but if the book you are scanning is complex, you'll need a bigger sheet of paper.
\begin{center}
\includegraphics[scale=0.5]{cheat_sheet}
\end{center}
You can do this math as a check on the final project.
\begin{align*}
001-015 &= 15 \times 20 & 300 \mbox{ pages} \\
016 &= 1 \times 4 & 4 \mbox{ pages} \\
016-024 &= 8 \times 20 & 160 \mbox{ pages} \\
025 &= 1 \times 12 & 12 \mbox{ pages} \\
\midrule
\mbox{Total} & & 476 \mbox{ pages}
\end{align*}
After you are done scanning and combining files, you can open that final \texttt{file.pdf} and you should be on page 1 of 476 pages.
Now we are \textit{finally} ready to start scanning.
\section{What Does This Have to do With Linux?}
You may be wondering why I am spending so much time talking about using scissors and pencils and rulers when this is a zine about Linux. Sure, this is what I need to do to get ready to scan and put all those scans together using the command line application \texttt{pdftk}, but what is the point here?
If you recall back in the first issue, I said that doing things on the command line makes you think about \textit{outcomes}. Thinking about outcomes doesn't matter just on the computer. Like I said earlier, there is no ``undo'' button in real life.\footnote{Although I sometimes think that lawyers are just rich people's undo buttons.} Once you've cut something apart, there's no putting it back together. You \textit{have} to think about what you want the next step of the process to be so that you don't do something in this step that makes the next step afterward difficult or even impossible. You have to think ahead about what you want to end up with. You have to know what you want.\footnote{And here I readily admit that you are probably going to do this a few times before you figure out a process for getting to that point. The workflow I laid out in section 2.1 took a few books to develop.}
I sometimes think that a GUI is like the menu at the McDonald's drive through.\footnote{It's no wonder that the menu in a GUI is called a \textit{menu}, when you think about it.} If you are lucky, you are behind the person that knows what they want. They planned ahead. They thought about the outcome they wanted (full stomach, happy taste buds) and chose something ahead of time that would get them to that outcome. But a lot of people (too many people, in my opinion\footnote{Just one of many reasons I don't eat fast food any more.} get up to that order screen and \textit{that's} when they decide to start thinking about outcomes. They are so used to seeing a menu in front of them that they can't even begin making a decision without seeing it.
And let's face it: the menu at McDonald's has not really changed in years. Yes, they have new things, but they also advertise the hell out of them when they do. How can you \textit{not} know about their new menu item if you watch more than 30 minutes of television a day? But again, a GUI does not encourage you to think. The command line does. And again: most people just don't like to think.\footnote{I admit, I like to think, but I don't like to think \textit{all the time}. Sometimes my brain needs a rest, so I make some popcorn and pull up something corny to watch on television for a while. But then my brain starts wandering, and I know it's time to get back to work.} They like the \textit{illusion} of choice, and that is what substitutes for thinking most of the time. ``What are you getting at McDonald's?'' is too often followed by ``I don't know; I'll think about it when we get there.''
Of course, if you are thinking about outcomes, chances are you don't eat fast food very often anyway, because the long term outcomes are obesity, heart disease, and hypertension. But damn, those fries are good!
\section{A GUI Solution}
For what it's worth, there is a GUI for \texttt{pdftk}. It's called PDF Chain and you can find it at \href{https://pdfchain.sourceforge.io/}{\texttt{https://pdfchain.sourceforge.io/}}.
Despite all my prattling on about the many advantages the command line has for your brain, I'm not opposed to using a GUI, actually. (I mean, I have Ubuntu installed on two machines and Kubuntu on a third---all GUIs that make Linux easier to use.) A GUI does make life easier in many ways, and what I like about one in a case like this is that if you're someone who has to manipulate pdf files rarely or only once, it's probably easier to just use a GUI than it is to learn the command line. Efficiency plays a role here, as well. If I'm going to use this all the time, it's definitely more efficient for me to learn the command line approach. But once or twice a year? Or only once ever? A GUI is much more efficient.
\textbf{tl;dr:} If you're only going to use a tool once, there's no issue with using the simplest tool required to get the job done. There's no point in being a command-line ascetic.
\begin{center}
\includegraphics[scale=0.47]{pdfchain_-_title}
\end{center}
\chapter{Make Life Easier with bash Aliases}
\includegraphics[scale=0.8]{intermediate}
\medskip
I'm not going to get into the difference between the command line, the terminal, and bash (the Bourne Again Shell, if you are interested\footnote{You may not be, but after all, you are reading \textit{this} so you very well may be. I'll talk about that in a future issue.}) For now, let's just assume that you know about \texttt{ctrl alt t} opening a terminal window to get you access to the command line.
If you are used to using the command line, chances are that you have a certain set of commands that you use a lot. For example, if you're pushing to your Github repos all the time, you probably are typing \texttt{git push origin main} quite often. You can create a bash alias that makes your life a lot easier.
Chances are, you will open the terminal in the root of your \texttt{Home} directory. You can tell by typing
\begin{verbatim}
$ pwd
\end{verbatim}
\texttt{pwd} stands for ``\texttt{print working directory}'' and shows you where you are. If you're in the home directory, you'll get something that looks like this:
\begin{verbatim}
/home/username
\end{verbatim}
\noindent{}where ``\texttt{username}'' is your login name. If you're \textit{not} in your home directory, you can get there with this command:
\bigskip
% We're doing it this way so we can get a better looking ~.
\noindent{}\verb=$ cd= $\sim$
\bigskip
\noindent{}The $\sim$~ is shorthand for your home directory. (If you are logged in to the terminal as your username, it takes to \texttt{/home/username}. If you are logged in to the terminal as \texttt{sudo}, it takes you to the \texttt{root} directory in the top level directory—where all those Linux directories are that we talked about in the last issue.)
We are looking for an invisible file, so execute this command:
\begin{verbatim}
$ ls -a
\end{verbatim}
\noindent{}The \texttt{ls} command will list visible files, the \texttt{-a} option shows all files, including the invisible ones.
We are looking for a file called \texttt{.bashrc}. If you have a lot of stuff installed, you may have to scroll around to find it. Once you find it, open it in a text editor. This is in your home directory, so you can use whatever text editor you want and no \texttt{sudo} privileges should be required.
If you want, scroll through it. There is some interesting stuff there. But we want to create aliases, so go to the end, and type
\begin{verbatim}
# my aliases
\end{verbatim}
\noindent{}The \verb=#= means that this line is a comment. We'll add our aliases beneath this line.\footnote{Let's stop and reflect for a moment on how important it is to add comments to whatever we work on. When you come back to this file in six months or two years and ask yourself ``Why is this here? Who wrote this?'' your comment will tell you. I often find it handy to include the date as well, and any url where I found something useful. Check the source code of the preamble to this document for examples.}
Let's use our Github example. Add the following line:
\begin{verbatim}
alias gpush="git push origin main"
\end{verbatim}
\noindent{}Save the file, and then go to one of your git repos, make some changes, and commit them. Then, when you want to push the changes to the remote repository, instead of typing \texttt{git push origin main} just type \texttt{gpush}. Your terminal will do the rest for you.
You can also execute bash scripts as well. In addition to a local backup on an external drive, I also backup the directories in my home drive to a remote storage location. To make life easy, I created a script (called, naturally, \texttt{backup.sh}) in each of those directories to back them up. To execute those backup scripts, I just need to go to that directory, open the directory in a terminal and type \texttt{./backup.sh}.
The problem here is that a lot of times, I'm not even in those directories when I'm saving files to them. I'm somewhere else. And to open the directory in my GUI and then open it in a terminal, or to open a terminal and then navigate to that directory, is a little \textit{too} much when I want to run that backup script. Remember, you want to back up soon, and you want to back up often. Backing up on that basis is a good habit to have. So let's remove as many obstacles to that habit as possible.\footnote{I am often amazed by how often people (myself included) want to form a new good habit (eating more fruit, getting more exercise, etc.) and then put as many things as possible in the way of that habit. Again, it's because we're so used to the old, bad habit that we don't think. Sometimes, we just need to get out of our own way.} In this case, we'll add an alias to run those backup scripts.
This is what I have in my \texttt{.bashrc} aliases:
\begin{verbatim}
alias kdoc="bash $HOME/Documents/backup.sh"
alias kdow="bash $HOME/Downloads/backup.sh"
alias kpic="bash $HOME/Pictures/backup.sh"
alias krec="bash $HOME/Recordings/backup.sh"
alias ktem="bash $HOME/Templates/backup.sh"
alias kvid="bash $HOME/Videos/backup.sh"
\end{verbatim}
Let's look at the first one. \texttt{kdoc} is the name of the alias. Since my first name is Ken, I prefix these with the letter \texttt{k} so I don't get them mixed up with something else. \texttt{bash} means to run this as a bash script. \texttt{\$HOME/Documents/backup.sh} means ``go to the \texttt{home} directory, then go to the \texttt{Documents} directory, and run this script called \texttt{backup.sh}''.
We can do other things as well. Log into your webhost via ssh a lot? Try this one:
\begin{verbatim}
alias kssh="ssh username@webhost.com"
\end{verbatim}
\noindent{}Replace ``\texttt{username}'' with your actual username and ``\texttt{webhost.com}'' with the actual host that you log into.
The next time you want to log into your host, just type \texttt{kssh} (or whatever you choose to call your command; the choice is yours as long as it doesn't conflict with a built-in bash command), and it will automatically ask for your password, as it has already sent your username to your host. You've now typed four characters instead of 24. Nifty, huh?
\newpage
\noindent{}This is probably my favorite, though:
\begin{verbatim}
alias kls="ls -Ahl"
\end{verbatim}
\noindent{}This gives us a directory listing, but with these options:
\begin{itemize}
\itemsep-0.4em
\item \texttt{A} lists all files and directories, including invisible ones (but excluding the . and .. directories\footnotemark).
\item \texttt{h} gives us file sizes in human readable sizes, i.e., ``4.0K'' instead of ``4096 bytes''.
\item \texttt{l} gives us the listing as a list, because I find that to be more readable, especially with a directory that contains a lot of stuff. I'd rather just scroll up and down than up and down \textit{and} right and left.
\end{itemize}
Again, I'm typing three keystrokes instead of seven. When you spend eight or more hours a day on the computer, whatever keystrokes you can save really start to add up.
\footnotetext{If you've ever wondered about what these are, here's a simple explanation. The . (dot) represents the current working directory, i.e., the one that you are in. The .. (dot dot) represents the parent directory, i.e., the directory that contains the directory you are currently in. Whenever you create a directory in a Unix-based system, it is added as a new entry to its parent directory, and these two entries (hard links) are created in the new directory. \\ \tabto{1.9em}\texttt{ls} and \texttt{ls .} are the same command: they give you the contents of the directory you are in. \texttt{ls ..} gives you the contents of the parent directory to the one you are in. It's the same as going up into your parent directory, getting a content listing, and then moving back into the child directory you were just in. And for what it's worth, you can do \texttt{ls ../..} to get the content listing of the grandparent directory. Nifty? Depends on how lost you are. \\ \tabto{1.9em}\texttt{cd ..} will move you up into your parent directory, whereas \texttt{cd .} moves you nowhere, because you are literally telling the terminal to change the directory to the current directory. It's a bit like changing into the underpants you are currently wearing. \\ \tabto{1.9em}Anyway, enough of the stupid pet tricks.}
And that's it. Just about anything you type often on the command line can be turned into a bash alias to save you time. Go for it. It's a great way to manage your mischief.
\chapter{What Have I Installed?}
\chapter{What's to Like About Linux?}
I have an app on my phone called ``The Stoic'' that shows quotations from various Stoic philosophers. As I was working on this issue, this popped up:
\begin{small}
\begin{quote}
Because a thing seems difficult for you, do not think it impossible for anyone to accomplish.
\begin{flushright}
---\textbf{Marcus Aurelius}
\end{flushright}
\end{quote}
\end{small}
\chapter{Coda}
\section{What I Learned About \LaTeX{} While Creating This Issue}
As a big part of the reason I created this was to learn more about LaTeX, I'm keeping up with this running list.
\begin{enumerate}
\item Need a little horizontal space? Use \verb|\hphantom{<stuff>}| where \texttt{<stuff>} is any standard unit. (I use this down below to separate the two images with borders when they are on the same line.)
\item Need a box around an \verb|\includegraphics[scale=]{}| item? Just wrap it in \verb|\frame{}|. (Ditto.)
\item Want a blockquote? Use the \texttt{quote} environment. (I wrapped mine in a \texttt{small} environment to help set it off, as most blockquotes or indented quotations use a slightly smaller font.\footnote{Yes, it bugs me when people use the word \textit{quote} as a noun, but the usage is here to stay, so I shall learn to live (somewhat begrudgingly) with it.})
\item You can draw with the \texttt{tikz} package. You can also draw chemical structures with the \texttt{chemdraw} package. I have no idea how to write about those things on paper in an interesting way, so it may be some time (or never---never is always an option) before I get around to that. But there's an example at the end.
\item As with most things that *nix-based, there is usually more than one way to get to where you are going. Often, there are many ways, and they lead you down paths you hadn't even imagined. A little research goes a long way. (See the next two sections as examples of this. I had not even thought about this before I sat down to write this.)
\end{enumerate}
\subsection{\LaTeX{} Without a GUI}
Despite my blathering on about the benefits of the command line, I'm actually using a GUI editor called Texmaker (which you can find at \href{https://www.xm1math.net/texmaker/}{\texttt{https://www \\ .xm1math.net/texmaker/}}). This seemed the easiest way to learn LaTeX at the time, because all you have to do to get a readable pdf is to press \texttt{F1}.
But you don't need to go that route. You can do this entirely from the command line. Simply create a LaTeX document in any text editor, and save it with a \texttt{.tex} extension. From that point, simply run the following command in a terminal:
\begin{verbatim}
$ latex file.tex
\end{verbatim}
This command should generate the following files:
\begin{verbatim}
file.dvi
file.aux
file.log
\end{verbatim}
\texttt{file.aux} contains information your document needs to manage any cross-references in your document. \texttt{file.log} contains information about how your file was processed; if you run into errors, this is a good place to find a solution, or at least to find what to search the internet for. But it's the \texttt{file.dvi} file that we're interested in.
\texttt{.dvi} files are device independent files. They're a lot like PostScript or PDF, but without font embedding. To convert this to a pdf file, run the following command:
\begin{verbatim}
$ dvipdf file.dvi
\end{verbatim}
This should generate \texttt{file.pdf} which you can read in any document viewer. You may need to install \texttt{dvipdf}---on my system (Ubuntu 20.04) it was not installed.
You can also just run \texttt{pdflatex} (which again, you may have to install), which skips over making a \texttt{.dvi} file:
\begin{verbatim}
$ pdflatex file.tex
\end{verbatim}
This should generate the following files:
\begin{verbatim}
file.aux
file.log
file.pdf
\end{verbatim}
I have noticed that when I generate the pdf file using the former method, I get a much smaller file than I do the second time. As an experiment, I ran the \texttt{integral.tex} file I created earlier through both of these methods. Running the file through \texttt{latex} and then through \texttt{dvipdf} resulted in a pdf file that was only 7.0 kb in size. But when I ran it solely through \texttt{pdflatex}, I ended up with a pdf file that was 30.5 kb big. This is most likely due to a difference in compression methods\footnote{See this for more information: \href{https://tex.stackexchange.com/questions/38145/why-does-pdflatex-produce-bigger-output-files-than-latexdvipdfm}{\texttt{https://tex.stackexchange.com/questions/38145/why-does-pdflatex-produce-bigger-output-files-than-latexdvipdfm}}} so this could make a difference for you if you are working with large documents.
Go forth and manage your mischief.
\subsection{Custom Page Sizes}
Okay, this is important enough that it deserves its own section.
Part of what makes \LaTeX{} great is that it's really good at typesetting mathematical formulas, such as
\includegraphics[scale=1]{pythagorean_theorem}
Here's the thing, though: I didn't create that formula in this document. It's just an image. I created it in a separate LaTeX document, using a custom page size. This can be handy if you want to use it in something that doesn't typeset math formulas, such as a presentation.\footnote{PowerPoint much? As much as I try to avoid PP, it seems to have gained something akin to Favored Nation Status in the business world. Such is life, alas.}
The source code looks like this:
\begin{Verbatim}[numbers=left,numbersep=-2pt]
\documentclass{article}
\usepackage[
left=0.1cm,
right=0.1cm,
top=0.1cm,
bottom=0.1cm]
{geometry}
\begin{document}
\pdfpagewidth=2.3cm \pdfpageheight=0.7cm
\noindent $ x^n + y^n = z^n $
\end{document}
\end{Verbatim}
That's it; that's the entire document. Let's take a closer look at what is happening here.
Lines 3-6 use the \texttt{geometry} package to give us some pretty tight margins. This is a good thing, as this is going to be clip art. We could set them to zero if we needed to (and which might not be a bad idea, actually).
Line 9 is where the magic happens. It allows us to set the actual page size of this example.And yes, I could have just used the \texttt{geometry} package to declare the page size in the preamble. It's what I do with this document. But doing that affects \textit{all} the pages in our document. This lets us handle page size on a page-by-page basis, as we shall see. All we need to do is add a new page and resize everything again. Take a look at this:
\begin{Verbatim}[numbers=left,numbersep=-2pt]
\documentclass{article}
\usepackage[
left=0.1cm,
right=0.1cm,
top=0.1cm,
bottom=0.1cm]
{geometry}
\begin{document}
\pdfpagewidth=2.3cm \pdfpageheight=0.7cm
\noindent $ x^n + y^n = z^n $
\newpage
\pdfpagewidth=4.6cm \pdfpageheight=1.4cm
\noindent $ x^n + y^n = z^n $
\end{document}
\end{Verbatim}
I admit, I had to play around with the variables here, and there may be a way to automatically fit the page size to the content, provided I only want to create a single page: use the \texttt{standalone} document class. This source code:
\begin{Verbatim}[numbers=left,numbersep=-2pt]
\documentclass{standalone}
\begin{document}
\noindent $ x^n + y^n = z^n $
\end{document}
\end{Verbatim}
\noindent gives us this output
\includegraphics[scale=1]{pythagorean_theorem2}
We've now managed to do with one line of code what previously took us 8 lines of code. I would call that efficient.
You'll also notice that there is no border spacing around the second formula. This is handy in the event that I want to drop this into a word processing document. I'll add a box around these images so you can see the actual size:
\medskip
\frame{\includegraphics[scale=1]{pythagorean_theorem}} \hphantom{1cm} \frame{\includegraphics[scale=1]{pythagorean_theorem2}}
\medskip
\noindent Also, for reasons I don't know yet, the typical way of starting and ending a math environment in LaTeX (i.e., \verb|\[...\]| doesn't work in the \texttt{standalone} document class.. Only \verb|$...$| and \verb|\begin{math}| \verb|...\end{math}| do.
The \texttt{standalone} class is definitely pretty handy. Now, let's combine this idea with converting \texttt{.tex} documents directly into pdf files without using a GUI. There is a program called \texttt{dvipng} which you should be able to install from the command line, which will convert these \texttt{.dvi} files to \texttt{.png} files just by running:
\begin{verbatim}
$ dvipng file.dvi
\end{verbatim}
If you need a \texttt{.gif} file instead,\footnote{dude, wtf?} just add the \texttt{--gif} flag:
\begin{verbatim}
$ dvipng file.dvi --gif
\end{verbatim}
I'm not going to forget about the first method, though. This could be handy if I wanted to create something (such as a business card) that is a standard size that I want to repeat, or if I want to print on a smaller, non-typical format that LaTeX doesn't have a built-in page size for. I have a few ideas where I might use this; I'll try them out and report back in a later issue.
The obvious advantage here is that it's possible to create a document where every page has a different size. You can use the \verb|\parbox{}| environment to more precisely control where text and images are placed on the page.
Is this useful? As stated, that's a loaded question, because it's missing two parameters: \textit{to whom} and \textit{in which context}. This isn't useful to me at all right now, but I can imagine in the future somebody might find a way to make an interesting zine in this way and I like that idea, because that's where technology (i.e., LaTeX) and art (zines) intersect, and this is the most comfortable part of that particular Venn diagram for me.
For what it's worth, I've added a repo of these experimental files to my gitea instance. You can find it at \href{https://git.kjodle.net/kjodle/codex-latex-experiments}{\texttt{https://git.kjodle.net/kjodle/codex-latex-experiments}}.
\subsection{Why I Love \LaTeX{}}
I didn't draw this. It's an example I got from \href{https://texample.net//tikz/}{\texttt{https://texample.net//tik \\ z/}}. I sometimes find it easier to learn a thing by finding examples and playing around with the parameters to see what they do. \footnote{If you are interested in drawing in LaTeX, be sure to check out \href{https://texample.net/tikz/resources/}{\texttt{https://texample.net/tikz/resources/}}}
\bigskip
\begin{center}
\begin{tikzpicture}
\begin{scope}[blend group = soft light]
\fill[red!30!white] ( 90:1) circle (1.8);
\fill[green!30!white] (210:1) circle (1.8);
\fill[blue!30!white] (330:1) circle (1.8);
\end{scope}
\node at ( 90:1.8) {Typography};
\node at ( 210:1.9) {Design};
\node at ( 330:1.9) {Coding};
\node [font=\Large] {\LaTeX};
\end{tikzpicture}
I am very comfortable living in the center of that Venn diagram.
\end{center}
\bigskip
\begin{wrapfigure}[8]{r}{0.2\textwidth}
\begin{tikzpicture}
\draw (0,0) rectangle (1.8cm, 1.8cm);
\draw (1.6,0) rectangle (1.1cm, 1.3cm);
\draw (0.8,1) rectangle (0.3cm, 0.6cm);
\draw (2,2) node{} -- (1,2.5) node{} -- (0,2);
\end{tikzpicture}
\end{wrapfigure}
\noindent Anyway, off to right is the kind of thing I've figured out how to draw using \texttt{tikz}.
Yeah, I've got a ways to go. (If you couldn't tell, it's a house with a floating roof. If you're wondering why the roof is floating, I am too. Let's just assume it's some modern Swedish design.\footnote{I'm good with this. Let's not make it weird.}) I literally have a dozen browser tabs open just to draw that little Swedish house, and yes, that is how I tend to learn the best: here's the basic idea, here are a bunch of examples (some of which seem to contradict one another), and here's my sandbox where I play around with it until I get it just the way I like it.
Now that I look at my code, I realize why my roof is floating. Here's my original code:
\begin{Verbatim}[numbers=left,numbersep=-2pt]
\begin{tikzpicture}
\draw (0,0) rectangle (1.8cm, 1.8cm);
\draw (1.6,0) rectangle (1.1cm, 1.3cm);
\draw (0.8,1) rectangle (0.3cm, 0.6cm);
\draw (2,2) node{} -- (1,2.5) node{} -- (0,2);
\end{tikzpicture}
\end{Verbatim}
Lines 2-3 draw the rectangle, and line 4 draws the triangle. Apparently, I resized the house and forgot to resize the roof. If I change line four to this:
\begin{verbatim}
\draw (1.8,1.8) node{} -- (0.9,2.5) node{} -- (0,1.8);
\end{verbatim}
\noindent We now have a house with a proper (i.e., non-Swedish modern) roof:
\begin{center}
\begin{tikzpicture}
\draw (0,0) rectangle (1.8cm, 1.8cm);
\draw (1.6,0) rectangle (1.1cm, 1.3cm);
\draw (0.8,1) rectangle (0.3cm, 0.6cm);
\draw (1.8,1.8) node{} -- (0.9,2.5) node{} -- (0,1.8);
\end{tikzpicture}
\end{center}
\noindent Well, time to stop playing and get back to work.
\end{document}