ENH: Added multicolumn/multirow support for latex
State: closed

- [x] closes #13508
- [X] tests added / passed
- [X] passes `git diff upstream/master | flake8 --diff`
- [X] whatsnew entry

Print names of MultiIndex columns.
Added "multicol" and "multirow" flags to to_latex
which trigger the corresponding feature.
Multirow adds clines to visually separate sections.


Labels:
name: Enhancement
name: IO LaTeX
description: to_latex

Comments:
You'll need to rebase your branch on master. Just post here if you need help with the git commands.

Oh my, what a mess...
I did `git rebase upstream/master` as in the documentation, which seemed to work correctly.
Before pushing, though, git performed an automatic merge of my local and remote branch.
Any way to clean this up? Thanks for helping!

You'll want to start by

```
git fetch upstream
git rebase -i upstream/master
```

This will start applying changes, but you'll have some merge conflicts. You'll need to edit the files (see `git status` for "Unmerged Paths") and look for the conflict markers git auto inserts (`<<<<<<<`, `========` and `>>>>>>>`). Fixup those files to look like how the should (make sure to remove the markers too), and the files you just edited, and then

```
git rebase --continue
```

Side-issue, typically you'll develop on a feature branch, no master. So before you make any changes you would `git checkout -b <branch-name>`. Not a big deal now though.

We can also jump into the [chat room](https://gitter.im/pydata/pandas) if that's easier.

# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/14184?src=pr&el=h1) Report
> Merging [#14184](https://codecov.io/gh/pandas-dev/pandas/pull/14184?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/211ecd5d829e6ff9019261680f1d4e6f1b193a13?src=pr&el=desc) will **decrease** coverage by `-0.02%`.
> The diff coverage is `98.55%`.


```diff
@@            Coverage Diff             @@
##           master   #14184      +/-   ##
==========================================
- Coverage   91.04%   91.03%   -0.02%     
==========================================
  Files         136      136              
  Lines       49088    49152      +64     
==========================================
+ Hits        44694    44744      +50     
- Misses       4394     4408      +14
```


| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/14184?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/config_init.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvY29uZmlnX2luaXQucHk=) | `95.27% <100%> (+0.23%)` | :white_check_mark: |
| [pandas/core/frame.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZnJhbWUucHk=) | `97.83% <100%> (-0.1%)` | :x: |
| [pandas/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL2Zvcm1hdHMvZm9ybWF0LnB5) | `95.4% <98.24%> (+0.09%)` | :white_check_mark: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `25% <0%> (-58.34%)` | :x: |
| [pandas/tools/merge.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL3Rvb2xzL21lcmdlLnB5) | `91.78% <0%> (-0.35%)` | :x: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...d2ae82d11165e0b2926cb722a2a992957464389b?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `81.87% <0%> (-0.19%)` | :x: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/14184?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/14184?src=pr&el=footer). Last update [211ecd5...ce0a0c9](https://codecov.io/gh/pandas-dev/pandas/compare/211ecd5d829e6ff9019261680f1d4e6f1b193a13...ce0a0c92f0b90d5544483028a9e0dafdd560a48f?el=footer&src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
Thanks, i've incorporated your renaming suggestions.
Also added an additional `multicolumn_format` parameter where one can specify the alignment similar to the existing column_format.
Unfortunately, I don't really see how one could separate the different parts of this routine without rewriting it from scratch, even before the routine was basically "take the result of `_to_str_columns` and completely change it".

lgtm. @jorisvandenbossche @TomAugspurger 
(conflict in the whatsnew), but can fix on merge if all other good.


status of this?
Is there anything I should still improve?
Thanks for the feedback, i hope the changes go in the direction you intended.

The test that failed previously was caused by the to_latex_multiindex test expecting no multicolumns, obviously. This has been fixed.
I don't know what causes the new failures, looks more like a technical issue to me, locally it just fails by trying to load pyqt4 and 5 simultaneously, everything i've touched works as inteded ;)
> I don't know what causes the new failures, looks more like a technical issue to me,

Yes, there are currently some issues with travis, nothing to do with this PR.
@hein09 Thanks a lot! 
(the travis failure was a pep8 issue, fixed that before merging)