The gerund also has a compound form. It is formed with habiendo + participio pasado. This construction shows an action that happened before another action.
Pattern:
habiendo + past participle
Examples:
Habiendo terminado el trabajo, salió de la oficina.
Having finished the work, he left the office.
Habiendo leído el mensaje, entendí la situación.
Having read the message, I understood the situation.
Habiendo hablado con el profesor, decidimos cambiar el horario.
Having spoken with the teacher, we decided to change the schedule.
The compound form of the gerund is used less often than the simple form. In everyday spoken Spanish, people often choose a simpler construction with después de:
Después de terminar el trabajo, salió de la oficina.
After finishing the work, he left the office.
Después de leer el mensaje, entendí la situación.
After reading the message, I understood the situation.
Still, the compound form is useful to know. It appears in texts, articles, documents, literature, and more formal speech. It is especially useful for showing the order of actions: first someone did something, and then another action happened.