How to Make LaTeX use a Hanging Indent
July 1st, 2008 at 10:22 pm (Computers, Technology, Writing)
Ah, LaTeX. The programmer’s text processing system, in which you have to compile your document before it turns into something viewable. It gives us the joys of truly beautiful equation typesetting and the agonies of obscure commands, crazy “badness” rules, and sometimes obstreperous auto-figure placement.
Today was a case in point. I’m typesetting the index for a book and I wanted to get entries to have hanging indents, like this:
This is my paragraph, which I am writing to demonstrate what it looks like to have a paragraph that wraps and uses a hanging indent.
The only problem is that LaTeX only lets you specify how much to indent the first line of a paragraph, not the rest. The assumption is that the “typical” sort of indentation you want is to get paragraphs like this:
This is another paragraph, which shows what it looks like to have a paragraph that wraps but indents the first line instead of the following lines.
The solution turns out to be to set your left margin in to where you want the hanging lines to be, and then use a negative offset to specify the indentation of the first line. Here’s an example:
\leftskip 0.1in
\parindent -0.1in
Thank you, google! Talk about thinking outside the box.
P.S. What’s funny is that HTML has the same limitation, so to show the first example above, I had to set a negative text indentation.
k said,
August 29, 2008 at 5:55 pm
(Learned something new!)thanks a lot! helped out a bunch
k said,
August 29, 2008 at 6:04 pm
also check out the following:
\begin{hangparas}{.25in}{1}
Paragraph to be hanging indented
Another paragraph to be hanging indented
\end{hangparas}
from http://dataninja.wordpress.com/2006/10/25/essential-latex-packages-for-school/
MartinB said,
March 3, 2009 at 1:06 am
(Learned something new!)PlainTex also has the nice commands
\hangindent and
\hangafter
They are a bit tricky to use, but very powerful. (See the TeX book, ch 14)
Swift Arrow said,
May 16, 2009 at 3:19 am
(Learned something new!)Thank You!!! Life Saver!!! Just in Time!!!
Lisa said,
September 8, 2009 at 3:08 pm
(Learned something new!)Awesome! So incredibly helpful. :)
Vijay Kaul said,
December 3, 2010 at 5:10 pm
(Learned something new!)I think that’s just how computer scientists think! I always forget these things, though; thanks for posting!
Anonym said,
September 24, 2011 at 2:16 am
(Learned something new!)Thanks, was useful for me.
Yalag said,
March 4, 2012 at 4:26 am
(Learned something new!)Thanx. Just what I needed.
Red said,
July 9, 2012 at 6:02 pm
(Learned something new!)You can also do \hangindent=1cm or something similar before the paragraph that you want to use it with. But it might be different for what exactly you’re wanting to do.