Germany's former foreign minister Frank-Walter Steinmeier is elected president, replacing Joachim Gauck as the largely ceremonial head of state.