3

Consider the code,

\documentclass[12pt]{book}

\begin{document}
\thispagestyle{empty}

\large
\noindent\textbf{How to Automatically Indent the Second Line of This Statement a Prescribed Amount---Say 15pt?}
\end{document}

Which produces

enter image description here

Question: What may be an expedient way to indent the last line (second line in this case) of a multi-lined statement a prescribed amount---say 15pt, here?

Thank you.

1

1 Answer 1

5

You can define and use the macro \indentlast:

\def\indentlast#1#2{\par
   \setbox0=\vbox{%
      \parfillskip=#1 plus1fil \relax
      \noindent #2\par
   }%
   \ifdim\prevdepth>-1000pt \kern-\prevdepth\kern1ex \fi
   \unvbox0
   \setbox0=\lastbox
   \nointerlineskip\moveright#1\box0
}

\indentlast{15pt}
   {This macro indents the last line of the paragraph. 
   How to Automatically Indent the Second Line of This Statement 
   a Prescribed Amount---Say 15pt?}
2
  • Thank you for this very helpful answer.
    – DDS
    Oct 1 at 6:14
  • The most interesting bit is that \setbox0=\lastbox literally removes the last line written. Oct 1 at 14:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .