Skip to content

Instantly share code, notes, and snippets.

@pop
Last active May 3, 2017 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pop/b1cf66e0dce101d9377c246b575dfb7d to your computer and use it in GitHub Desktop.
Save pop/b1cf66e0dce101d9377c246b575dfb7d to your computer and use it in GitHub Desktop.
A whirlwind introduction to LaTeX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Introduction to LaTeX, in LaTeX!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Welcome to this introduction to LaTeX. It's pretty self explanatory.
% If you have any questions contact ElijahCaine on GitHub.
% You should also check out the following resources:
% - https://en.wikibooks.org/wiki/LaTeX
% - https://en.wikibooks.org/wiki/LaTeX/Document_Structure
% - https://tex.stackexchange.com
% - https://www.sharelatex.com/learn
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
% \documentclass[arguments]{class}
%%%
% This defines the type of document you are writing.
% Some common ones include:
% - article: Pretty common default. Batteries included.
% - minimal: Bare bones. Just enough to get a PDf.
% - report: For multi-chapter/section documents.
% - letter: For writing letters.
% - beamer: LaTeX Slides!
%%%
% More info:
% - https://tex.stackexchange.com/questions/782/what-are-the-available-documentclass-types-and-their-uses
%%%
\documentclass{article}
%%%
% Preamble
%%%
% This isn't a specific command or section, but it is common to define your custom commands, variables, and imported packages at the top of the file.
%%%
%%%
% \usepackage[options]{packagename}
%%%
% Includes a LateX library.
% Just like with code, you *can* write it yourself, but you probably shouldn't.
%%%
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{titling}
\usepackage{hyperref}
\usepackage[backend=bibtex]{biblatex}
\usepackage{setspace}
\addbibresource{references.bib}
\graphicspath{ {./} }
%%%
% \newcommand{command}[#args]{command}
%%%
% Defines custom commands to be used in your document
%%%
\newcommand{\urgent}[1]{\textit{\textbf{\underline{#1}}}}
%%%
% \begin{document}
% [...]
% \end{document}
%%%
% This defines the contents of your document.
% Everything that gets rendered into a PDF is contained between these.
%%%
\begin{document}
%%%
% \maketitle
%%%
% Takes the document's metadata (author, title, etc) and creates a title.
%%%
\author{Elijah C. Voigt}
\title{Intro to LaTeX}
% \date{May 2, 2017}
\maketitle
\section{Hello \LaTeX}
\begin{doublespace}
Welcome to the \LaTeX introduction!
This document shows the output of the README.tex file which includes comments and source code for this file which is very useful for learning \LaTeX.
\LaTeX is a programming language for typesetting documents.
Just like HTML, Markdown, or a letter-press are used to format words on a page, \LaTeX is used to format books, academic papers, assignments, and even presentations!
The most common output of a \LaTeX document is a PDF, but this is customizable just like most things that have survived since 1978!
Using \LaTeX you can write paragraphs, lists, math formulas, import images, draw UML diagrams, and pretty much anything you can think of.
You can also extend the language by writing functions, included in packages, which can be used to automate common or complex tasks.
The advantage of using \LaTeX over, say Microsoft Word, are as follows:
\begin{itemize}
\item Your document is just code! Just like all code it can be shared, edited, and stored under version control.
This means you can share a [small] text file with a friend, they can compile your document, and see the output, all without sharing big PDF files or Word documents that might render weird on their installation of LibreOffice.
\item It looks good! \LaTeX was designed from the outset to render papers and reports written by scientists and engineers into clean, clear, printable documents.
You still need to be a good writer, but you don't need to be a good designer too!
\end{itemize}
\section{Output references}
\subsection{Custom command}
Using our custom command we can make something \urgent{sound really really urgent}.
\subsection{Lists}
There are two types of lists. Itemized lists:
\begin{itemize}
\item Itemized lists are un-ordered.
\item Some people call them 'bulleted lists'
\end{itemize}
And enumerated lists:
\begin{enumerate}
\item Enumerated lists are ordered.
\item They can have different formatting based on the arguments you pass.
\end{enumerate}
\subsection{Math}
Inline math looks like: $x^10$ and $\sum_{n=1}^{100} 2^{n-1} + C$
Block math looks like:
\[ % This is an alias for \begin{equation}
\int_{a}^{b} x^2 dx % Putting a and b in {} is not necessary if the statement is only one character.
\]
\input{extra-stuff}
and this
\begin{equation}
\begin{split}
N & = pq \\ % The \\ is used to say "newline"
phi & = (p-1)(q-1) % No newline needed on the last line
\end{split}
\end{equation}
\subsection{Citations}
We can cite things, like the Stack Overflow post I used to learn about citations! \cite{stack-overlow} \cite{sharelatex}
\subsection{Packages}
Packages can be downloaded indivudally from CTAN (\url{https://www.ctan.org/?lang=en}).
In all honesty though, you should probably just install \textit{texlive-latex-extra} through your package manager, or use a WYSIWYG editor.
That's what the pros do.
\end{doublespace}
\includegraphics[width=\textwidth]{foo}
\printbibliography
\end{document}
#!/bin/bash
for f in `ls *.tex`; do
# Run pdflatex,
# The run biber for citations
# Then run pdflatex again
pdflatex $f;
biber `basename $f .tex`;
pdflatex $f;
# I know. Kinda stupid.
done
#!/bin/bash
rm *{log,aux,pdf,xml,out,-blx.bib,blg}
FROM debian:latest
RUN apt update -y
RUN apt install -y texlive-latex-recommended
RUN apt install -y biber
RUN apt install -y texlive-latex-extra
WORKDIR /opt
CMD ["/opt/build.sh"]
\subsection*{extra stuff}
This is some extra stuff.
Yeah you heard me, extra stuf.
################################################################################
# Simple Debian LaTeX file
################################################################################
Vagrant.configure("2") do |config|
# debian ftw
config.vm.box = "debian/jessie64"
# install latex
config.vm.provision "shell",
inline: "apt update -y && apt install -y texlive-latex-recommended"
# Sync the current folder
config.vm.synced_folder ".", "/vagrant"
end
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment