LaTeX/C3/Decimal-Point-Alignment/English

From Script | Spoken-Tutorial
Jump to: navigation, search

Title of the Script: Decimal point alignment.

Author: Ambika Vanchinathan, Ketki Bhamble

Keywords: latex, Siunitx, decimal alignment,table formatting, video tutorial.


Visual Cue Narration
Slide 1

Title Slide

Welcome to this Spoken tutorial on Decimal Point Alignment.
Slide 2

Learning Objectives

In this tutorial we will learn to,
  • Define the SIunitx package
  • Understand the code.
  • Use capital S to show decimal point alignment.
  • Run the LaTeX code to see the output.
Slide 3

System Requirements

To record this tutorial, I am using:
  • Ubuntu Linux OS version 22.04 and
  • Texworks version 0.6.6
Slide 4

Pre-requisites

To follow this tutorial,

Learners should have basic knowledge of LaTeX.

Slide 5

Code Files

The following code file is required to practice this tutorial:

1. SIunitx-eg1.tex

This file is provided in the Code Files link of this tutorial page.

The following code file is required to practice this tutorial.

This file is provided in the Code Files link of this tutorial page.

Slide 6

What is Siunitx?

What is Siunitx?

The siunitx package formats,

  • numbers, units, and aligns decimals in tables.
Now let us begin.
\usepackage{siunitx} \usepackage{siunitx} Imports the siunitx package.

It enables decimal alignment using the capital S column type in tables.

\begin{table} This command makes a table and places it automatically in the best position.
\caption{Standard behaviour of the \texttt{S} column type.\label{tab:S:standard}}

\label{tab:S:standard}}

\ref{tab:S:standard}

This command adds a Caption for the table.

This label acts as an identifier.

It can be referenced elsewhere in the document using the ref command.

\begin{center} This command centers the table on the page.
\begin{tabular}{...}

({l@{}S@{}r}):

This command starts a tabular column.

In this command,

  • l denotes left-aligned columns for serial numbers.
  • S denotes a decimal-aligned column for numerical values.
  • r denotes a right-aligned column for the variables.
%\begin{tabular}{l@{}s@{}r} The commented line shows that s in lowercase and it does not work in siunitx.
\hline

Highlight all three horizontal lines.

point the cursor to all three horizontal lines.

There are three horizontal lines to separate the rows in the table.
No. & {Some Values} & Var.\\ This command creates a table with three columns: Number, some Values and var .
Highlight:

1 & 1 & 1000\\

Highlight all the lines:

1 & 1.0 & 1000\\

2 & 34.2345 & 100 \\

3 & -555.12 \\

In these lines of code, the second column is decimal aligned.

The decimal alignment happens due to the siunitx package.

Highlight line 10 and 6

\begin{tabular}{l@{}s@{}r} %% lower case s does not work

Let us comment line number 10, and uncomment line number 11.

Let’s run the code.

Click the green Typeset button to run the code.

We get an error.

Using lowercase ‘s’ in tabular is a syntax error as LaTeX doesn't recognize it.

Comment line number 11 and uncomment line number 10.

Show the output.

Again comment line number 11 and uncomment line number 10.

Let’s run the code to see the proper output.

We have resolved the error.

Slide 7

Summary

In this tutorial, we have learnt to

  • Define the SIunitx package
  • Understand the code
  • Use capital S to show decimal point alignment.
  • Run the LaTeX code to see the output.
With this we come to the end of this tutorial. Let us summarise.
Slide 8

Assignment

As an Assignment

Add 2 more rows of data to the table and see the difference in the output.

Slide 9

Thank you

Thank you for joining

Contributors and Content Editors

Ketkinaina, Madhurig