nbconvert: Latex template refactor

[Work in progress]

Goals:
- Minimize future pull request for latex style changes
- Separate working parts of the templates
- Best effort to de-obfuscate the latex

Motivation:
#3989, #3866