LaTeX: indent from second line
I want to indent from the second line.
I want to write in LaTeX something like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam interdum dictum suscipit magna molestie. Vestibulum nibh dolor, interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper in commodo erat dignissim. Cras e开发者_如何学JAVAt suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus. Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla imperdiet cursus enim condimentum congue.
And I want to produce:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
Depending on why you want to do this, you might be better off using the built-in TeX support for hanging indentation, which the hanging package sugars. If it's a one-off, use the package, but if it's built in to some other layout, the package might just confuse things. Up to you.
The \hangindent
dimension gives the size of the indentation, and the \hangafter
number indicates when that indentation should start or stop. If the \hangafter
number is positive, then indentation starts after that number of lines; if it's negative, then it starts immediately and stops after (minus) that many lines.
These apply only to the immediately following paragraph. The hanging package handles this by using \everypar
. That's an occasionally problematic technique, which is why the package includes a 'word of caution' about it.
\documentclass{article}
\parindent=0pt
\parskip=\medskipamount
\begin{document}
\hangindent=2em
\hangafter=2
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
\hangindent=2em
\hangafter=-2
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
\end{document}
Negative hanging indentations in LaTeX are most easily handled with the hanging package.
Edit: Fixed the broken link.
Similar to Ricibald's answer but simpler (it wasn't clear to me in his post which length was doing the job). I was using this for a bulleted list to indent each line after the first:
\begin{list}{}%
{\leftmargin=1em \itemindent=-1em}
\item
\item
\end{list}
\hangindent=\parindent
\hangafter=1
\noindent
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
I found this solution. For me it's better because it is valid for all text since this point: I don't need to repeat the command for every paragraph:
\begin{list}{}{%
\setlength{\topsep}{0pt}%
\setlength{\leftmargin}{0.1in}%
\setlength{\listparindent}{-0.1in}%
\setlength{\itemindent}{-0.1in}%
\setlength{\parsep}{\parskip}%
}%
\item[]
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent
sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam
interdum dictum suscipit magna molestie. Vestibulum nibh dolor,
interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem
sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper
in commodo erat dignissim. Cras et suscipit enim.
Nunc adipiscing ligula at ligula egestas id ullamcorper felis luctus.
Aliquam tincidunt turpis sed eros pellentesque iaculis. Nulla
imperdiet cursus enim condimentum congue.
\end{list}
Now my normal text!
When you create a list the list margin is indented by one indent (\leftmargini) and \itemindent is 0; if you set the \itemindent equal to the negative of the left margin, the hanging indent will line up exactly with the outer scope margin, and you'll get exactly one indent inside the list. It is a quick and simple way to get in and out of a hanging indented list setting only one value: \itemindent.
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\begin{list}{}{\setlength\itemindent{-\leftmargin}}
\item \lipsum[1]
\item \lipsum[2]
\end{list}
\end{document}
How about:
\usepackage{changepage}
\newenvironment{indentblock}{\begin{adjustwidth}{\parindent}{}\hspace{-\parindent}}{\end{adjustwidth}}
\begin{document}
\begin{indentblock}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin eu tempor velit. Fusce accumsan ultrices fringilla. Praesent sed odio mi. Mauris non ligula turpis. Duis posuere lacus nec diam interdum dictum suscipit magna molestie. Vestibulum nibh dolor, interdum eget rhoncus ut, sodales eget justo. Morbi blandit lorem sit amet nulla egestas aliquam. Nunc pharetra est at nibh ullamcorper in commodo erat dignissim. Cras et suscipit enim.
\end{indentblock}
\end{document}
Simply change \parindent
to a value of your liking, e.g., 4em
.
You can modify globally or locally the length named parindent
(that has a default value depending on your documentclass and packages and options):
\documentclass{article}
\usepackage{lipsum}
\setlength\parindent{-3em}
\begin{document}
\lipsum[1]
\setlength\parindent{0pt}
\lipsum[2]
\end{document}
精彩评论