Added section on tikz package

This commit is contained in:
Kenneth John Odle 2021-11-26 09:33:05 -05:00
parent 9924f00a1b
commit 6f579d148c

View File

@ -78,6 +78,9 @@
% Use line numbers with code samples % Use line numbers with code samples
\usepackage{fancyvrb} \usepackage{fancyvrb}
% Pictures!
\usepackage{tikz}
\author{Kenneth John Odle} \author{Kenneth John Odle}
\title{ \title{
{\Huge the codex} \\ {\Huge the codex} \\
@ -330,6 +333,7 @@ As a big part of the reason I created this was to learn more about LaTeX, I'm ke
\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 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 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 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.) \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} \end{enumerate}
@ -473,4 +477,72 @@ Is this useful? As stated, that's a loaded question, because it's missing two pa
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}}. 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} \end{document}