ENH: added optional caption and label arguments to DataFrame.to_latex()
State: closed

- [x] closes #25436 
- [x] tests added / passed
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [x] whatsnew entry


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

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=h1) Report
> Merging [#25437](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/85572de5e7bb188cfecc575ee56786406e79dc79?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `94.11%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25437/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25437      +/-   ##
==========================================
+ Coverage   91.74%   91.75%   +<.01%     
==========================================
  Files         173      173              
  Lines       52923    52950      +27     
==========================================
+ Hits        48554    48582      +28     
+ Misses       4369     4368       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.31% <94.11%> (ø)` | :arrow_up: |
| #single | `41.7% <2.94%> (-0.03%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.99% <100%> (ø)` | :arrow_up: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `94.16% <33.33%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `87.66% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25437?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/25437?src=pr&el=footer). Last update [85572de...2ce8c67](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

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

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25437/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #25437      +/-   ##
==========================================
- Coverage   92.04%   91.97%   -0.07%     
==========================================
  Files         180      175       -5     
  Lines       50714    52409    +1695     
==========================================
+ Hits        46679    48204    +1525     
- Misses       4035     4205     +170
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.53% <100%> (-0.15%)` | :arrow_down: |
| #single | `40.68% <0%> (-1.28%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/formats/format.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvZm9ybWF0LnB5) | `97.91% <100%> (ø)` | :arrow_up: |
| [pandas/core/generic.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ2VuZXJpYy5weQ==) | `93.54% <100%> (-0.67%)` | :arrow_down: |
| [pandas/io/formats/latex.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2Zvcm1hdHMvbGF0ZXgucHk=) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/plotting/\_misc.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL3Bsb3R0aW5nL19taXNjLnB5) | `38.46% <0%> (-26.41%)` | :arrow_down: |
| [pandas/io/gbq.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2dicS5weQ==) | `78.94% <0%> (-21.06%)` | :arrow_down: |
| [pandas/io/gcs.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2djcy5weQ==) | `80% <0%> (-20%)` | :arrow_down: |
| [pandas/io/clipboard/clipboards.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9jbGlwYm9hcmRzLnB5) | `18.98% <0%> (-15.8%)` | :arrow_down: |
| [pandas/io/clipboard/\_\_init\_\_.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NsaXBib2FyZC9fX2luaXRfXy5weQ==) | `39.21% <0%> (-15.14%)` | :arrow_down: |
| [pandas/io/s3.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3MzLnB5) | `89.47% <0%> (-10.53%)` | :arrow_down: |
| [pandas/core/groupby/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS9iYXNlLnB5) | `91.83% <0%> (-8.17%)` | :arrow_down: |
| ... and [124 more](https://codecov.io/gh/pandas-dev/pandas/pull/25437/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25437?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/25437?src=pr&el=footer). Last update [edf5ae8...3eb433b](https://codecov.io/gh/pandas-dev/pandas/pull/25437?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

cc @syxolk @toobaz @tomneep @shangyian @ScientiaEtVeritas @kdebrab 

if any of you would like to comment on this.
Looks like a style issue: https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=15235&view=logs&jobId=435ca956-9126-505f-566f-fff31072e2ba&taskId=e3717827-2a2f-5148-8ad4-7900d2171f6e&lineStart=14&lineEnd=15&colStart=1&colEnd=1

```
Checking black formatting
would reformat /home/vsts/work/1/s/pandas/io/formats/latex.py
would reformat /home/vsts/work/1/s/pandas/tests/io/formats/test_to_latex.py
All done! 💥 💔 💥
2 files would be reformatted, 858 files would be left unchanged.
```

Can you run `black` on those two files?
@jeschwar still working this? If so can you merge master and fix up conflicts?
Fixed the docstring validation issue. Merging on green.
Thanks @jeschwar!