This rustic tart makes a good first course when served with a salad; it's also a perfect accompaniment to roasted meats or chicken.
Melt butter in a 10-inch nonstick skillet with an ovenproof handle; sprinkle with sugar, and remove from heat.
Cut 6 of the onions in half crosswise, and fit them snugly into the pan, cut sides down. (Cut more onions if necessary to cover pan.) Cut leeks into lengths about the same height as the onion halves, and fit them into spaces near center of the pan. Sprinkle with half the thyme leaves; add salt and pepper to taste.
Slice remaining onions 1/4 inch thick, and arrange over onion halves. Sprinkle with remaining thyme; season with salt and pepper.
Cook over medium-high heat for 5 minutes. Reduce heat to medium, and continue cooking for another 5 minutes, or until onions are a deep golden brown on the cut side. Shake pan gently from time to time and rotate its position on the burner to ensure even browning.
Pour stock and vinegar over onions; bring to a simmer, cover, and cook over low heat for 25 minutes, or until onions are very tender. Remove lid, raise heat, and cook until liquid is syrupy and almost completely reduced. Remove from heat; let cool slightly.
Heat oven to 375 degrees. On a lightly floured surface, roll out pastry 3/8 inch thick to a diameter slightly larger than pan. Wrap dough around rolling pin; unroll over pan. Tuck in excess.
Place pan in oven, and bake until pastry is golden brown and juices are bubbling, 30 to 35 minutes. Let cool in pan for 10 minutes, then invert onto a serving plate. Serve warm, garnished with fresh thyme.