Class can have max 2 gaps per day
The software doesn't create gaps for classes and students by default, but calculates the average number of lessons per day and then it places them consecutively. This is ensured by so-called "Educational block". See this article for more information: Education block - Checking of gaps in class timetables
However if you need to have gaps in classes timetables, but you wish to minimize them to max 2 free periods in a day, you can do so in this way:
1. At first allow gaps in classes timetables with "discontinuous educational block". See: Education block - How to allow gaps in class timetables
OR
set, that some subjects can be in the afternoon. See: How can I define lessons that can be outside teaching block(in the afternoon)?
2. Now you can add use card-relationship "Max gaps per day" to minimize the created gaps:
Notes:
- this topic is for longer gaps, if you just need one lesson free for lunch you can do this directly:
How to specify when a class can have a lunch?
- the same card-relationship can be setup for individual students:
Student can have max 3 gaps per day
See also: 
French and Spanish language lessons can be in one day, but with a gap at least 2 periods
Two subjects must follow each other
 
                 English
								English							 Slovenčina
								Slovenčina							 Deutsch
								Deutsch							 España
								España							 Francais
								Francais							 Polish
								Polish							 Russian
								Russian							 Čeština
								Čeština							 Greek
								Greek							 Lithuania
								Lithuania							 Romanian
								Romanian							 Arabic
								Arabic							 Português
								Português							 Indonesian
								Indonesian							 Serbia
								Serbia							 Farsi
								Farsi							 Hebrew
								Hebrew							 Mongolian
								Mongolian							 Bulgarian
								Bulgarian							 Georgia
								Georgia							 Azerbaijani
								Azerbaijani							 Thai
								Thai							 Turkish
								Turkish							 Magyar
								Magyar