Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 741
License: APACHE
1
\documentclass{article}
2
3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4
%
5
% Hello, this is the start of a LaTeX document
6
%
7
% First rule: everything after a percent-sign is a comment.
8
% It is ignored and does not show up in the final PDF document.
9
%
10
% Second rule: everything that starts with a backslash \ is a command.
11
% This is used for everything!
12
% * \begin{document} signals where the real meat of the file starts (after the preemble)
13
% * \section and \subsection structure the document
14
% * and much more ...
15
%
16
% Third rule: In between the commands, or inside the command's arguments in {...} you write text.
17
% You can make arbitrary single linebreaks, which will not break apart a paragraph.
18
% Two or more linebreaks signal the start of a new paragraph.
19
%
20
% Formulas: LaTeX is most famous for writing formulas. They're inside of $...$ or
21
% \begin{equation}
22
% ...
23
% \end{equation}
24
% environments.
25
%
26
% Why? Well, this might seem overly complex, but in the end it is also very precise.
27
% You can define exactly what each part of the document should be and LaTeX formats it for you.
28
%
29
% Got interested? Here is a link to an online LaTeX book explaining more about all this:
30
% https://en.wikibooks.org/wiki/LaTeX
31
%
32
% Now, skim over the preemble and find the \begin{document} command
33
%
34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36
% set font encoding for PDFLaTeX or XeLaTeX
37
\usepackage{ifxetex}
38
\ifxetex
39
\usepackage{fontspec}
40
\else
41
\usepackage[T1]{fontenc}
42
\usepackage[utf8]{inputenc}
43
\usepackage{lmodern}
44
\fi
45
46
% used in maketitle
47
\title{My first \LaTeX{} document}
48
\author{My Name}
49
50
% Enable SageTeX to run SageMath code right inside this LaTeX file.
51
% documentation: http://mirrors.ctan.org/macros/latex/contrib/sagetex/sagetexpackage.pdf
52
\usepackage{sagetex}
53
54
55
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
56
\begin{document}
57
58
\section{First Steps}
59
60
This is a short introduction document to \LaTeX{}.
61
You write the code on the left hand side of this editor,
62
while compiled and rendered output shows up on the right hand side.
63
64
Pay attention to any syntax errors!
65
\LaTeX{} is a programming language and stops compiling and updating the document upon errors.
66
Any command starts with a backslash.
67
Watch out for the red "Errors" tab and inspect any problems.
68
69
\subsection{Subsection}
70
71
You can organize your document in sections,
72
just like this one here is a subsection!
73
74
\subsection{Another one ...}
75
76
Here is \textit{another one},
77
where the text ``another one'' is formatted italic.
78
79
\textbf{Bold font} is also possible.
80
81
\subsection{Formulas}
82
83
Latex is famous for setting formulas.
84
This is usually done between dollar signs.
85
For example: $\int_{x=0}^{\infty} \frac{1}{2 + x^2}\;\mathrm{d}x$.
86
87
\section{SageMath}
88
89
You can also run a couple of computations with Sage and embed the output right here in the document.
90
91
% this line here is an invisble comment
92
% and the block below some sage code setting x and y but not producing any output.
93
\begin{sagesilent}
94
x = var('x')
95
a = 1328782374
96
b = 2394728347628374
97
\end{sagesilent}
98
99
% Here, we use x and y defined above:
100
The product of $\sage{a}$ and $\sage{b}$ is \\
101
$\sage{a*b}$
102
and its prime factorization: $\sage{factor(a*b)}$.
103
104
It is also possible to create a plot:
105
106
\begin{center}
107
\sageplot[width=.5\textwidth]{plot(sin(x) * cos(3*x), (x, -10, 10))}
108
\end{center}
109
110
% this is the last command of the document.
111
\end{document}
112
113
% Do NOT edit past the last command!
114
115
116