diff options
Diffstat (limited to 'overleaf-30m')
| -rw-r--r-- | overleaf-30m/simple.tex | 282 |
1 files changed, 282 insertions, 0 deletions
diff --git a/overleaf-30m/simple.tex b/overleaf-30m/simple.tex new file mode 100644 index 0000000..26d79d4 --- /dev/null +++ b/overleaf-30m/simple.tex @@ -0,0 +1,282 @@ +% "30m" but took me 2h. Very informative. I've copy pasted the examples here +% to play with them. Reading this tutorial before starting big LaTeX projects +% (like my thesis) would've been very beneficial and safe me some time and +% headaches. I'm happy I've read it and completed it now, some concepts are +% now much clearer. +% +% Ref.: https://www.overleaf.com/learn/latex/Learn_LaTeX_in_30_minutes + +% preamble ("setup" section) +% ============================================================================ +\documentclass[12pt, a4paper]{article} +% document class: article (other options include book and report) +% aditional options: 12pt font (default is 10pt), a4paper size + +% Loading packages `\usepackage[options]{package}` +\usepackage{graphicx} +\graphicspath{{img/}} +\usepackage{amsmath} % For the "equation*" environment +\usepackage{parskip} % Used to typeset paragraphs with larger spacing +% \usepackage[ +% total={6.5in,8.75in}, +% top=1.2in, left=1.0in, includefoot +% ]{geometry} + +\title{My first LaTeX document} +\author{Hubert Farnsworth\thanks{Funded by the Overleaf team.}} +\date{September 2023} +% \date{\today} + + +% actual content +% ============================================================================ +\begin{document} +\maketitle +\tableofcontents +\begin{abstract} + This is a simple paragraph at the beginning of the document. A brief + introduction about the main subject. +\end{abstract} + +% \part{Learn} + +% \chapter{Learn \LaTeX} + +\section{Basic typesetting} + +First document. This is a simple example, with no extra parameters or packages +included. + +We have now added a title, author and date to our first \LaTeX{} document! + +Some of the \textbf{greatest} +discoveries in \underline{science} +were made by \textbf{\textit{accident}}. (\textit{italics}.) + +% emphasize (toggles italics depending on context) +% (some packages, such as Beamer, change the behaviour of the \emph command.) +Some of the greatest \emph{discoveries} in science were made by accident. + +\textit{Some of the greatest \emph{discoveries} in science were made by accident.} + + +% "starred version" of the appropriate command +\section*{Unnumbered section} +% unnumbered sections aren't added to the TOC by default +\addcontentsline{toc}{section}{Unnumbered Section} + +Lorem ipsum dolor sit amet, consectetuer adipiscing +elit. Etiam lobortisfacilisis sem. Nullam nec mi et +neque pharetra sollicitudin. Praesent imperdietmi nec ante. +Donec ullamcorper, felis non sodales... + + +\section{Figures} + +% images + +% The \includegraphcs command is provided (implemented) by the graphicx package +Lorem Ipsum Lorem Ipsum Lorem Ipsum +How is text rendered just before an image? +\includegraphics[width=0.25\textwidth]{rocas} +How is text rendered right after an image? + +% figures: captions, labels, references + +\begin{figure}[h] + % Code here is encapsulated by the "figure" environment + \centering + \includegraphics[width=0.15\textwidth]{rocas} + \includegraphics[width=0.30\textwidth]{rocas} + \includegraphics[width=0.60\textwidth]{rocas} + \caption{From the top left, clockwise: Unas roquitas relajandose, unas rocas + relajandose, unas rocotas relajandose.} + % Caption can be placed above or below the list of figures + \label{fig:rocas} +\end{figure} + +As you can see in figure \ref{fig:rocas}, the rocks are happyto see their owner. +(This example is on page \pageref{fig:rocas}.) + + +\section{Lists} + +% lists + +\begin{itemize} + \item The individual entries are indicated with a black dot, a so-called bullet. + \item The text in the entries may be of any length. +\end{itemize} + +\begin{enumerate} + \item This is the first entry in our list. + \begin{enumerate} + \item This is the 1.1 entry in our list. + \begin{enumerate} + \item This is the 1.1.1 entry in our list. Things begin to look messy + \begin{enumerate} + \item This is the 1.1.1.1 entry in our list. Things begin to look messy + in the source code. + % Maximum default depth (4) reached, further is invalid + % \begin{enumerate} + % \item This is the 1.1.1.1 entry in our list. Things begin to look messy + % in the source code. + % \item The list numbers increase with each entry we add. + % \end{enumerate} + \item The list numbers increase with each entry we add. + \end{enumerate} + in the source code. + \item The list numbers increase with each entry we add. + \end{enumerate} + \item The list numbers increase with each entry we add. + \end{enumerate} + \item The list numbers increase with each entry we add. +\end{enumerate} + + +\section{Math} + +% math + +% inline math uses the "math" environemnt +\begin{math} E=mc^2 \end{math} is typeset in a paragraph using inline math +mode---as is $E=mc^2$, and so too is \(E=mc^2\). + +% display math uses the "displaymath" or the "equation" environment +% (usage of $$ is no longer recommended). +The mass-energy equivalence is described by the famous equation +\[ E=mc^2 \] discovered in 1905 by Albert Einstein. +In natural units ($c = 1$), the formula expresses the identity +\begin{equation} E=m \end{equation} + +% more examples + +Subscripts in math mode are written as $a_b$ and superscripts are written as +$a^b$. These can be combined and nested to write expressions such as + +\[ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = +T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) \] + +We write integrals using $\int$ and fractions using $\frac{a}{b}$. Limits are +placed on integrals using superscripts and subscripts: + +\[ \int_0^1 \frac{dx}{e^x} = \frac{e-1}{e} \] + +Lower case Greek letters are written as $\omega$ $\delta$ etc. while upper case +Greek letters are written as $\Omega$ $\Delta$. + +Mathematical operators are prefixed with a backslash as $\sin(\beta)$, +$\cos(\alpha)$, $\log(x)$ etc. + +% amsmath package: +\begin{equation*} + \sqrt{x^2+1} +\end{equation*} + +% manual newline + +I will start the third paragraph and then add \verb`\\`\\ a manual line break which +causes this text to start on a new line but remains part of the same paragraph. +Alternatively, I can use the \verb|\newline|\newline command to start a new +line, which is also part of the same paragraph. + +% Longer documents, irrespective of authoring software, are usually partitioned +% into parts, chapters, sections, subsections and so forth. + +\section{Document Structure} + +Collectively, LaTeX document classes provide the following sectioning commands, +with specific classes each supporting a relevant subset: + +\begin{verbatim} + \part{part} + \chapter{chapter} + \section{section} + \subsection{subsection} + \subsubsection{subsubsection} + \paragraph{paragraph} + \subparagraph{subparagraph} + +In particular, the \part and \chapter commands are only +available in the report and book document classes. +\end{verbatim} + +\section{Tables} + +TIP: Creating tables in LaTeX can be time-consuming so you may want to use the +https://tablesgenerator.com online tool to export LaTeX code for tabulars. + +\begin{center} +\begin{tabular}{c c c} + % alignment: Center, Right, Left + % &: alignment symbol + % \\: newline + cell1 & cell2 & cell3 \\ + cell4 & cell5 & cell6 \\ + cell7 & cell8 & cell9 +\end{tabular} + +% adding borders (rules) +\begin{tabular}{||c l c r||} + \hline + Col1 & Col2 & Col2 & Col3 \\ [0.5ex] % control extra spacing + \hline\hline + 1 & hola & 87837 & 787 \\ + \hline + 2 & mundo & 78 & 5415 \\ + \hline + % 3 & 世界、 & 778 & 7507 \\ + % \hline + % 4 & こんにちは & 18744 & 7560 \\ + % \hline + 5 & hello world! & 788 & 6344 \\ [1ex] + \hline +\end{tabular} +\end{center} + +% To add captions, labels, and references use the Table environment + +Table \ref{table:data} shows how to add a table caption and reference a table. +\begin{table}[h!] +\centering +\begin{tabular}{||c c c c||} + \hline + Col1 & Col2 & Col2 & Col3 \\ [0.5ex] + \hline\hline + 1 & 6 & 87837 & 787 \\ + 2 & 7 & 78 & 5415 \\ + 3 & 545 & 778 & 7507 \\ + 4 & 545 & 18744 & 7560 \\ + 5 & 88 & 788 & 6344 \\ [1ex] + \hline +\end{tabular} +\caption{Table to test captions and labels.} +\label{table:data} +\end{table} + +\section{Finding and using LaTeX packages} + +Documentation (in pdf format) in +\begin{verbatim} +~/code/tex-live-native/build/texmf-dist/doc/latex +\end{verbatim} + +\LaTeX packages usually have ".sty" extension. + +Packages are distributed through the Comprehensive TeX Archive Network +(https://www.ctan.org/), usually referred to as CTAN. + +Once per year a (large) subset of packages hosted on CTAN, plus LaTeX-related +fonts and other software, is collated and distributed as a system called TeX +Live (https://tug.org/texlive/), which can be used to install your own (local) +LaTeX setup. + +Overleaf (https://www.overleaf.com) makes available thousands of templates in +their gallery (https://www.overleaf.com/gallery). + +Some nice packages like https://ctan.org/pkg/igo?lang=en are hosted on CTAN +but not distributed by TeX Live due to a variety of reasons: perhaps a package +is obsolete, has licensing problems, is extremely new (recently uploaded) or has +platform dependencies, such as working on Windows but not Linux. + +\end{document}
\ No newline at end of file |
