Breakdown of Gestern hatte ich schon Kopfschmerzen, bevor die Klassenarbeit begann.
Questions & Answers about Gestern hatte ich schon Kopfschmerzen, bevor die Klassenarbeit begann.
Both are correct. German has flexible word order for elements like time, manner, and place.
Gestern hatte ich schon Kopfschmerzen, …
– Emphasis is a bit more on “yesterday” as the time frame.Ich hatte gestern schon Kopfschmerzen, …
– Emphasis is a bit more on “I had” (the state of me having a headache), with gestern just giving extra information.
In both cases, German keeps the verb in second position in the main clause:
- Gestern (1st position) – hatte (2nd position) – ich …
- Ich (1st position) – hatte (2nd position) – gestern …
So the choice is mostly about style and emphasis, not grammar correctness.