Workshop Guide/Template
Author
John Biechele-Speziale
Last Updated
7 years ago
License
Creative Commons CC BY 4.0
Abstract
Interactive LaTeX Workshop Guide
\documentclass{article}
%This package will format the bibliography for us, and do many other things if we want it to.
\usepackage{achemso}
%The next package is used to define page margins, and the command for it is on line 4.
\usepackage{geometry}
\geometry{top=0.75in, bottom=0.75in, left=0.75in, right=0.75in}
%The next few lines make the page look nicer by adding a lined header with a page number at the top right. The \cfoot{} tells the compiler that the center foot of the page should be left blank, since the page number usually goes there.
\usepackage{fancyhdr}
\pagestyle{fancy}
\cfoot{}
\rhead{\thepage}
%This next line is to include pictures! (Pronounced graphics, but with an x since we're edgy
\usepackage{graphicx}
%The next line is not necessary but is good to have for any special characters that may arise.
\usepackage[utf8]{inputenc}
%FINALLY! We start the document. All this stuff above the \begin{document} statement is called the preabmle and is where most of the formatting for the document goes, which means changing stuff up here can seriously change how your document looks and feels!
\begin{document}
To begin our document, we will start out with a simple sentence, this sentence to be exact: recursive humor, I suppose if you re-read this sentence enough times you'll probably get it...Darn it, I did it again!
But on a serious note, this is where the body of our document begins. Let's say you want to start a new line, for that you should either press enter to make your document look like it's paragraphed, or you should type the following sequence $\backslash \backslash$, kind of like this. \\ Now you can see it in action! But I already know what you're thinking "JOHN, WHAT IF WE WANT A LINE BETWEEN OUR PARAGRAPHS?!?!?!?!?!" Well there are two ways to do that, our overenthusiastic questioner! One way is to define it in the preamble with the following command
%The "verbatim" environment is used to put anything inside as text, so it is not read by the compiler.
\begin{verbatim}
\setlength{\parskip}{0.5cm}
\end{verbatim}
And replace the "0.5cm" with any value you want! It's just that easy folks! This will then make any set of paragraphs separated by exactly 0.5cm without any guess work. This does so by redifining the command LaTeX uses to space paragraphs (parskip) by a certain amount, which makes this method incredibly consistent. A "set it and forget it" style.
45
Now, let's say you like to live by the edge of your seat, on the wild side! In that case, you can instead enter down a line like we did in the beginning, but before you do so, add the previously mentioned $\backslash \backslash$, and voilà! \\
Like so!
So, as much as I'm SURE you're all loving the lesson on how to format basic text, I think it's time we get into the more complicated stuff so I don't completely waste your time.
Some of the greatest advantages in LaTeX come from the following properties, especially for us scientists. \\
%using \begin{center} lets the table be in the middle of the document. The {c|c|c|c} tells us there are 4 columns separated by 3 bars. If you want to leave a bar out for style, you can. The \hline command makes a horizontal line to separate rows from each other. Finally, the & symbols between words represent divisions between the columns.
\begin{center}
\begin{tabular}{c|c|c|c}
\hline
&Microsoft Word & LaTeX & Other Guys\\
\hline \hline
Intuitive Equation Editor? & With Plugin & Built In & Depends on who you ask \\
\hline
Vector Graphics Handling? & Nope & Totally & Nada \\
\hline
Easy Citations? & With plugins & built in, and works with plugins & Varies \\
\hline
Cost? & DOLLA DOLLA BILLZ & Free like beer (and freedom) & Homework \\
\hline
Easy to troubleshoot? & Fairly & Depends on the issue & Same as 1\\
\hline
Easy to make changes? & Can be & Absolutely & Mostly\\
\hline \hline
\end{tabular}
\end{center}
%A single set of dollar signs lets you do math mode inside a paragraph, two sets together ($$text here$$) lets you do what the begin equation command does but without the numbering.
So, to start, let's focus on equations. We can make things from the simple $y=mx+b$ to the just as simple, but better looking $x=\frac{y-b}{m}$. That fancy in-line fractioning allows for easy unit display such as $\frac{mg}{mL}$ or $\frac{cm^3}{WKm^3}$. Additionally, we can set off our equations by centering them and giving them a number for reference later, just by using the following command.
\begin{equation}
\left((k+h)\partial_{z_i} + \sum_{j\neq i}\frac{\sum_{a,b} \eta_{ab}t^a_i \otimes t^b_j}{z_i-z_j}\right)\langle\Phi(v_N,z_N)...\Phi(v_1,z_1)\rangle=0
\end{equation}
The best part about editing this equation in LaTeX, is that the commands are quite easy to learn or find, there are no menus to sift through, and sub/super scripted parts of the equation are as easy to add as adding an underscore or a carat (and some braces if you need multiple characters).
Next thing!
Vector graphics!
Why are these important over your standard JPG, PNG, TIFF and Bitmap? Well first of all, these NEVER get pixelated if you blow them up really big, and will always have the same size regardless of what you scale them to. Whilst this has other applications (making presentation slides with perfect scaling so you don't have to test it on the screen you'll be using before the show if you don't have time), we are mostly concerned with theses and journal articles, which obviously need some very high quality figures. So, I've included a pdf document with the picture of a cat.
%the \includegraphics command is included in the graphicx package above, and can use many types of formats, pdfs being some of the ideal since they can scale up without being pixelated. These are called vector graphics, and using inkscape+gimp to draw and edit them for free is great.
\begin{center}
\includegraphics[width=0.5\textwidth]{cat.pdf}\\
\end{center}
Now, that cat wasn't the best example to use here, so how about an image I made for my bioinorganic OP? It may not look like much to start, but the beauty is apparent when you zoom in a LOT.
\begin{center}
\includegraphics[width=1.9\textwidth]{Figure2.pdf}
\end{center}
And while the viewer on Overleaf is not the greatest, when you download the pdf of your document and take a look, it will look as crisp and clean as a refreshing drink of mountain water from the middle of the Himalayas.
But some of you may be asking yourselves "What if we want a sideways image? Or one at some ridiculous angle for the sake of proving you can do it in LaTeX fairly simply to support your argument that it's good?" Well, take a look!
\newpage
\begin{center}
\includegraphics[width=1.3\textwidth, angle=270]{Figure2.pdf}
\end{center}
This kind of thing is great for theses and the like where you have large graphics.
Finally, I want to discuss one of the most important parts of this for people who need to manage large bibliographies. For this we need a separate file known as a .bib file, where we can put our citation information. I've assembled one for us here, which will give us a start.\cite{test}
As you have noticed, the first thing in the ref.bib file is the following
\begin{verbatim}
@Article{test,
Title = {Enhanced Gas Sensitivity and Sensing Mechanism of Network Structures Assembled from \alpha-Fe2O3 Nanosheets with Exposed {104} Facets},
Author = {Ma, Yong and Yang, Juan and Yuan, Yukun and Zhao, Hua and Shi, Qian and Zhang, Fangjuan and Pei, Cuijin and Liu, Bin and Yang, Heqing},
Journal = {Langmuir},
Year = {2017},
Note = {PMID: 28737405},
Doi = {10.1021/acs.langmuir.7b00455},
Eprint = { http://dx.doi.org/10.1021/acs.langmuir.7b00455},
Url = { http://dx.doi.org/10.1021/acs.langmuir.7b00455}
}
\end{verbatim}
The first thing you see on the first line after the \@ sign, is what kind of reference this is. Is it a book? An article? An electronic publication? These are all handled differently in most citation styles, and LaTeX can do that for you. Yet another convenient addition is that it interfaces incredibly well with multiple browser plugins and citation managers that let you control everything the way you want. If you use Zotero with the Better Bibtex plugin, it can auto-generate keys based on a formula you give it, so citing for you becomes much easier as long as, for example, you can remember the last name of the first author and the year the paper was published.
%The following command gives the LaTeX compiler the bibliography, and you use the \cite{} command with the key
\bibliography{ref.bib}
\end{document}