Heat the oven to 190 degrees Celsius (375 degrees Fahrenheit) and generously butter a 9 by 13 inch baking dish.
Slice the potatoes evenly to about 3 millimeters thick, using a sharp knife or a mandoline, and pat the slices dry.
Melt the butter in a medium saucepan over medium heat, add the garlic, and cook for 30 seconds until fragrant.
Stir in the flour and cook for 1 minute, stirring constantly, to form a pale roux.
Gradually whisk in the milk and cream, then simmer gently, stirring often, until the sauce thickens enough to coat a spoon.
Season the sauce with salt, pepper, and nutmeg, then stir in 1.5 cups of the cheddar until melted and smooth.
Layer one third of the potato slices in the dish, slightly overlapping, and season lightly; top with some onion slices and sauce. Repeat the layers twice more.
Pour any remaining sauce over the top, sprinkle with the remaining cheddar and the Parmesan, and cover the dish tightly with foil.
Bake covered for 45 minutes, then uncover and bake for 25 to 35 minutes more, until the top is golden and a knife slides easily through the center.
Rest the dish for 15 minutes before serving so the sauce thickens and the layers set.