01
Position a rack in the center of the oven and preheat to 400 degrees F. Butter a 2-quart glass or ceramic baking dish.
02Heat the oil in a heavy large skillet over medium-high heat. Add the onions and cook until tender and golden, about 10 minutes. Add the garlic and stir 1 minute. Add the cream, broth, rosemary, salt and pepper. Remove the pan from the heat.03Mix all the grated cheeses together in a medium bowl.04Mix the yams and potatoes together in a medium bowl.05Arrange one-third of the potato mixture in the bottom of the prepared baking dish. Sprinkle with one-third of the cheese mixture. Repeat the layers twice more ending with a layer of the cheese mixture. Pour the cream mixture over the layers and cover the pan with foil.06Bake the gratin until the potatoes are almost tender, about 45 minutes. Remove the foil and continue to bake until the potatoes are tender and golden on top, 20 to 25 minutes longer. Remove from the oven and let the gratin rest, 10 minutes. Sprinkle with the chopped parsley, if using, and serve.