Slice onions; a good pattern is cutting each onion in half, then cutting wedges such that the plane of each cut intersects at the center line of the onion (this makes each slice roughly the same length, whereas semicircles has a greater range of lengths)
Place onions in a shallow pot and add sugar and salt
Fill the pot with equal parts vinegar and water until the onions are barely submerged
Cook the onions on medium-high heat, i.e. so the solution gently boils, until the solution turns pink but the onions are still somewhat crisp
Allow the onion solution to cool
Place the spices in the bottom of the jar and pour the solution over top
Allow the onions to marinate for a day in the refrigerator before eating; keep the onions refrigerated