We've seen from the TOS movies that you can have more than one person of Captain rank serving aboard a starship. By the time of the TOS crew's assignment to the Enterprise-A at the end of TVH, you had Kirk, Spock, and Scotty all holding the rank of Captain even though only Kirk actually was in command of the ship. So why couldn't Riker have retained the rank of Captain but still been first officer?
That always annoyed me... that there could be a "Captain of Engineering." Very unrealistic!