enter image description here

How can I apply custom length of indent by giving a "precise word length" instead of estimate numbers under trial and error e.g. x pt or x mm?

  • For a single paragraph \settowidth{\hangindent}{\textbf{A Shot Head: }} will work. Sep 29 '15 at 4:00
  • possible duplicate tex.stackexchange.com/questions/263765/…
    – CroCo
    Sep 29 '15 at 4:01
  • 2
    @JohnKormylo - Using the \settowidth approach isn't quite sufficient: If the right-hand edges of the paragraph are justified, the actual head text has to be encased in an \mbox in order to "freeze" the widths of any interword spaces.
    – Mico
    Sep 29 '15 at 5:25

You could use the \settowidth macro to set the value of the \hangindent length parameter to the width of a chosen string.

Note: If you use hanging indentation, and assuming the right-hand edges of the paragraph are justifed, it's necessaryto encase the head element -- "A short head", "A much longer head", etc -- in an \mbox in order to keep LaTeX from stretching or shrinking any spaces that may occur in the lead text. Placing the head element in an \mbox "freezes" the widths of the interword spaces.

enter image description here

\usepackage{parskip} % no \parindent, \non-zero parskip

\newcommand\dummytext{This is a long sentence that will extend to the second line. I want the second line indented by the length of the head words.}


\settowidth{\hangindent}{\textbf{A short Head: }}
\mbox{\textbf{A short Head: }}\dummytext

\settowidth{\hangindent}{\textbf{A much longer Head: }}
\mbox{\textbf{A much longer Head: }}\dummytext

\settowidth{\hangindent}{\textbf{Head: }}
\mbox{\textbf{Head: }}\dummytext


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.