LaTEXON Tutorials
Introduction to LaTeX
1. Basic Structure
What you see below is the most simplest structure of a LaTeX file. Every LaTeX file starts by defining the class type. Here classtype is article, which defines the style of the document. Also, the font size is set at 12pt that is provided within square brackets. If you do not specify the font size, then LaTeX chooses the default font size which is 10pt.
\documentclass[12pt]{article} \begin{document} This is my first latex document. \end{document}
You get the following output when you run the above code.
By changing the document class, you can create various documents. For example, \documentclass{report} will set the style of report class.
The only content that is given between the \begin{document} and \end{document} will be visible in the output document. However, you need several packages to create standard LaTeX documents. We can include those additional packages by setting the command \usepackage{}. For example, the below code uses two packages: inputenc and graphicx. The purpose of the packages will be discussed in the following sections.
\documentclass[12pt]{article} \usepackage[utf8]{inputenc} \usepackage{graphicx} \begin{document} This is my first latex document. \end{document}
2. How to set the document heading?
A document must have a title and author details. We can set such details using the following commands: \title{} sets the title, \author{} sets the author details, \date{} provides the date. These are defined before the \begin{document}. Therefore, these information will not be visible in the output document. We use \maketitle just after the begin document to make the title visible to the document.
\documentclass{article} \usepackage[utf8]{inputenc} \title{LaTeX Document Preparation} \author{Author} \date{June 2022} \begin{document} \maketitle This is my first LaTeX document. \end{document}
When you compile the above code, you get the document with a title which looks like the figure given below.
3. How to run this code?
We recommend you to use overleaf for creating document. Please go to overleaf.com, and create an account then start executing the code.
other tutorials
Need Help?
If you need any further clarification or assistance in LaTeX coding, feel free to contact us.