Creating jazz-style repeats

In response to a request for jazz-style repeats, where there is a number in the middle of the bar which indicates how many bars to repeat, with a heavy horizontal bar on either side of the number, Robin Bannister provided this snippet.