Beginning Latex : Tutorial For Beginners
So you are writing a paper and you need to display formulas or math in it. Then this quick beginning Latex tutorial is for you. Your paper needs to be accurate and look good. You then go to your favorite word processor to type things out. It is then you discover, maybe for the first time, that regular text editors can not do math very well. You may be trying to display physics equations, biology genes, or chemical formulas.
Whichever it is, you realize you have to be super creative to even approach the accuracy that you want. At this point you will probably start asking around or researching the best way to do this. Well let me tell you folks, there is a better way. This is when most people find out about the wonderful Latex typesetting environment. Read on and I will explain as simply as I can about Latex.
Beginning Latex Tutorial
Latex is a tool that many people will need eventually. It is great for creating a document exactly the way you want it. It does have a learning curve, however, once you get past that it is quicker to create an advanced document than a word processor.
If you write about math then this is your go to solution. Scientists and mathematicians use this every day.
Getting Latex Free
Latex is easy to get. It is free. You can not beat that. You just download it to your computer and start working with it. For Linux users try here. If you are a Mac user then you go to this site. If you are using Windows then go here. That is all there is to it. Follow the directions from there that you are given. This article by the way is a quick Latex tutorial for Windows who need more functionality than Microsoft Word or Google Docs gives them.
You can use any editor. The document you create just needs the appropriate extension. There are also TEX environments available like [TexWorks] and [TexMaker]. I use them both.
Installing Latex
You first need to install a distribution. This can be something like MikTex, TexLive, or ProText. They are all good and it does not matter which one. It did not to me when I looked at their differences.
Then you either work from the console, use an editor, or an IDE. Again it does not matter which you do as long as you are comfortable with it. most people prefer IDE's from what I have seen. Here is a picture of TexMaker below.
Your First Document
There are two ways to create your first document. First of all, use the text editor of your choice and write a sentence. Save the file as a [.tex] file. Now open a terminal and navigate to the directory of the document to run it. The second choice, if it is available, is to use your TEX environment to run the file you just created.
Latex Uses Backslashes
The first thing you might notice about Latex is that is uses backslashes to start every command. I felt it was important to mention. Every time I have a document that will not compile it was because of a missing backslash. A little reinforcement will only help you in future debugging I am hoping.
Latex Environments
There are many kinds of environments in Latex. An environment is a section devoted to a specific kind of formatting task. It can be a block of text or an [equation]. There are commands that to start them. I mentioned above that each environment is started and ended with a backslash. It looks like this: [\begin{document] and [\end{document}]. It is not hard to use. The hard part is keeping up with the brackets and backslashes. Examples of beginning latex environments are equation, center, figure, picture, and verse.
This example is simple but it shows the basics of an environment. An environment can grow and be as complicated as you are familiar with the language. It is easy to start though as you can see. So no fearing how complicated it can get. You just do what you need and learn more if you need to.
Note how the commands start with a backslash. They all start like that. Also notice that for every [\begin{equation}] there is a [\end{equation}] with it.
The Parts Of An Article Are Easy To Word With
The document area must be defined. Commands begin with a backslash. Environment declarations have a begin and ending tag. This pretty much describes everything. There are many kinds of environments and commands. The most basic document would be defining the class, starting and then stopping the document. Every document pretty much needs that information in order to compile.
Every document must have [\documentclass{article}]. The [article] option is optional. There are other classes you can use with [\documentclass]. Hope this is not confusing. Since this is a beginner Latex tutorial
Latex Subsections
You can also add subsections easily when writing paragraphs. This is super useful. It is through the [\subsection] command. This works just like the [\section] command. This makes it easy to format your text. Do not make the mistake of writing paragraphs without formatting your text. High school and college students are both very bad at this. This is why the command [\subsection] exists so please use it. Here is an example of beginning latex subsections what it looks like.
Doing More With Documents
In the above section I showed a quick example of what could be done to organize a document. Now I want to go into how to do that. Take a look at this piece of code.
The \documentclass line is always be there. For now assume it does not change. You will also have a \begin{document} and an \end{document}. Everything that makes your document what it is will go between the \begin and \end statements. The above code looks like this once it is run.
Choosing the font size of your document is quite easy. Use \documentclass[15pt]{article} in the beginning of your code.
Organizing Your Documents
Let me show you how to make sections and subsections in your thesis or proposal.
As you can see I used \section for my main topic. Then \subsection is used to narrow down for more organization. We can do even more though because often it is needed. I want to add more sections to each of the planets. How would you do that you might ask? Its done like this.
You will see the statement \subsubsection. Yes it is kind of weird but that is how you make sections within sections. This is the output.
Formatting Text
This is done often by everyone. Fortunately it is easy to do. Just type: \textbf{Planets of our Solar System}
This will make the text bold and stand out.
To emphasize text use: \emph{Mercury}
Creating Tables of Information
Latex Packages
You can add functionality to your installation by downloading morepackages. To use different packages you use the [\usepackage] command. You do this in the preamble of the document. There are many packages to use. You just download them to use. It is nice and simple. To search for different packages to download you go to CTAN. In the future I will write the most useful packages and how to use them.
Using Equations
This beginning Latex tutorial for math is designed to show equations and formulas. If you have ever used a word processor you know how hard this can be. In addition to using a math environment, you can also just include an equation in the middle of a sentence. You do this by putting [$] symbols around your math. This is really just when you want to put a formula into the middle of your text. This is not for doing expressions. You do it like this: [$x^2+ 6x -3$]. The exponents will be in the proper position then.
Aligning Equations Makes A Huge Difference
It is easy to align equations in Latex. You do so by using the command [\begin{align}]. You will end it by using [\end{align}] when you are done with that section. This makes all your equations look beautiful. It is for your math environments that have expressions. When you want equations to look nice, that is what you do. It also helps in making comparisons because the equations or formulas are seen more clearly.
Typesetting Latex Matrices
Latex can even do matrices. This is very useful. It is done by [\begin{matrix}] and ended by typing [\end{matrix}]. This is very practical for math students. There are other ways of doing them too. So you have options if the regular way of [\begin{matrix}] does not fit your needs.
As you can see it is easy to get a matrix going. Here is the simple code for that.
Two things to watch out for:
First, just make sure you space everything out correctly. I added spaces so I would be less prone to mistakes.
Second, you need to watch for those backslashes. Missing one will mess up the code when it compiles.
Using Powers
Latex can easily handle equations with powers or exponents. It even doessubscripts well too. Here are a couple quick examples. This shows the versatility of Latex code. Here I just made up some arbitrary numbers for equations. So don’t go trying to factor them. I have a feeling it will end badly. Anyway, a couple things I want to point out is that the equations are right justified and they are automatically numbered.
You can adjust the left or right justification if you need to at some point. It is also very handy to have the equations numbered when you are going through steps in an equation.
The code to generate this is short but powerful. Here it is. It is just the basics in order to show you the equations above. Notice after the first equation that there are two backslashes. You do not want to forget those. I will again mention to not forget your other backslashes. Also you see every regular command has a [\begin] and [\end] section. So when you are writing your code pay attention to that.
Typesetting Fractions
Fractions are also handled nicely. It is done by the [\frac] command. The first example is just a plain old fraction. See, that really is easy. It is numbered and that is about it. Now the second expression is adding two fractions together. You can see how things are spaced and aligned with each other. The third expression starts showing some of the real potential here. You will notice it is a complex fraction. It looks very good.
Note the code below. It still does not take very much code to accomplish the fractions above. Nor is the code complex. It is actually very simple. Latex can do so much more just so you know. I just typed some random expression in my head and added some spacing. That is it. That is how you do fraction and should cover most of your needs.
Using Square Roots Is Not Complicated
You can do square roots in beginning latex as well. While not terribly exciting they are still important to know. In the first expression I just do a simple root. The second expression I show how you can be a bit more complicated and add a fraction under the root. For the third expression I show how to do a whole expression under the root. All these forms are useful.
In the code below I demonstrate how to do square roots. Note the simple syntax. Just remember to keep everything spaced so you can see potential errors. If everything goes well you will be shooting out roots in no time.
Typesetting Derivatives
Making derivatives look nice is something you want to do too. It is quite easy also. You are just putting a fraction over a fraction. In beginning Latex you will use derivative notation heavily.
This is how you can do derivatives. There are a myriad of ways to do them. There are different styles and display modes for everything mathematical. So this is just one way to accomplish it. The equations are again numbered. They are spaced out as well nicely. This is evident in the code. You can see at any time how to adjust your vertical spacing. In the code itself I am still using [amsmath] package. There are several more math packages. One day I will get to them all. I am just concentrating on the basics for this quick latex tutorial.
Using Integrals
Integrals are one of the most used equation forms out there. Look how much you can do. Here are example integrals. They are the opposite of derivatives in a way. The typesetting here in this beginning latex tutorial looks really good. Integrals are done flawlessly. Notice at bottom and top of the integral symbol you have the area where the calculation takes place.
In the code window below you have the integration examples. This is just standard. It is meant to be combined with the other examples above or whatever your math needs are. This does not take complex code as you can see. For each type of math we do the code is always pretty simple.