12

I have a manual bibliography (i.e. not bibtex) that I'd like to indent with hanging indent (only second, third, etc, lines). Ideally, I'd like not to have to do this with a command on each line, but for the whole block, like \begin{hangingindent} and \end{hangingindent}. How do you do that?

  • 2
    I've provided an answer to a similar question at Opposite of \parindent – A.Ellett Dec 7 '13 at 3:12
  • In the case of a bibliography, I wonder if a list environment wouldn't make more sense? Though that would require issuing \item for each entry, I guess. – cfr Dec 7 '13 at 3:23
  • \hangindent=2em does what I want, but only for the next paragraph. But I want it to apply to all paragraphs in a section. – Jonathan Dec 7 '13 at 3:32
  • Have you considered using a list environment? – A.Ellett Dec 7 '13 at 3:47
  • Try: \usepackage{hanging} and \begin{hangparas}{<indent amount>}{<after line number>} ... \end{hangparas}`. – jon Dec 7 '13 at 4:50
11

Perhaps a list environment is all you need?

\documentclass{article}

\newenvironment{hangingpar}[1]
  {\begin{list}
          {}
          {\setlength{\itemindent}{-#1}%%'
           \setlength{\leftmargin}{#1}%%'
           \setlength{\itemsep}{0pt}%%'
           \setlength{\parsep}{\parskip}%%'
           \setlength{\topsep}{\parskip}%%'
           }
    \setlength{\parindent}{-#1}%%
    \item[]
  }
  {\end{list}}

\usepackage{lipsum}


\pagestyle{empty}
\begin{document}

  \begin{hangingpar}{2em}
  \lipsum[1-5]  
  \end{hangingpar}

  \vspace{2ex}

  But, \lipsum[6-7]

\end{document}

enter image description here

Alternatively, you could define an environment as follows:

\newenvironment{hangingparII}[1]
  {\setlength{\leftskip}{#1}%%
   \setlength{\parindent}{#1}%%
  }
  {\par}

This approach is not quite equivalent to the first. \leftskip handles the horizontal placement of displayed math differently from how a list environment handles things as the following MWE illustrates.

\documentclass{article}

\newenvironment{hangingpar}[1]
  {\begin{list}
          {}
          {\setlength{\itemindent}{-#1}%%'
           \setlength{\leftmargin}{#1}%%'
           \setlength{\itemsep}{0pt}%%'
           \setlength{\parsep}{\parskip}%%'
           \setlength{\topsep}{\parskip}%%'
           }
    \setlength{\parindent}{-#1}%%
    \item[]
  }
  {\end{list}}


\newenvironment{hangingparII}[1]
  {\setlength{\leftskip}{#1}%%'
   \setlength{\parindent}{-#1}%%'
  }
  {\par}

\usepackage{lipsum}
\pagestyle{empty}
\begin{document}

  \begin{hangingpar}{3em}
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
  purus elit, vestibu- lum ut, placerat ac, adipiscing vitae,
  felis. Curabitur dictum gravida mauris.  Nam dui ligula,
  fringilla a, euismod sodales, sollicitudin vel, wisi.
  \[
    \sin^2(x) + \cos^2(x) = 1
  \]
  Morbi auctor lorem non justo. Nam lacus libero, pretium at,
  lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed
  accumsan bibendum, erat ligula aliquet magna, vitae ornare odio
  metus a mi. Morbi ac orci et nisl hendrerit mollis. 

  Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum
  sociis natoque penatibus et magnis dis parturient montes,
  nascetur ridiculus mus. Aliquam tincidunt urna. Nulla
  ullamcorper vestibulum turpis. Pellentesque cursus luctus
  mauris.
  \end{hangingpar}      

  \begin{hangingparII}{3em}
  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut
  purus elit, vestibu- lum ut, placerat ac, adipiscing vitae,
  felis. Curabitur dictum gravida mauris.  Nam dui ligula,
  fringilla a, euismod sodales, sollicitudin vel, wisi.
  \[
    \sin^2(x) + \cos^2(x) = 1
  \]
  Morbi auctor lorem non justo. Nam lacus libero, pretium at,
  lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed
  accumsan bibendum, erat ligula aliquet magna, vitae ornare odio
  metus a mi. Morbi ac orci et nisl hendrerit mollis. 

  Suspendisse ut massa. Cras nec ante. Pellentesque a nulla. Cum
  sociis natoque penatibus et magnis dis parturient montes,
  nascetur ridiculus mus. Aliquam tincidunt urna. Nulla
  ullamcorper vestibulum turpis. Pellentesque cursus luctus
  mauris.

  \end{hangingparII}      

\end{document}

enter image description here

  • 1
    I upvoted you, but how can this be applied to thebibliography environment? – karlkoeller Dec 7 '13 at 9:56
3

Redefining thebibliography with the help of \parshape can be a solution.

Add these lines to your preamble and adjust the length of \listindent to your needs.

\newlength\listindent
\setlength\listindent{50pt}
\newlength\labellength

\let\oldthebibliography\thebibliography
\let\oldendthebibliography\endthebibliography
\renewenvironment{thebibliography}[1]
 {%
  \settowidth{\labellength}{#1}\addtolength{\labellength}{1em}%
  \oldthebibliography{#1}%
  \parshape=2%
    \labellength \linewidth%
    \listindent \dimexpr\linewidth-\listindent+\labellength\relax%
  }{%
   \oldendthebibliography%
  }

MWE:

\documentclass{article}

\newlength\listindent
\setlength\listindent{50pt}
\newlength\labellength

\let\oldthebibliography\thebibliography
\let\oldendthebibliography\endthebibliography
\renewenvironment{thebibliography}[1]
 {%
  \settowidth{\labellength}{#1}\addtolength{\labellength}{1em}%
  \oldthebibliography{#1}%
  \parshape=2%
    \labellength \linewidth%
    \listindent \dimexpr\linewidth-\listindent+\labellength\relax%
  }{%
   \oldendthebibliography%
  }


\begin{document}

\begin{thebibliography}{9}
    \bibitem{item1} text text text text text text text text text text text text text
     text text text text text text text text text text text text text text text text
     text text text text text text text text text text text text text text text text
    \bibitem{item2} text text text text text text text text text text text text text
     text text text text text text text text text text text text text text text text
     text text text text text text text text text text text text text text text text
\end{thebibliography}

\end{document}

Output:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.