Al (masculine/neuter singular), a (feminine singular), ai (masculine plural), and ale (feminine/neuter plural) are used if the genitive doesn't come immediately after a noun with a definite article. Al, a, ai or ale agree in gender and number with the term they refer to.
Capitala Braziliei este Brasilia (The capital of Brazil is Brasilia). - Capitala has a definite article and is immediately before Braziliei, in the genitive case.
Vechea capitală a Braziliei este Rio de Janeiro (The old capital of Brazil is Brasilia). - Capitală, the term immediately before Braziliei, in the genitive case, doesn't have a definite article. The article is in the adjective vechea.
Cărțile profesorului sunt pe masă (The books of the teacher/The teacher's books are on the table). - Cărțile, the term immediately before profesorului, in the genitive case, has a definite article.
Cărțile de matematică ale profesorului sunt pe masă (The math books of the teacher/The teacher's math books are on the table). -Cărțile, with a definite article, is not immediately before profesorului, in the genitive case, is separated by the phrase de matematică.
It is also important to remember that even though the genitive and the dative look alike in Romanian, the dative never uses al (and variations).
Îi dau cartea profesorului de matematică profesorului de fizică (I give/am giving the book of the math teacher/the math teacher's book to the physics teacher). No al (and variations) before profesorului de fizica, as this is the dative, the person you are giving the book to.
Îi dau cartea veche a profesorului de matematică profesorului de fizică (I give/am giving the old book of the math teacher/the math teacher's old book to the physics teacher). See above why there is an a after veche.
Muncitorii sunt împotriva reformelor și a reducerilor de salariu (The workers are against the reforms and salary reductions/cuts). - The preposition împotriva requires the genitive, that is why there is an a before reducerilor, which is not immediately after the preposition.
Datorită reformelor și măririlor de salariu oamenii sunt mai fericiți (Thanks to the reforms and pay raises people are happier). - The preposition datorită requires the dative, that is why there is no a before măririlor, even though it is not immediately after the preposition.