Browse Source

Added section on custom page sizes

Kenneth John Odle 2 weeks ago
  1. 70
  2. BIN
  3. BIN


@ -74,6 +74,9 @@
% Put a horizontal rule in an align environment
% Use line numbers with code samples
\author{Kenneth John Odle}
{\Huge the codex} \\
@ -316,5 +319,72 @@ Because a thing seems difficult for you, do not think it impossible for anyone t
\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.
\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.)
\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
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:
\pdfpagewidth=2.3cm \pdfpageheight=0.7cm
\noindent $ x^n + y^n = z^n $
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:
\noindent $ x^n + y^n = z^n $
\noindent gives us this output
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:
\frame{\includegraphics[scale=1]{pythagorean_theorem}} \hphantom{1cm} \frame{\includegraphics[scale=1]{pythagorean_theorem2}}
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.