# Section text appears misaligned

I am a beginner in LaTex and I have written the following code:

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}

\begin{document}
\selectlanguage{english}

\title{Physics assignment}
\author{me}
\date{\today}
\maketitle

\section*{Excercise 1}
\selectlanguage{greek}
$m = 5kg$

$t = 0sec$: $\vec{υ} = 2m/s$

$t' = 2sec$: $\vec{υ} = 12m/s$

$\mu = 0,2$

$\vec{g} = 10m/s^2$

\end{document}



This is the output of the code. How can I make it so that the first line of the section, "m = 5kg" aligns with the rest of the lines?

Any help is greatly appreciated.

• You are making new paragraphs, paragraphs are indented by default. You should probably put this into a math construction like align. Also: look up the siunitx package for formatting units, you're doing it wrong here (there are actually rules as to how unites should be formatted and siunitx makes this super easy) Mar 20 '20 at 16:27

Hi @PuperHacker and welcome to TeX-SE.

As you are a beginner let's go step by step.

Standards

There are many standards around the world. LaTeX's standard depends of the class and normally they are related to common standards in USA. I'm from Brazil and the common standard here (the one taught in elementary schools) is all paragraphs are indented.

So, first basic command \usepackage{indentfirst}

This is a MWE (Minimum Working Example). OBS: \usepackage{lipsum} generates dummy text.

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{indentfirst} %(un)comment this line to test
\usepackage{lipsum}
\begin{document}
\section{title}
\lipsum[1]

\lipsum[2]
\end{document}


With \usepackage{indentfirst}

Without \usepackage{indentfirst}

Equations and Units

There are many methods to input math into LaTeX.

I must be honest here, I learned about siunitx only after I started my own set of units commands, so there might be some better methods to use the package siunitx.

A not so minimal WE follows

\documentclass{article}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{siunitx}
\begin{document}
\section{title}
Text $m = 5 kg$ does not result in the same as $m = 5$ kg.

With a blank line (not recommended)

$$m = 5 kg$$

Without a blank line (recommended)
$$m = 5 kg$$

Let's test some text commands in math mode.

Using align
\begin{align}
m & = 5 kg                \\
m & = 5 \operatorname{kg} \\
m & = 5 \text{kg}         \\
m & = 5 \textrm{kg}       \\
m & = 5 \mathrm{kg}
\end{align}

Using split
$$\begin{split} m & = 5 kg \\ m & = 5 \operatorname{kg} \\ m & = 5 \text{kg} \\ m & = 5 \textrm{kg} \\ m & = 5 \mathrm{kg} \end{split}$$

Align and split don't interfere with spacing, but they label equations differently.

\clearpage
And now some siunitx commands and spacing
\begin{align}
m & = 5 \si{\kilogram}        \\
m & = 5 \ \si{\kilogram}      \\
m & = 5 \, \si{\kilogram}     \\
m & = 5 \; \si{\kilogram}     \\
m & = 5 \quad \si{\kilogram}  \\
m & = 5 \qquad \si{\kilogram}
\end{align}

And now some siunitx commands to better spacing comparing the ones without it.
\begin{align}
m       & = 5\si{\kilogram}            \\
m       & = \SI{5}{\kilogram}          \\
\vec{u} & = 12 \si{m/s}                \\
\vec{u} & = \SI{12}{m/s}               \\
\vec{u} & = \SI{12}{m \per s}          \\
\vec{u} & = \SI{12}{\metre\per\second}
\end{align}

\end{document}


and the results are

In my point of view, siunitx has the most options and is a well maintained package. If you do not want to use it, the second best approach would be \operatorname{} due the better handling of spacing.

With align* and siunitx:

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\begin{document}
\selectlanguage{english}

\section*{Excercise 1}
\selectlanguage{greek}

\begin{align*}
m &= \SI{5}{\kg}\\
t &= \SI{0}{\s}: \vec{υ} = \SI{2}{\m\per\s}\\
t' &= \SI{2}{\s}: \vec{υ} = \SI{12}{\m\per\s} \\
\mu &= 0,2\\
\vec{g} &= \SI{10}{\m\per\s\squared}
\end{align*}
\end{document}


Generally, you will want to align to the = sign, as was shown by leandris. Occasionally, however, you may wish to align to both the left side of the variables AND the = sign.

\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage[english, french, greek]{babel}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\selectlanguage{english}

\section*{Exercise 1}
\selectlanguage{greek}
\TABbinary \setstackaligngap{0pt} \setstackgap{L}{1.2\baselineskip} \alignCenterstack{ &m&=& \SI{5}{\kg}\\ &t&=& \SI{0}{\s}: \vec{υ} = \SI{2}{\m\per\s}\\ &t'&=& \SI{2}{\s}: \vec{υ} = \SI{12}{\m\per\s} \\ &\mu&=& 0,2\\ &\vec{g}&=& \SI{10}{\m\per\s\squared} }
\end{document}