1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-04 22:07:52 +02:00

merge patch-1, restructure, fix grammar

This commit is contained in:
Colton Kohnke
2015-10-09 21:29:01 +02:00
parent 31b063865c
commit f3de591fc5

View File

@@ -6,28 +6,23 @@ contributors:
- ["Sricharan Chiruvolu", "http://sricharan.xyz"] - ["Sricharan Chiruvolu", "http://sricharan.xyz"]
filename: learn-latex.tex filename: learn-latex.tex
--- ---
LaTeX is known to create aesthetically pleasing documents without you worrying
about the formatting. It is also great if one wants to create documents
containing a lot of mathematics. Getting a good document is very easy, but
getting it to behave exactly the way you want can be a bit hairy.
```latex
% All comment lines start with % % All comment lines start with %
% There are no multi-line comments % There are no multi-line comments
% LaTeX is NOT a ``What You See Is What You Get'' word processing software like % LaTeX is NOT a "What You See Is What You Get" word processing software like
% MS Word, or OpenOffice Writer % MS Word, or OpenOffice Writer
% Every Latex command starts with a backslash (\)
% LaTeX documents start with a defining the type of document it's compiling % LaTeX documents start with a defining the type of document it's compiling
% Other document types include book, report, presentations, etc. % Other document types include book, report, presentations, etc.
% The options for the document appear in the [] brackets. In this case
% it specifies we want to use 12pt font.
\documentclass[12pt]{article} \documentclass[12pt]{article}
% Next we define the packages the document uses. % Next we define the packages the document uses.
% If you want to include graphics, colored text or % If you want to include graphics, colored text, or
% source code from a file into your document, % source code from another language file into your document,
% you need to enhance the capabilities of LaTeX. This is done by adding packages. % you need to enhance the capabilities of LaTeX. This is done by adding packages.
% I'm going to include the float and caption packages for figures. % I'm going to include the float and caption packages for figures.
\usepackage{caption} \usepackage{caption}
@@ -42,13 +37,13 @@ getting it to behave exactly the way you want can be a bit hairy.
% Everything before this line is called "The Preamble" % Everything before this line is called "The Preamble"
\begin{document} \begin{document}
% if we set the author, date, title fields, we can have LaTeX % if we set the author, date, title fields, we can have LaTeX
% create a title page fo us. % create a title page for us.
\maketitle \maketitle
% Most research papers have abstract, you can use the predefined commands for this. % Most research papers have abstract, you can use the predefined commands for this.
% This should appear in its logical order, therefore, after the top matter, % This should appear in its logical order, therefore, after the top matter,
% but before the main sections of the body. % but before the main sections of the body.
% This command is available in document classes article and report. % This command is available in the document classes article and report.
\begin{abstract} \begin{abstract}
LaTex documentation written as LaTex! How novel and totally not my idea! LaTex documentation written as LaTex! How novel and totally not my idea!
\end{abstract} \end{abstract}
@@ -56,76 +51,103 @@ getting it to behave exactly the way you want can be a bit hairy.
% Section commands are intuitive. % Section commands are intuitive.
% All the titles of the sections are added automatically to the table of contents. % All the titles of the sections are added automatically to the table of contents.
\section{Introduction} \section{Introduction}
Hello, my name is Colton and together we're going to explore LaTeX ! Hello, my name is Colton and together we're going to explore LaTeX!
\section{Another section} \section{Another section}
This is the text for another section. I think it needs a subsection. This is the text for another section. I think it needs a subsection.
\subsection{This is a subsection} \subsection{This is a subsection} % Subsections are also intuitive.
I think we need another one I think we need another one
\subsubsection{Pythagoras} \subsubsection{Pythagoras}
Much better now. Much better now.
\label{subsec:pythagoras} \label{subsec:pythagoras}
% By using the asterisk we can suppress Latex's inbuilt numbering.
% This works for other Latex commands as well.
\section*{This is an unnumbered section} \section*{This is an unnumbered section}
However not all sections have to be numbered! However not all sections have to be numbered!
\section{Some Text notes} \section{Some Text notes}
LaTeX is generally pretty good about placing text where it should go. If LaTeX is generally pretty good about placing text where it should go. If
a line \\ needs \\ to \\ break \\ you add \textbackslash\textbackslash to a line \\ needs \\ to \\ break \\ you add \textbackslash\textbackslash to
the text. In case you haven't noticed the \textbackslash is the character the source code. \\
the tells the LaTeX compiler it should pay attention to what's next.
\section{Lists}
Lists are one of the easiest things to create in Latex! I need to go shopping
tomorrow, so let's make a grocery list.
\begin{enumerate} % This creates an "enumerate" environment.
% \item tells the enumerate to increment
\item Salad.
\item 27 watermelon.
\item A single jackrabbit.
% we can even override the item number by using []
\item[how many?] Medium sized squirt guns.
Not a list item, but still part of the enumerate.
\end{enumerate} % All environments must have an end.
\section{Math} \section{Math}
One of the primary uses for LaTeX is to produce academic article or One of the primary uses for LaTeX is to produce academic articles or
technical papers. Usually in the realm of math and science. As such, technical papers. Usually in the realm of math and science. As such,
we need to be able to add special symbols to our paper! \\ we need to be able to add special symbols to our paper! \\
Math has many symbols, far beyond what you can find on a keyboard. Math has many symbols, far beyond what you can find on a keyboard;
Set and relation symbols, arrows, operators, Greek letters to name a few. \\ Set and relation symbols, arrows, operators, and Greek letters to name a few.\\
Sets and relations play a vital role in many mathematical research papers. Sets and relations play a vital role in many mathematical research papers.
Here's how you state all y that belong to X, $\forall$ x $\in$ X. Here's how you state all y that belong to X, $\forall$ x $\in$ X. \\
Notice how I needed to add \$ signs before and after the symbols. This is % Notice how I needed to add $ signs before and after the symbols. This is
because when writing, we are in text-mode. However, the math symbols only exist % because when writing, we are in text-mode.
in math-mode. We can enter math-mode from text mode with the \$ signs. % However, the math symbols only exist in math-mode.
The opposite also holds true. Variable can also be rendered in math-mode. \\ % We can enter math-mode from text mode with the $ signs.
% The opposite also holds true. Variable can also be rendered in math-mode.
My favorite Greek letter is $\xi$. I also like $\beta$, $\gamma$ and $\sigma$. My favorite Greek letter is $\xi$. I also like $\beta$, $\gamma$ and $\sigma$.
I haven't found a Greek letter that yet that Latex doesn't know about!
Operators are essential parts of a mathematical document: trigonometric functions Operators are essential parts of a mathematical document:
(sin, cos, tan), logarithms and exponentials (log, exp), limits (lim) e.t.c. have trigonometric functions ($\sin$, $\cos$, $\tan$),
pre-defined LaTeX commands. Let's write an equation to see how it's done: \\ logarithms and exponentials ($\log$, $\exp$),
limits ($\lim$), etc.
have per-defined LaTeX commands.
Let's write an equation to see how it's done: \\
$\cos$ (2$\theta$) = $\cos$^2 $\theta$ - $\sin$^2 $\theta$ $\cos(2\theta) = \cos^{2}(\theta) - \sin^{2}(\theta)$
Fractions(Numerator-denominators) can be written in these forms: Fractions(Numerator-denominators) can be written in these forms:
% 10 / 7 % 10 / 7
^10/_7 $^{10}/_{7}$
% Relatively complex fractions can be written as % Relatively complex fractions can be written as
% \frac{numerator}{denominator} % \frac{numerator}{denominator}
$\frac{n!}{k!(n - k)!}$ $\frac{n!}{k!(n - k)!}$ \\
We can also insert equations in an "equation environment."
% Display math with the equation 'environment' % Display math with the equation 'environment'
\begin{equation} % enters math-mode \begin{equation} % enters math-mode
c^2 = a^2 + b^2. c^2 = a^2 + b^2.
% for cross-reference \label{eq:pythagoras} % for referencing
\label{eq:pythagoras} \end{equation} % all \begin statements must have an end statement
\end{equation} % all \begin statments must have an end statement
We can then reference our new equation!
Eqn.~\ref{eq:pythagoras} is also known as the Pythagoras Theorem which is also Eqn.~\ref{eq:pythagoras} is also known as the Pythagoras Theorem which is also
the subject of Sec.~\ref{subsec:pythagoras}. the subject of Sec.~\ref{subsec:pythagoras}. A lot of things can be labeled:
figures, equations, sections, etc.
Summations and Integrals are written with sum and int commands: Summations and Integrals are written with sum and int commands:
\begin{equation} % enters math-mode
\sum_{i=0}^{5} f_i
\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x % Some latex compilers will complain if there are blank lines
% In an equation environment.
\begin{equation}
\sum_{i=0}^{5} f_{i}
\end{equation}
\begin{equation}
\int_{0}^{\infty} \mathrm{e}^{-x} \mathrm{d}x
\end{equation} \end{equation}
\section{Figures} \section{Figures}
@@ -133,40 +155,56 @@ Summations and Integrals are written with sum and int commands:
Let's insert a Figure. Figure placement can get a little tricky. Let's insert a Figure. Figure placement can get a little tricky.
I definitely have to lookup the placement options each time. I definitely have to lookup the placement options each time.
\begin{figure}[H] \begin{figure}[H] % H here denoted the placement option.
\centering \centering % centers the figure on the page
% Inserts a figure scaled to 0.8 the width of the page.
%\includegraphics[width=0.8\linewidth]{right-triangle.png} %\includegraphics[width=0.8\linewidth]{right-triangle.png}
% Commented out for compilation purposes. Use your imagination. % Commented out for compilation purposes. Please use your imagination.
\caption{Right triangle with sides $a$, $b$, $c$} \caption{Right triangle with sides $a$, $b$, $c$}
\label{fig:right-triangle} \label{fig:right-triangle}
\end{figure} \end{figure}
\subsection{Table} \subsection{Table}
Let's insert a Table. We can also insert Tables in the same way as figures.
\begin{table}[H] \begin{table}[H]
\caption{Caption for the Table.} \caption{Caption for the Table.}
\begin{tabular}{ccc} % the {} arguments below describe how each row of the table is drawn.
Number & Last Name & First Name \\ % Again, I have to look these up. Each. And. Every. Time.
\hline \begin{tabular}{c|cc}
Number & Last Name & First Name \\ % Column rows are separated by $
\hline % a horizontal line
1 & Biggus & Dickus \\ 1 & Biggus & Dickus \\
2 & Monty & Python 2 & Monty & Python
\end{tabular} \end{tabular}
\end{table} \end{table}
% \section{Hyperlinks} % \section{Hyperlinks} % Coming soon
\section{Getting Latex to not compile something (i,e, Source Code)}
Let's say we want to include some code into our Latex document,
we would then need Latex to not try and interpret that text and
instead just print it to the document. We do this we a verbatim
environment.
% There are other packages that exist (i.e. minty, lstlisting, etc.)
% but verbatim is the bare-bones basic one.
\begin{verbatim}
print("Hello World!")
a%b; % look! We can use % signs in verbatim.
random = 4; #decided by fair random dice roll
\end{verbatim}
\section{Compiling} \section{Compiling}
By now you're probably wondering how to compile this fabulous document By now you're probably wondering how to compile this fabulous document
(yes, it actually compiles). \\ and look at the glorious glory that is a Latex pdf.
(yes, this document actually does compiles). \\
Getting to the final document using LaTeX consists of the following steps: Getting to the final document using LaTeX consists of the following steps:
\begin{enumerate} % we can also created numbered lists! \begin{enumerate}
\item Write the document in plain text \item Write the document in plain text (the "source code").
\item Compile plain text document to produce a pdf. \item Compile source code to produce a pdf.
The compilation step looks something like this: \\ The compilation step looks something like this (in Linux): \\
% Verbatim tells the compiler to not interpret.
\begin{verbatim} \begin{verbatim}
$pdflatex learn-latex.tex learn-latex.pdf $pdflatex learn-latex.tex learn-latex.pdf
\end{verbatim} \end{verbatim}
@@ -191,5 +229,3 @@ That's all for now!
* The amazing LaTeX wikibook: [https://en.wikibooks.org/wiki/LaTeX](https://en.wikibooks.org/wiki/LaTeX) * The amazing LaTeX wikibook: [https://en.wikibooks.org/wiki/LaTeX](https://en.wikibooks.org/wiki/LaTeX)
* An actual tutorial: [http://www.latex-tutorial.com/](http://www.latex-tutorial.com/) * An actual tutorial: [http://www.latex-tutorial.com/](http://www.latex-tutorial.com/)