Sauté onions until golden: Heat 1 Tbsp of olive oil on medium high heat in a thick-bottomed sauté pan. Add the sliced onions, stir to coat with the olive oil, and cook until golden brown, about 15 to 20 minutes.
Preheat oven to 400°F (205°C).
Toss sliced potatoes with olive oil, cheeses, salt, pepper: In a large bowl put the sliced potatoes and gently toss with 1 Tbsp of olive oil, 1/2 cup grated Gruyere cheese, 1/2 cup of grated Parmesan, salt, and white pepper.
(If you are making ahead, make sure that the potatoes are well coated with the olive oil, even if you have to add more olive oil. This will help prevent them from turning grey.)
Layer onions in buttered dish, arrange potatoes on top, pour stock over, sprinkle with more cheese: Butter a large gratin dish or 9×13 casserole lightly and line with the caramelized onions in an even layer at the bottom of the dish.
Arrange the sliced potatoes (including the grated cheeses) in a pattern over the onions. Pour stock over the potatoes. Sprinkle with remaining cheese.
Cover with foil and bake, then broil to finish: Cover with aluminum foil and bake at 400°F (205°C) for 50 minutes (or until fork tender). Remove aluminum foil. Broil for 5 minutes, uncovered, until lightly browned. Sprinkle with minced rosemary to serve.