A strong earthquake shook much of Taiwan on Sunday, toppling a three-story building and stranding about 400 tourists on a mountainside.