How to write in LaTeX
Have you finally come to the end of a long course of study and you just have to finalize it with the drafting of your thesis? Or maybe you’ve been commissioned to write a report or essay on an experiment and need to write math formulas and bibliography clearly and neatly. In that case, your own professor may have specifically suggested that you write everything using the LaTeX markup language: but how to write in LaTeX?
Don’t worry: it is a completely legitimate and understandable question, since this writing system is certainly less common than the “visual” ones we are used to in programs like Word. Nevertheless, it is a widely used system for writing textbooks, articles and theses, especially scientific ones, precisely for the advantage of being able to report mathematical formulas with dedicated tools.
As I will explain in this guide, writing in LaTeX allows you to worry less about formatting and to focus more on the text to be written. Furthermore, the texts can be immediately processed in PDF format. Later I will tell you about the basic functions of the system and which are the best computer programs, as well as some excellent applications for smartphones and tablets, which allow you to make texts with this system. Ready to get started? Well then I wish you good reading and good work!
Index
- What is LaTeX and basic formatting
- Applications for writing in LaTeX
- MikTeX (Windows / macOS / Linux)
- Other applications for writing in LaTeX
- App for writing in latex on smartphones and tablets
- How to write in LaTeX on Word
What is LaTeX and basic formatting
First of all I would say to clarify what is meant by the word LaTeX and above all, what it is exactly. Well, LaTeX is a markup language (or marking ) created for the preparation of documents, unlike those made with programs such as Microsoft Word or LibreOffice Writer, uses only plain text (or plain text ), or in simple bytes.
Unlike the most popular text programs that use the “What You See is What You Get” system, which reproduce the text on the screen as it would appear once printed, the LaTeX system shows only simple alphanumeric characters and basic symbols without any representation. graphics.
To write in LaTeX, therefore, textual codes are used which represent rules for formatting the text according to specific language conventions . By affixing these markers, the rules for formatting the text are established, so once sent to print or displayed outside the editor, in a special program capable of “translating” the formatting, the text will be perfectly readable and formatted with all the formulas and other elements displayed in a clear and readable format for all.
If the most common writing programs can represent the most practical and direct solution for drafting documents, the LaTeX system is often appreciated and preferred for writing, for example, theses or documents containing mathematical formulas. This is because it is a language that allows precise and uniform formatting of such contents (without risking gross errors or in any case “bad” results to see).
If this is your first experience with LaTeX writing, before moving on to talk of the programs to use want to dwell on formatting functions base.Per example, it is crucial to place these markers at the beginning of each of your document.
\documentclass[a4paper,12pt]{article}
\begin{document}
testo del documento
\end{document}
The first of these is used to set the page format (A4) and the size of the characters, while the part inside the brace indicates the type of article: in this case article (also suitable for writing a thesis), but you can also set book and report as type.
The markers \begin{document}
and \end{document}
delimit the content of the main body of the text, so it is essential that you write your text between these two markers.
Again to give structure to your text, the marker is certainly useful \section{titolo capitolo}
as it is used to create a new chapter in the text, in the same way it \subsection{titolo paragrafo}
adds a paragraph, or even \subsubsection
a sub-paragraph. So, as an example, the following code.
\section{Metodo d’indagine}
\subsection{Metodi principali}
\subsubection{Descrizione dei metodi principali}
Generates the chapter “Survey method”, followed by the paragraph “Main methods” and finally the paragraph “Description of the main methods”. The marker \paragraph
and that are used in the same way \subparagraph
. While in the type of book document and report you can also use markers \chapter{Primo capitolo}
.
Thanks to the marker \pagenumbering{stile di numerazione}
you can set the page numbering in Arabic or Roman numerals, respectively as follows: \pagenumbering{arabic}
and \pagenumbering{roman}
.
Finally, if you want to insert an index, you can use this marker \tableofcontenents
which will produce an index of the chapters, paragraphs, sub-chapters and sub-paragraphs that you have inserted in the document at the point where you find it.
But what are the tags to use, for example, to make bold? If you are wondering how to write in bold LaTeX, the marker is \textbf{testo in grassetto}
, then to use this way \textbf{Salvatore Aranzulla}
to write my name in bold in LaTeX.The same type of usage applies to how to write LaTeX in italics but using the marker \textit{testo in corsivo}
for example in this way \textit{lorem ipsum}
. The use of the marker for underlined text does not differ, that is \underline{testo sottolineato}
, to use for example like this \ underline {nota bene} to underline the words “nota bene”.
A considerable advantage of the LaTeX writing system, however, is the possibility to insert formulas in the text, how to write equations in LaTeX, or how to write matrices in LaTeX.
To do this, you need to use the math mode. Its activation is very simple: just insert the $ symbol followed by the formula in the text. For example it $ 2 + 2 = 4*$
will be composed by the LaTeX system with the equation format.
Doubling the $ symbols at the beginning and end of the equation will move the formula to the center, making it stand out from the body of the text. If you want to insert more equations you can use the sequence of equations function : \begin{eqnarray}
[insert equations here] \end{eqnarray}
.
These commands are obviously the simplest ones, for a basic use of LaTeX, because especially for mathematical functions there are a great variety of methods. If you want to learn more about LaTeX and mathematics, my suggestion is to consult the Wikibook LaTeX Mathematics page, as it is a complete source of practical examples on how to write functions in LaTeX and a lot of other information about this language.
Applications for writing in LaTeX
Now that you know what the basic commands are, it’s time to recommend some of the best programs for writing in LaTeX, in order to prepare you for how to write theses in LaTeX or in any case to create any document you need to prepare using this language.
MikTeX (Windows / macOS / Linux)
To start writing in LaTeX, one of the programs that I most recommend is MiKTeX. Among its advantages there is certainly the compatibility with Windows, macOS and Linux operating systems, moreover this program has been optimized for a practical and direct use of the LaTeX system to the user.
MiKTeX is a modern TeX distribution able to manage the installation of the components necessary for the functioning of the writing system without necessarily installing unnecessary components compared to the use made by the user.
To download MiKTeX connect to the download page of the project and click on the logo of the operating system for which you want to download the program and, subsequently, on the Download button.
When the download is complete, to proceed with the installation of the Windows version, double-click on the executable file you just downloaded, check the I accept the MiKTeX copying conditions box, then click on the Next button and do it again for the next three times, then press the button Start.
At the end of the process, click on the Next button two more consecutive times and to conclude, remove the check from the Tell me more box and click the Close button. After this step, you can move on to using the program.
If you are using a Mac, on the other hand, open the .dmg package obtained, click on the Agree button and copy the MiKTeX icon in the MacOS Applications folder, then start the software and answer affirmatively to the warning that appears.
So now, what to do to start writing a document in LaTeX? Well, in the MikTeX console a simple and practical editor is included, oriented to the creation of PDF documents with LaTeX system. It’s called TeXworks and you can start it from the console by clicking on a picture of a letter T.
As you can see for yourself, the TeXworks screen is quite elementary as it is characterized by a menu bar and one of the commands at the top, an empty area in the center where the documents are shown and finally a status bar at the bottom that informs the type of formatting, the text encoding and the position of the cursor (line and column) in the text.
In short, whenever you want to start creating a new text in LaTeX, click on the New button (whose icon is a blank white page with a yellow dot at the top right). Then start writing the text following the LaTeX rules and when you are done, click on the green arrow at the top left, or the Composition key, to start processing the document and export it also in PDF format.
I suggest you create a folder for each document in LaTeX, this is because multiple files are created for each one by the program. This is all for the basic operation of TeXworks, you just have to deepen the language in markup and other peculiarities of the LaTeX system to get familiar with its use and create all the documents you want.
If, on the other hand, you would like to discover other programs, or a way to use this writing system on smartphones and tablets, I invite you to continue reading the next chapters.
Other applications for writing in LaTeX
If the program mentioned above did not fully convince you, you could try other solutions to write in LaTeX. In general, I still recommend installing the MikTeX console as it is very useful for semi-automatic management of components and updates useful for writing in LaTeX. That said, here are some other good programs for producing text in LaTeX.
- TeXstudio (Windows / macOS / Linux) – a program for writing and creating documents in LaTeX born with the aim of making this writing system accessible and simple. To put this goal into practice, TeXstudio integrates tools such as syntax highlighting (for example by assigning specific colors to functions scattered throughout the text), text auto-completion, an integrated viewer, a text control system and some virtual assistants to the writing.
- LyX (Windows / macOS / Linux) – a program particularly appreciated for the attention placed on the interface, designed to remember the classic text editors such as Word, but also for the optimization of useful tools for mathematical formulas. LyX also includes advanced markers for writing texts such as theses, for example thanks to the appropriate bibliography tool.
- Texmaker (Windows / macOS / Linux) – a valid software for writing in LaTeX, it is no coincidence that it has also become one of the most popular. Its strong points include the very intuitive basic configuration page, as well as the integrated grammar check system. Furthermore, thanks to the “Structure View” tool, it allows quick access to the various contents included in the document, divided by category.
App for writing in latex on smartphones and tablets
Maybe you didn’t know it yet, but writing with the LaTeX system from smartphones and tablets is possible. There are some apps that allow you to write with this system and although they are not many, there are really complete ones and with little or nothing to envy to the programs that can be installed on computers. Here are which I recommend.
- VerbTeX ( Android / iOS / iPadOS ) – a truly comprehensive LaTeX writing app full of features and tools. In addition to the editing and creation of documents, it also integrates tools for viewing, editing and managing other already created ones. Among the most appreciable tools there is the PDF file creator (PdfTeX or XeTeX), automatic synchronization with DropBox account and the presence of two modes: Local mode and Cloud mode. While the first allows you to work disconnected from the web and save everything on your device, the other takes advantage of the cloud technology of various services to also allow multiple users to collaborate on the same documents at the same time (like Google Drive or Microsoft 365 for be clear).
- texpad ( iOS / iPadOS ) – a reference tool for creating text in LaTeX directly from Apple-branded devices. The app includes a checking tool that highlights the syntax, an error reporting system geared even to less experienced users and a tool to render the file to PDF in real time (during the drafting itself).
- Overleaf ( Web ) – this last tool I tell you about is actually a service that is easily accessible from any web browser. It is therefore a cloud service accessible from any place and device (including smartphones and tablets), complete with every function for editing in LaTeX, including a collaboration tool and a text preview tool in real time. To access the service you need to register, and then choose the type of subscription. The free plan is also available, while the paid ones range from 9 euros/month for the Personal profile to 28 euros / month for the Professional one. More details here.
These are the most useful apps and services when it comes to writing LaTeX text from smartphones and tablets. In general, I recommend that you practice as much as possible with this system before deciding whether to use it or not. It is usually just a matter of getting used to and taking the time to practice.
How to write in LaTeX on Word
Although the solution of writing in LaTeX on Word is not possible (and practical), there is the possibility of combining the use of the Microsoft text editor with the LaTeX system and inserting mathematical formulas. As I imagine you already know, Word is one of the most traditional tools to write a thesis, but how to insert mathematical formulas in LaTeX?
The requirement is that you have subscribed to Microsoft 365, otherwise unfortunately there is currently no integrated function with other versions of Word.
From the main Microsoft 365 screen, click on the Insert tab, then click on the Equations item and then on the Insert new equation item, then click on the LaTeX button, right next to the Unicode one. Alternatively you can press the key combination Alt + Shift + [+] + [=] .
By doing so, a text box is placed in the body of the text, just where you had positioned the cursor, where you can write your formula in LaTeX, exactly as I explained to you in the chapter above. For convenience, I report the main supported commands in the following image.
For example, if you write the following code \{\matrix{a&b&c\\d&e&f\\g&h&j}\}
, a 3 × 3 matrix is inserted in the body of the text. Remember, however, that \begin{}
and markers \end{}
are not supported in Word, so you don’t need to use them.
Finally, I remind you that Microsoft Word allows you to enter formulas even without resorting to the LaTeX system. So, if just this way of writing is not for you, I suggest you read my guide on how to write math formulas in Word. Well, I just have to wish you good work!