a mandoline or food processor with a slicing attachment
Preheat the oven to 375 degrees F.
Peel the sweet potatoes, and then slice them into even rounds (1/8-to-1/4-inch thick). A mandoline or the slicing attachment on a food processor is the best way to do this.
Place the sliced sweet potatoes in a large mixing bowl. Add the garlic, salt and pepper. Toss well to coat.
Coat the inside of a 3-quart baking dish with the butter. Arrange an overlapping layer of sweet potatoes on the bottom of the dish in a clockwise pattern. Sprinkle around some of the Parmesan and Gruyere cheeses. Continue layering the gratin, going in a counter-clockwise direction (this will keep the gratin from falling over on your plate after it is cut). Again, add some of the cheese before adding the next layer. Continue alternating layers until the gratin is full.
Bring the half-and-half to a simmer on the stovetop and pour it over the potatoes. Cover the baking dish with aluminum foil and place a heatproof dish on top of the foil. Place in the oven to bake for 20 minutes.
Remove the foil from the baking dish and cover the top of the gratin with some extra grated cheese. Continue baking until the top is golden brown and bubbling, 20 to 30 minutes more. Remove from the oven and cool 20 minutes before serving.