Select Page

How to write a simple “Hello World” in LaTeX


In this article, we will look at how to print a basic “Hello World” in latex. This is the traditional message most people learning a new language learn to display.


nanadwumor

June 01, 2023

Latex - simple hello word program using the latex document formatting software -villagecoder.com


  • The latex document is created using commands.
  • A latex command begins with a backslash.
  • In latex, when braces follow a command, the command demands compulsory argument. If not given, an error will occur when TeX compiles your code.


RECOMMENDED ARTICLES


Variables and Literals in Java

Variables and Literals in Java

Variables are used in many situations. For Instance, game applications use variables to collect your name when you sign in; to store and keep track of your number of trials, successes and failures. In Java, a variable is a container used to store...

The documentclass and its optional arguments

The documentclass and its optional arguments

Optional arguments in LaTeX are enclosed in square brackets. In our Hello World example, we passed the compulsory argument article to the \documentclass command. LaTeX has compulsory arguments which are enclosed in curly braces. LaTeX also allows...

double data type in Java

double data type in Java

The double data type is also a floating point number. It is called double because it has a double-precision decimal number.   The double data type is a floating point number. It is double precision data type The range is 4.9406564584124654 x...


In this article, we will look at how to print a basic “Hello World” in latex. This is the traditional message most people learning a new language learn to display. 

Let’s look at what a basic LaTeX “Hello World” program looks like and its parts.


Join Other Subscribers on Our YouTube Channel and Don’t Miss a thing!


Basic “Hello World” Program in LaTeX

Output

Hello World

Explanation of code

The latex document is created using commands. A latex command begins with a backslash. In the source code above, we have three latex commands.

\documentclass: The documentclass command is the first command in a latex document. It defines the type of class you use for creating your document.

A class defines the general structure of your latex document.  We have different classes such as article, exam, book etc. These individual classes define different structures. For example, if you want to write a book, you use the book class. If you are typing examination questions, the recommended class is the exam class.

In our example, we decided to write a simple article so we used the article class.

\documentclass{article}

The \documentclass command takes in an argument. In latex, when curly braces follow a command, the command demands compulsory argument. If not given, an error will occur when TeX compiles your code.

An argument is a value passed to the function when the function is called. In this case, article is the argument passed to the \documentclass command.

\begin{document}

\begin{document} : This statement begins the actual document. That’s , any command after this may be printed in your output. The \begin command takes a compulsory argument which is document. The command is given for the latex document to be created.

Hello World

Hello World : This is the statement displayed in the latex document. This is not a latex command. It’s normal text written to the latex document. This explains why it is not preceded by a backslash.

\end{document}

\end{document}: The \end{document} command ends the latex document. Beyond this command, any other latex command is unreachable and it will lead to an error. That is, LaTex will ignore any statement you type outside this command. The TeX compiler will throw an error and draw your attention to the fact that no statement can go beyond this delimiting command.


You May Also Like…




0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *