Welcome to this LaTeX tutorial creating your first LaTeX document LaTeX is a document markup
language mostly used to produce technical documents such as research papers and mathematical
books LaTeX is particularly good in producing documents which have mathematical notation
for example a math report or a math homework to use LaTeX you have to install 3 things
the first is the LaTeX distribution which will compile your latex code and there are
couple of options for example Windows PC users the recommended LaTeX distribution is MiKTeX
This MiKTeX can be downloaded from this miktex.org website there is another option which is called
Texlive and which can be downloaded from tug.org and I have made a comparison between these
two in one of my other videos which you can watch I will put a link in this video but
I am assuming that you have installed this MiKTeX distribution and if you dont know how
to install this distribution I will also put a link to my video which shows how to install
miktex but this is the first thing you need to have in order to produce a latex document
so latex document is a pdf document which is the output but the file in which we write
the code is a tex file it has an extension .tex so we will discuss this in a minute second
thing you need is a LaTeX text editor and currently as you can see that I am using this
Texmaker this is a text editor for latex in which we write the code and then we compile
it it provides us the compiler and as well as the viewer which is the third component
in order to see our output the third thing you need is a pdf viewer so you can use any
pdf viewer for example Adobe acrobat pdf viewer is one of the very popular pdf viewer there
is another one called foxit you can use that one or any other pdf viewer is ok so these
are the three basic components in order to produce a latex document so once you have
installed all these three components then you can open up any of the editor Texmaker
is one the second famous editor is TeXstudio and another very popular is WinEdt so if you
are using Texmaker so before you write your first program I would recommend you to configure
this Texmaker and this can be done by going into this option menu and there is an item
here configure Texmaker if you click on that so on the left hand side there are four tabs
command, quickbuild, editor and shortcuts we will not talk about shortcuts but in these
three you have to check few things so first in the command tab you should look for these
two that these two are enabled builtin viewer builtin viewer means your pdf viewer is inside
the editor and you can quickly see the output file and you just tick this embed as well
so under this quickbuild tab you should check this pdf-to-Latex + viewpdf so it will compile
the document and it will view the output file which will be a pdf file so this is normlly
checked by default but sometimes you might have changed this so just double check this
thing then under the editor tab you have to check these three things word wrapping completion
and show line numbers line numbers will help you identifying where is the error if there
is any error so you will be able to quickly identify the location of the error so once
these few options are set so if you want to save your work after 10 minutes or so you
can also check this backup document every 10 minute now you are ready to begin your
first document so in order to do that we start a new file latex commands start with backslash
so there are three commands which must be present in a latex document so the first command
is documentclass and as you can see that when we start to type this editor is showing us
this option so you can press enter and it will automatically insert this option this
is auto-completion now you have two pair of brackets here one is the pair of square brackets
the other is pair of curly brackets so in the pair of square brackets we have options
so let us see what kind of options are available so these are some of the options available
as you can see here so in the square bracket you can put options option-1 option-2 option-3
and what are these options these options could be there are many possible options for example
you can put font sizes by default its 10pt you can put 11pt or 12pt similarly you can
change the paper size so there are many paper sizes available sometimes you have to use
the landscape option so so whatever is written in the green you can put it here so lets say
we put a4 paper size a4paper and in the second curly bracket we have to tell LaTeX what type
of document is this so we have to put the name of the class so there are few types of
classes available in latex you can design your own classes if you are an expert in programming
but by default mostly we use these three classes, article class, report class , book class but
for this first lecture we will be using article class just put article so this is the first
compulsory command in a latex document thye second compulsory command is begin document
and as we are typing its asking us to insert this so we can insert this begin document
and this command is always in pair so begin document and end document anything which starts
with begin it should have an end and all these types of commands are called latex environments
so document is an environment begin document and end document is the body of the document
and anything before this begin document this area is called preamble and this is useful
to know because there are some errors in which you will see this message so you should know
that preamble is the area before the begin document and now this is an empty document
so before we can do anything with the document for example before we could compile the document
we must save the document because if I now press this it will show me the error and lets
say i press this so this is the error a document must be saved with an extension I have to
close this and close this so now lets save this document so file save as i will save
this on my desktop so that I could show you something later on so create a new folder
here so i just created a folder on my desktop and I saved this document in this folder and
this is an empty folder and the document name is latex tutorial 1 and as you can see that
this is an empty document there is no code here so lets put something so we can say This
is my first document and now i compile and view it so as you can see that this is the
pdf the output pdf of my document so this is my first document now this is the text
mode so lets say i enter here I say this is the second line of my text and if I recompile
this and view the document now you will notice that although I have entered a line here but
the text is continuous this is because latex does not break the line if we go to the next
line so in order to break the line there are two ways the first way is you put double backslash
and the latex will break the line and now see what kind of line break is this if i compile
this again and view the document as you can see that it has started a new line because
of these double backslash but this line is indented in a different way this line starts
from the beginning and this is because first line is the first line of the paragraph which
is automatically indented in latex and i have discussed this formatting in one of my other
videos which I will put a link here right here in the video which you can watch if you
want this line to start at the same point a new paragraph just like a new paragraph
so then instead of these two lines there is another way of inserting a line and which
is just put an empty line if i insert an empty line see what happens I compile this again
and view the document now you can see that these are basically two different paragraphs
both are indented so this is how you can align two lines but there are many ways in latex
so we will be discussing this in other videos so this is a little bit because when some
students come from other text editors they expect that when they enter a line there is
a line break but this is not the case in latex the second thing i would like to show you
is how to write a mathematical notation something like this The product of 1+x and x square
i want to write x square so x raise to the power 2 so the way I write is x ^ 2 this is
a way of writing mathematical code I want to write this in a mathematical notation so
I have to put a dollar sign at the beginning and at the end of this sentence which i want
to write in mathematical notation although only x+1 and x square is true mathematical
phrase but I have just written all this in the mathematical form so in order to show
you the difference so if i compile this now and view, you see that there is no space is
here because if you write something in mathematical notation then you have to follow the rules
for mathematical notation so everything between these two dollar signs is called the math
mode this is math mode so there are different rules for writing the math mode in math mode
these spaces are ignored and if you want to put a space you have to put a tilde sign here
if I put a tilde sign here this then a tilde sign here and a tilde sign here then it will
insert the spaces here the second difference is the way it looks different this looks like
italics or something like that if i compile it again and view the document now there are
spaces but the style of math mode typing is different than the text mode typing I want
to type this in the normal way I just want to type these two phrases in mathematical
notation so what can i do is just remove this dollar sign and put the dollar sign where
I want the mathematical where i want the mathematical phrases so just these and then I can remove
this tilde because this is a way of writing in math mode now the other difference you
can notice here is that anything within the dollar sign in the math mode is green and
anything in the text mode is black similarly the commands are blue and the documentclass
is red or brown this is called "Syntax Highlighting" and syntax hughlighting is available in almost
all latex editors whether you use textstudio Texmaker or Winedt all have this syntax highlighting
in some of the editors you can change these colors, color of your own choice color combinations
of your own choice so this is one of the things you can do so now if i compile and see what
happens now you can see that our text is text and only these two are in mathematical and
now as you can see that now we have to insert a space here because so everything is fine
only these only these are mathematical notations they are different otherwise the text is same
so this is how you write math in latex this way of writing math is called inline math
mode because we are writing math notations within the text so what if I want this notation
or any other notation on a separate line so for that I have to use double dollar sign
so if i use double dollar sign here now this will become on the next line even if type
in front of it this will be on the next line so although I have typed just in front of
that but it is on the next line because I am using double dollar sign another way of
writing on a separate line is by using backslash and this this is also equivalent to double
dollar sign this is another way of writing the same thing so for example I write x cube
plus x square plus one and then I write then I write the same thing is another line so
you have to start with a backslash then square bracket then backslash and the square bracket
at the end now even if I write in front of this This is the next line it will appear
on the next lien because this is called display math mode because this is a display math mode
so there is also a command displaymath and you can also use that now let us see the third
way of writing in math mode and that is by using the displaynmath environment begin you
can keep typing or you can just type a little bit and then select it will automatically
put the end displaymath so this is display math which is also a math mode so I can write
any equation here for example x square plus two x plus one so as you can see that x square
plus 2x + 1 you can notice here that the color does not change in displaymath it only changes
if you use dollar double dollar or this symbol so this is another way of writing mathematics
in latex now the last thing I would like to show you is the folder so this is the folder
which i have created and as you can see that there are a lot of files we only created a
.tex file which was this one in which we wrote our code and then we created a pdf file but
there are also some other files as well you can say that these files the auxiliary file
and this log file these are the files which are a by product of creating a pdf file you
can consider it like this these files latex creates in order to create the pdf output
so this is it for this tutorial I hope that you find this tutorial useful and now you
can start writing text and mathematical notations in your LaTeX documents.