[Tex/LaTex] LyX: Indent first line inside a numbered list

lyx

I am using LyX to answer questions for an assignment. Specifically, I am using the numbered list tool to number my answers. Some of the answers are quite long and go over multiple paragraphs, so I am using the following method to have multiple paragraphs inside a single numbered item:

  1. Click the "numbered list" button.
  2. Type first the paragraph.
  3. Hit return to start a new paragraph. This automatically starts a new numbered item.
  4. Type the second paragraph.
  5. Click the "default" button next to the "numbered list" button, or change the type to standard. This removes the undesired number from the start of the paragraph and indents the first line, but the entire paragraph is unaligned with the first paragraph.
  6. Hit tab, or hit alt+shift+right, or click the "increase depth" button. This aligns the second paragraph with the first, but removes the indent from the first line.

The result of the above steps looks likes this:

1. This is the first paragraph.
   This is the second paragraph,
   here it is wrapped around,
   and wrapped around some more.

This is what I would like it to look like:

1. This is the first paragraph.
      This is the second paragraph,
   here it is wrapped around,
   and wrapped around some more.

I can achieve the desired result by hitting ctrl+space a couple times before each new paragraph, but would like a better (less duplication of effort) method. This is similar to this question, except that I want indentation inside the list, not after. At the time of posting, the other question has no accepted solution.

Note that this requirement is self-imposed purely to make for easy reading. Alternative suggestions to the same end will also be appreciated!

EDIT: The tex source, copied and pasted:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\begin{document}
\begin{enumerate}
\item This is a paragraph.


This is another paragraph.\end{enumerate}

\end{document}

Running through pdf-latex gives the original result, i.e. no first-line indentation.

Best Answer

Within LaTeX's default list environments, paragraphs have no indent. The definition of \list from the LaTeX kernel identifies this:

\def\list#1#2{%
  \ifnum \@listdepth >5\relax
    \@toodeep
  \else
    \global\advance\@listdepth\@ne
  \fi
  \rightmargin\z@
  \listparindent\z@% <------------------ No \listparindent
  \itemindent\z@
  \csname @list\romannumeral\the\@listdepth\endcsname
  \def\@itemlabel{#1}%
  \let\makelabel\@mklab
  \@nmbrlistfalse
  #2\relax
  \@trivlist
  \parskip\parsep
  \parindent\listparindent% <----------- No \parindent
  \advance\linewidth -\rightmargin
  \advance\linewidth -\leftmargin
  \advance\@totalleftmargin \leftmargin
  \parshape \@ne \@totalleftmargin \linewidth
  \ignorespaces}

So you either have to insert this manually via an ERT that contains \hspace*{20pt} (where 20pt is the default \parindent) or "fix" \list to not set this value to zero (\z@) via an etoolbox patch:

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\list}{\listparindent\z@}{\listparindent\parindent}{}{}
\makeatother

Include the above in your LaTeX preamble.

enter image description here

\documentclass{article}
\usepackage{lipsum,etoolbox}% http://ctan.org/pkg/{lipsum,etoolbox}
\makeatletter
\patchcmd{\list}{\listparindent\z@}{\listparindent\parindent}{}{}
\makeatother
\begin{document}
\begin{enumerate}
  \item \lipsum[1-2]
\end{enumerate}

\end{document}
Related Question