Heat the oven to 375°F with a rack in the middle position. Coat a 9-by-13-inch baking dish with 1 tablespoon butter.
In a 12-inch skillet over medium, cook the bacon, stirring occasionally, until crisp, about 5 minutes. Using a slotted spoon, transfer to a paper towel–lined plate, then pour off and discard all but 1 tablespoon bacon fat.
Return the pan to medium and add the remaining 2 tablespoons butter, followed by the onions and ¼ teaspoon each salt and pepper. Cover and cook, stirring occasionally, until the onions are softened and lightly golden, about 12 minutes. Off heat, stir in the garlic, followed by the broth and half of the cooked bacon.
While the onions cook, in a large bowl, stir together the rosemary, 1 teaspoon salt and ½ teaspoon pepper. Peel and slice the potatoes into rounds about 1/16 inch thick. Add the potatoes to the bowl and toss.
Distribute about a quarter of the potatoes in an even layer in the prepared baking dish, then evenly spoon on about a third of the onion mixture. Repeat the layering, dividing the remaining potatoes into thirds and the remaining onion mixture in half, for a total of 4 potato layers separated by 3 onion layers. Press down on the top to compress. Sprinkle with the remaining cooked bacon, cover tightly with foil and bake for 50 minutes.
Carefully remove the foil and bake until the surface of the gratin is browned and a skewer inserted into the potatoes meets no resistance, about another 40 minutes. Cool for about 10 minutes before serving.
