Friday, September 26, 2014

Starting out in LaTeX

Part 1

Now that we have texmaker on our computer, we can begin to create Tex documents!

Today I am going to introduce to you to a basic "Hello World" type program that will show you basic concepts in TeX. 

Open up texmaker. When you open it up, you should see something like this:

To create a new file you can do one of two things:
  • Go to File -> New
  • Ctrl + n
Once you have created a file, type in the following code into the right window:

\documentclass[12pt]{article}
\begin{document}
Hello, \emph{World}!
\end{document}


Now, save the file wherever you want and then go to Tools -> PDFLaTeX. This will convert the file into a PDF file so that other computers can see it. Go into the folder where you saved the TeX file, and you should find a PDF there. When you open it, it should look something like this:


 
As you can see, we now have a PDF that shows the words "Hello, World!" but...

How does this code work exactly?

Code explanation

The line \documentclass[12pt]{article} declares what type of document type it will be. Here, the document type is being declared as an article. This line also shows what the font size will be. This line makes the font size 12pt font, but we can edit this to be either 10, 11, or 12. So I could have written:

\documentclass[10pt]{article}

\begin{document} and \end{document} should be fairly self explanatory. We are designating the beginning and the end of the document. Anything within these two lines will be put into the document. 

Hello, \emph{World}!

Here, we are putting Hello, World! in the PDF.

The portion that should be noted here is \emph{World}! 
  
As you may have guessed, \emph is short for emphasis. Anything between the braces will be emphasized. In other words, they will be italicized. However, this is not the only way to italicize text. Text can also be italicized by using \textit{} where, again, everything between the braces are italicized. 


Hopefully you learned some more about LaTeX. In my next tutorial, I will go over how to make lists in LaTeX as well as basic formatting. The next tutorial will be longer than this, so it will be up by Sunday night. 

Thanks for reading. If you liked this tutorial, make sure to share this blog with others. 







No comments:

Post a Comment