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 Answers
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}
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}
-
1I upvoted you, but how can this be applied to
thebibliography
environment? Dec 7, 2013 at 9:56
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:
\hangindent=2em
does what I want, but only for the next paragraph. But I want it to apply to all paragraphs in a section.list
environment?\usepackage{hanging}
and\begin{hangparas}{<indent amount>}{<after line number>} ...
\end{hangparas}`.