开发者

Indented Word Wrap in LaTeX

开发者 https://www.devze.com 2022-12-18 15:09 出处:网络
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

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{\object开发者_运维知识库iveresheading}[1]{%
  {\parashade[.9]{sharpcorners{\textbf{\Large{Objective: }\large{#1}}}}}


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消