Select Page

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.


nanadwumor

June 03, 2023

documentclass and optional arguments


  • LaTeX has compulsory arguments which are enclosed in curly braces.
  • LaTeX also allows optional arguments for its commands.
  • Optional arguments in LaTeX are enclosed in square brackets.

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...

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...

How to write a simple “Hello World” in LaTeX

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. The latex document is created using commands. A latex command begins with a...


LaTeX has compulsory arguments which are enclosed in curly braces. The \documentclass command takes a compulsory argument to determine the document structure of the LaTeX document.

That’s, whether it’s an article, book, exam, report, letter, or slides.


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


However, LaTeX also allows optional arguments for its commands. That’s, some LaTeX commands may or may not take some 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.

Besides the compulsory command, the \documentclass command takes optional commands to further determine customization of the document structure

documentclass[a4paper, 12pt, landscape, twocolumn]{article}

In the code above, article is a mandatory argument and that explains why it’s in curly braces. Without an argument in the curly braces, the TeX compiler will cry foul and an error will occur.

The argument we used in the code above is article because we want to prepare the document to write an article. Other standard classes you can use in your LaTeX document include report, book, letter, and slides.

It should be noted that you can define your own class and most people create their specified classes. Class files end with .cls extension.

Let’s look at the optional arguments of the document class.

a4paper : The default paper used by most LaTeX distributions is letter.  If you want your work to be built on A4 sheet, you have to tell LaTeX to use the A4 paper by passing the a4paper optional argument in the square brackets.

12pt : This means 12 points. This sets the font size of your characters to 12pt. LaTeX has three standard fonts. These are 10pt, 11pt and 12pt. By default, LaTeX uses 10pt. If you want something different, you have to add this optional argument in square brackets.

landscape : This sets the paper orientation to landscape. The default orientation is portrait.

twocolumn : This sets the paper to two columns. The default is a single column.

Note that the options are separated by comma but not whitespace.

Program demonstrates optional arguments of the documentclass

Output

documentclass and optional arguments code display

You May Also Like…




0 Comments

Submit a Comment

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