Browse Source

Added information about dvipng; reordered first section a bit

main
Kenneth John Odle 1 week ago
parent
commit
75ab5b89be
  1. 38
      002/codex-002.tex

38
002/codex-002.tex

@ -329,7 +329,8 @@ As a big part of the reason I created this was to learn more about LaTeX, I'm ke
\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.
\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 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}
@ -374,7 +375,7 @@ 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.
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.
@ -408,9 +409,26 @@ That's it; that's the entire document. Let's take a closer look at what is happe
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 variables here, and there may be a way to automatically fit the page size to the content.
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:
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{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}
@ -435,7 +453,17 @@ You'll also notice that there is no border spacing around the second formula. Th
\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.
\medskip
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.

Loading…
Cancel
Save