views:

339

answers:

2

I'm writing a document in LaTeX, and am encountering a problem when I have a line of text that wraps around. What I need is for the text, when it wraps around, to indent so that it matches the label (much like the \item[Label:] Text function, except I can't use a {description} context. Any ideas?

This happens in the context of

\newcommand{\objectiveresheading}[1]{%
  {\parashade[.9]{sharpcorners{\textbf{\Large{Objective: }\large{#1}}}}}
A: 

You can put the label into a numbered box, take the width of that box, and use \hangindent and \hangafter to make an indented paragraph. To learn how to use \setbox, \wd, \hangindent, and \hangafter, the best source is probably the horse's mouth: The TeXbook.

Norman Ramsey
Yep, this is what `\@hangfrom` does internally :)
Will Robertson
@Will: You are a LaTeX master, and I am such a dinosaur...
Norman Ramsey
I'd say it's more important to know how to do it! But for a question like this it's useful to know a shortcut. P.S. One day I may well solicit you for noweb expertise :)
Will Robertson
+3  A: 

There is an internal LaTeX macro to perform this function called \@hangfrom. Here is an example:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\makeatletter
\newcommand*\objectiveresheading[1]{%
  \@hangfrom{\Large\bfseries Objective: }%
  {\large\bfseries #1\par}%
} 
\makeatother
\objectiveresheading{\lipsum[1]}
\end{document}

Note that the wrapped text can only be a single paragraph. If you need multiple paragraphs, something more similar to a list environment would be better.

Will Robertson
How do you discover stuff like this? Browsing `latex.ltx`?
Norman Ramsey
Osmosis :) I haven't spent much time reading source2e cover-to-cover, so to speak, but I've spent a fair amount of time in various sections of it. Otherwise, spending lots of time in places like comp.tex.text., where there's a bunch of people who've been using (La)TeX for decades longer than I.
Will Robertson