Added section on custom page sizes

This commit is contained in:
Kenneth John Odle 2021-11-20 18:06:26 -05:00
parent 72a38e574d
commit 011d544e67
3 changed files with 70 additions and 0 deletions

View File

@ -74,6 +74,9 @@
% Put a horizontal rule in an align environment % Put a horizontal rule in an align environment
\usepackage{booktabs} \usepackage{booktabs}
% Use line numbers with code samples
\usepackage{fancyvrb}
\author{Kenneth John Odle} \author{Kenneth John Odle}
\title{ \title{
{\Huge the codex} \\ {\Huge the codex} \\
@ -316,5 +319,72 @@ Because a thing seems difficult for you, do not think it impossible for anyone t
\end{flushright} \end{flushright}
\end{quote} \end{quote}
\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.)
\end{enumerate}
\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. I admit, I had to play around with the variable here, and there may be a way to automatically fit the page size to the content.
As it turns out, there is, and it's very simple: 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
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.
\end{document} \end{document}

Binary file not shown.

Binary file not shown.