Repository: scipy/scipy

Issue:
DOC: LaTeX package expdlist interacts badly with nested description environment
Currently the following set-up is used

```latex
\usepackage{expdlist}
\let\latexdescription=\description
\let\endlatexdescription=\enddescription
\renewenvironment{description}%
{\begin{latexdescription}[\setleftmargin{60pt}\breaklabel\setlabelstyle{\bfseries\itshape}]}%
{\end{latexdescription}}
```

There is also a bugfix which was added at #8637:

```latex
% Fix bug in expdlist's modified \@item
\usepackage{etoolbox}
\makeatletter
\patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{}
\makeatother
```
but this is not related to present issue.

This usage of `expdlist` interacts badly with typical mark-up produced by Sphinx, here is a  short example which was copied from produced `scipy-ref.tex` and made compilable by removing some `\sphinxcode` etc... macros:

```latex
\documentclass{article}

\usepackage{expdlist}
\let\latexdescription=\description
\let\endlatexdescription=\enddescription
\renewenvironment{description}%
{\begin{latexdescription}[\setleftmargin{60pt}\breaklabel\setlabelstyle{\bfseries\itshape}]}%
{\end{latexdescription}}
% Fix bug in expdlist's modified \@item
% \usepackage{etoolbox}
% \makeatletter
% \patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{}
% \makeatother

\begin{document}
\begin{quote}\begin{description}
\item[{Parameters}] \leavevmode\begin{description}
\item[\textbf{bw\_method}] \leavevmode{[}str, scalar or callable, optional{]}
The method used to calculate the estimator bandwidth.  This can be
‘scott’, ‘silverman’, a scalar constant or a callable.  If a
scalar, this will be used directly as \emph{kde.factor}.  If a callable,
it should take a \texttt{{gaussian\_kde}} instance as only parameter and
return a scalar.  If None (default), nothing happens; the current
\emph{kde.covariance\_factor} method is kept.

\end{description}

\end{description}\end{quote}
\end{document}
```

It produces this output with an extra blank line:

![capture d ecran 2018-04-02 a 10 03 08](https://user-images.githubusercontent.com/2589111/38188635-12ef0a8a-365d-11e8-87a2-3abe5a06b1fa.png)


Compare when commenting out completely all `expdlist, latexdescription, ...` from the above.

LaTeX Source:

```latex
\documentclass{article}

\begin{document}
\begin{quote}\begin{description}
\item[{Parameters}] \leavevmode\begin{description}
\item[\textbf{bw\_method}] \leavevmode{[}str, scalar or callable, optional{]}
The method used to calculate the estimator bandwidth.  This can be
‘scott’, ‘silverman’, a scalar constant or a callable.  If a
scalar, this will be used directly as \emph{kde.factor}.  If a callable,
it should take a \texttt{{gaussian\_kde}} instance as only parameter and
return a scalar.  If None (default), nothing happens; the current
\emph{kde.covariance\_factor} method is kept.

\end{description}

\end{description}\end{quote}
\end{document}
```

output:

![capture d ecran 2018-04-02 a 10 02 28](https://user-images.githubusercontent.com/2589111/38188622-0376b346-365d-11e8-8712-a644461378b1.png)

### Proposal:

Find some alternative to ``expdlist`` to get similar functionality but avoid the extra blank line, which manifests itself by `badness 10000` lines in log

With usage of expdlist:

```
$ grep '(badness 10000) in paragraph' scipy-ref.log | wc -l
    2630
```

Without it:

```
$ grep '(badness 10000) in paragraph' scipy-ref.log | wc -l
     198
```

### Scipy/Numpy/Python version information:

1.1.0.dev0+ca03829 1.14.2 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)

Sphinx version : 1.7.2.

In my testing there was some latex compilation bug due to bad math mark-up (see https://github.com/scipy/scipy/blame/ca0382968ed05c255d8ea069db3e0f97d1c52cd5/doc/source/tutorial/optimize.rst#L525). I will make separate issue.


Discussion:
Sorry, I wanted to refer to https://github.com/scipy/scipy/blame/ca0382968ed05c255d8ea069db3e0f97d1c52cd5/doc/source/tutorial/optimize.rst#L535, or on master https://github.com/scipy/scipy/blame/master/doc/source/tutorial/optimize.rst#L535

cf PR #8653 

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -187,13 +187,28 @@
 \usepackage{expdlist}
 \let\latexdescription=\description
 \let\endlatexdescription=\enddescription
-\renewenvironment{description}%
-{\begin{latexdescription}[\setleftmargin{60pt}\breaklabel\setlabelstyle{\bfseries\itshape}]}%
+\renewenvironment{description}
+{\renewenvironment{description}
+   {\begin{latexdescription}%
+    [\setleftmargin{50pt}\breaklabel\setlabelstyle{\bfseries}]%
+   }%
+   {\end{latexdescription}}%
+ \begin{latexdescription}%
+    [\setleftmargin{15pt}\breaklabel\setlabelstyle{\bfseries\itshape}]%
+}%
 {\end{latexdescription}}
 % Fix bug in expdlist's modified \@item
 \usepackage{etoolbox}
 \makeatletter
 \patchcmd\@item{{\@breaklabel} }{{\@breaklabel}}{}{}
+% Fix bug in expdlist's way of breaking the line after long item label
+\def\breaklabel{%
+    \def\@breaklabel{%
+        \leavevmode\par
+        % now a hack because Sphinx inserts \leavevmode after term node
+        \def\leavevmode{\def\leavevmode{\unhbox\voidb@x}}%
+    }%
+}
 \makeatother
 
 % Make Examples/etc section headers smaller and more compact


Test patch: