我有一个手册书目(即不是 bibtex),我想用悬挂缩进来缩进(仅第二行、第三行等)。理想情况下,我不想在每一行都使用命令来执行此操作,而是对整个块执行此操作,例如\begin{hangingindent}
和\end{hangingindent}
。您如何做到这一点?
答案1
也许list
您所需要的就是一个环境?
\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}
或者,您可以按如下方式定义环境:
\newenvironment{hangingparII}[1]
{\setlength{\leftskip}{#1}%%
\setlength{\parindent}{#1}%%
}
{\par}
这种方法与第一种方法并不完全相同。 \leftskip
处理显示数学的水平放置的方式与list
环境处理事物的方式不同,如下面的 MWE 所示。
\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}
答案2
thebibliography
重新定义\parshape
可以解决问题。
\listindent
将这些行添加到您的序言中并根据您的需要调整长度。
\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%
}
梅威瑟:
\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}
输出: