Main categories on product listing

To show main categories before product listing please go to Product Settings and find the Product listing shows settng.

Product Listing with categories setting

You can select Product or Products & Main Categories. When you select the second option the product listing will contain also the main categories at the beginning.

The categories listing template will be the same as the one selected for products.