This is for my own reminder, and if you like them, take and modify them as you wish.
Preamble
Preamble is where you put all your defining and including stuff there. It’s a bit like
#include#define BLAH blahblah
in C.
In , we need to start with a
\documentclass[letterpaper]{article}
to start an article. Usually when I write an assignment or Lab report, I use article rather than report.
Packages
Then it’s the packages. is so versatile because so many clever people put their effort in improving it. The usual ones that I use are:
\usepackage[margin=1cm]{geometry} % For paper margin \usepackage{amsmath, amssymb, color, colortbl, graphicx, tikz, setspace, multirow} \usepackage[pdfstartview=FitH]{hyperref} \usepackage[utf8]{inputenc} % amsmath is used for generating math expressions; % amssymb is used for getting prettier math symbols; % color is color :) and colortbl can be used to highlight cells in tabular (table); % graphicx is used for importing graphics to the document; % tikz is a strong and powerful graphics drawer, very versatile and difficult to learn them all. % setspace is used for setting space size between lines. % multirow is an extra tool used for mainly creating tables. % hyperref is used to changing default zoom options. % inputenc set the default encoding to utf8 or else.
The percentage sign % is comment sign! When you need the percentage sign, you need to type \% like in regex.
When it comes to you that you’ll use some of the packages, then include the necessary ones into your \usepackage.
Resources
amssymb list: http://www.math.niu.edu/help/tex/amssymbols.pdf
tikz examples: http://www.texample.net/tikz/
tikz docu: http://www.texample.net/media/pgf/builds/pgfmanualCVS2012-11-04.pdf
Importing graphics: http://en.wikibooks.org/wiki/LaTeX/Importing_Graphics
setspace: http://mirror.its.dal.ca/ctan/macros/latex/contrib/setspace/setspace.sty
multirow: http://en.wikibooks.org/wiki/LaTeX/Tables#Columns_spanning_multiple_rows
hyperref:http://mirror.switch.ch/ftp/mirror/tex/macros/latex/contrib/hyperref/doc/manual.html
Always, Google is our best friend.
End of Preamble
For more detailed Document Structure, please visit WikiBooks
Document
After finishing the preamble content, let’s start to write our content!
Usually we need to add title, author and date on our first page for lab report or assignments.
\begin{document} \title{Some Lab Report \\ % \\ is nextline Circuit Lab \\ Section 1 \\ Composed by: } \author{ Luxing Huang \and Some Guy \and Another Guy } \date{\today} \maketitle
You can extend your spacing between lines using \vspace{2cm} inside your title or author section.
I think the indentation is messed up by default, so I always add
\setlength{\parindent}{0cm}
under \maketitle.
Then time for your \section{name}’s. And \subsections.
Math
The math module is very fun. You need to write your math expressions inside two dollar signs “$”.
$\sum m{(0, 1, 3, 6)}$
looks like: , fraction function is
\frac{numeritor}{denominator}
Some Math resources: http://en.wikibooks.org/wiki/LaTeX/Mathematics http://en.wikibooks.org/wiki/LaTeX/Advanced_Mathematics
Table
Table is even more fun. Here is a snippet of my for the lab work:
\begin{center} \begin{tabular}{l l l l l l} A & B & C & D & f & Simu \\ \hline 0 & 0 & 0 & 0 & 1 & 1 \\ \hline 0 & 0 & 0 & 1 & 1 & 1 \\ \hline 0 & 0 & 1 & 0 & 1 & 1 \\ \hline 0 & 0 & 1 & 1 & 0 & 0 \\ \hline 0 & 1 & 0 & 0 & 1 & 1 \\ \hline 0 & 1 & 0 & 1 & 0 & 0 \\ \hline 0 & 1 & 1 & 0 & 0 & 0 \\ \hline 0 & 1 & 1 & 1 & 1 & 1 \\ \hline 1 & 0 & 0 & 0 & 0 & 0 \\ \hline 1 & 0 & 0 & 1 & 0 & 0 \\ \hline 1 & 0 & 1 & 0 & 1 & 1 \\ \hline 1 & 0 & 1 & 1 & 1 & 1 \\ \hline 1 & 1 & 0 & 0 & 0 & 0 \\ \hline 1 & 1 & 0 & 1 & 1 & 1 \\ \hline 1 & 1 & 1 & 0 & 0 & 0 \\ \hline 1 & 1 & 1 & 1 & 0 & 0 \\ \end{tabular} \end{center}
You define whether you’ll need a column line in \begin{tabular}{l l l l l l}, where the second set of braces located. So l l l l l means 5 left alignment’s, if I write |c|c|c|c|c| then I’ll get colomn lines (\cline) and text centered. \hline is obviously a horizontal line.
More on tables: http://en.wikibooks.org/wiki/LaTeX/Tables.
Tikz
Tikz is always a headache for me. I do not have enough time to dig through it but I know it’s extreamly powerful.
Here is some code I wrote for probability tree:
\tikzstyle{level 1}=[level distance=3cm, sibling distance=7cm] \tikzstyle{level 2}=[level distance=1.5cm, sibling distance=3.5cm] \tikzstyle{level 3}=[level distance=2.5cm, sibling distance=2cm] \tikzstyle{fly}=[text width=2em, text centered] \tikzstyle{end}=[circle, minimum width=1pt, fill, inner sep=0pt] \begin{tikzpicture}[grow=right, sloped] \node[fly] {} child { node[fly] {B} child { node[fly]{B} child { node [end, label=right:B BBB 0.027] {} edge from parent node[above] {0.3} } child { node[end, label=right:G BBG 0.063] {} edge from parent node[above] {0.7} } } child { node[fly]{G} child { node[end, label=right:B BGB 0.063] {} edge from parent node[above] {0.3} } child { node[end, label=right:G BGG 0.147] {} edge from parent node[above] {0.7} } } } child { node[fly] {G} child { node[fly]{B} child { node[end, label=right:B GBB 0.063] {} edge from parent node[above] {0.3} } child { node[end, label=right:G GBG 0.147] {} edge from parent node[above] {0.7} } } child { node[fly]{G} child { node[end, label=right:B GGB 0.147] {} edge from parent node[above] {0.3} } child { node[end, label=right:G GGG 0.343] {} edge from parent node[above] {0.7} } } }; \end{tikzpicture}
You’ll see what it looks like when you compile it to PDF.
Bullet Points and Indentation
There are 3 types of bullet points listing, itemize(points or dashes), enumerate(using numbers and abc’s) and description, can be nested. No external package required. Code is like this:
\begin{itemize} \item Be Professional \begin{itemize} \item Formal \item Subject Line - State the Purpose \item Hello, Good Morning, Good Afternoon ... \item Clear, concise, get to the point \item Proofread everything \end{itemize} \item Don't be Emotional \begin{itemize} \item Angry, Sad, Frustrated. \item Never assume the receiver will take your message the way you expect. \item Limit the exchanges \item Limit the "reply all" Button \item Acronyms \begin{description} \item[yes]: TQM(Total Quality Management)/CEO/ROI \item[no]: LOL/TTYL/CUL8R \end{description} \end{itemize} \end{itemize}
Compilation
is so great when it work with Makefile. I didn’t write much for my Makefile, here is the general template:
LC = pdflatex # LC stands for Latex Compiler SOURCE = assign5.tex OUTPUT = assign5.pdf make: all all: $(SOURCE) $(CC) $(SOURCE) $(OUTPUT) okular $(OUTPUT) #okular is my pdf viewer.
When you see an error or warning while compiling PDF from .tex files, read where the problem is, and type X then enter to quit compilation. Otherwise sometimes pdflatex will drain your CPU resource.
When you finish your document, put \end{document} at the very bottom.
texlive
This is the package you need to install under your system. For Linux users, package manage systems should already include most of the latex packages.
For RHEL and Fedora users, type
sudo yum install texlive*
should do the intallation job.
I will add more notes when it comes to me.