BUG: Fix to_latex with longtable (#17959)
- [x] closes #17959
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry

pandas.DataFrame.to_latex(longtable=True) always contained `\multicolumn{3}{r}{{Continued on next page}}` regardless of the number of columns in the output. This is now changed to use the actual number of columns in the output.