QST: need to refactor pandas/io/formats/latex.py?
#### Refactoring

Recently ``pandas/io/formats/latex.py`` undertook some updates and extension of it functionality.
Adding more into it led to some code smell.

Recently there was a refactoring done by @SylvainLan, PR https://github.com/pandas-dev/pandas/pull/35649.
Even after that I see some improvements that can be done.
1. Split the process of writing the table into the beginning of the environment, the body and end of the environment.
2. Implement polymorphism to smoothly handle transition from regular table to longtable (currently there are multiple ifs here and there).

I made some changes in the local branch (not in sync with master because of the recent refactoring).
See https://github.com/ivanovmg/pandas/tree/refactor/latex-formatting for the preliminary solution.

Would you be interested in following this direction?
If so, then I would make it in sync with master and continue improvements.
