Basic $\LaTeX$ Usage
Introduction
So, we are here to learn one of, if not the most, powerful typesetting systems in the world, $\LaTeX$. LaTeX is a document preparation system that is widely used for scientific and technical documents. It is especially useful for writing documents that contain a lot of mathematical symbols and equations. In this tutorial, we will cover the basics of $\LaTeX$, including how to write simple text, how to include mathematical symbols, and how to create a PDF document.
Some History
$\LaTeX$ is based on the $\TeX$ typesetting system, which was created by Donald Knuth in the late 1970s. $\TeX$ is a low-level typesetting system that is used to produce high-quality documents. $\LaTeX$ is a set of macros that provides a higher-level interface to $\TeX$. It was created by Leslie Lamport in the 1980s and is now the de facto standard for writing scientific and technical documents.
But why did $\TeX$ exist in the first place? Well, Donald Knuth was not happy with the quality of the typesetting in the second edition of his book, “The Art of Computer Programming.” He decided to create his own typesetting system that would produce high-quality output. The result was $\TeX$, which is now widely used by mathematicians, scientists, and other technical writers.
Getting Started
Installing $\LaTeX$
Below, you can see some ways to install $\LaTeX$ on your system:
- Windows: MikTeX
- Mac: MacTeX
- Linux: TeX Live
- Ubuntu:
sudo apt-get install texlive-full
- Fedora:
sudo dnf install texlive-scheme-full
- Arch:
sudo pacman -S texlive-most
- OpenSUSE:
sudo zypper install texlive-scheme-full
- Gentoo:
sudo emerge texlive
- Ubuntu:
- Online: Overleaf
For starters, you can use Overleaf, which is an online $\LaTeX$ editor that allows you to create and edit documents without having to install any software on your computer. It is a great way to get started with $\LaTeX$ without having to worry about installing anything. Once you are comfortable with $\LaTeX$, you can then install it on your computer.
As you can see, some of the distributions have texlive packages. You can install them by running the commands above. However, some are deprecated or non-existent. You can check the official website for the most recent information.
In my setup, I use Arch Linux, and I have installed the texlive-full
package, which overkills the package size but includes everything I need. In Windows, I have used MikTeX, which is also a great distribution. However, I recommend using Overleaf for beginners since it comes with almost all the packages and benefits of easy collaboration.
Writing Your First Document
For the first document, we will create a simple document that contains some text and a mathematical equation. Create a new file called basic-latex-usage.tex
and add the following content:
|
|
In above code, we have created a simple document that contains a title, an author, and a date. We have also added a section that contains some text and a mathematical equation. I will not introduce you to how to compile your $\LaTeX$ code since if you are starting from very beginning, either you should stick with Overleaf or check the official documentation of the distribution you have installed – Probably, you can use pdflatex
command to compile your code –.
As you can see from above code, $\LaTeX$ uses a lot of commands that start with a backslash (\
). These commands are used to format the text and to include special characters, such as mathematical symbols and equations. The commands are easy to learn, and there are many resources available online that can help you get started with $\LaTeX$. For example, you can use the Overleaf documentation to learn more about how to use $\LaTeX$, which is a great documentation for beginners, and experts trying to refresh their memory.
What’s Next?
While writing your document, try to Google everything you might need. Because there WILL be commands doing the jobs you need, at least one part of it. $\LaTeX$ is a vast system, and it is impossible to memorize all the commands. However, you can always check the documentation or search online to find the commands you need.
There can be some issues while you are learning $\LaTeX$:
- You may encounter errors while compiling your code. This is normal, and it is part of the learning process. You can use the error messages to help you identify and fix the issues in your code.
- You may find that the output of your document does not look the way you expected. This can happen if you are not familiar with the formatting commands in $\LaTeX$. You can use the documentation to learn more about how to format your text and equations.
- You may have trouble finding the right commands to use in your document. This is where the documentation and online resources can help you. You can search for the commands you need and find examples of how to use them in your document. Google and ChatGPT are your friends!
Example: Lab Report Template for PHYS107&108 at METU.
I created a template for the lab reports of PHYS107&108 courses at METU. You can check the repository for more information. It is a great example beginner-level usage of $\LaTeX$.