\documentclass[a4paper]{article}\newsavebox{\defbox}\newenvironment{definition}[2][]{% \sbox\defbox{#1\begin{tabular}[t]{@{}l@{}}#2\end{tabular}}% \count255=\numexpr1+(\dimexpr(\ht\defbox+\dp\defbox))/% \numexpr(\baselineskip)\relax \par\addvspace{\topsep} \hangindent=1.2\wd\defbox \hangafter-\count255 \noindent\llap{% \makebox[1.2\wd\defbox][l]{\smash{\usebox\defbox}}}% \ignorespaces} {\par\addvspace{\topsep}}\usepackage{lipsum}\begin{document}\lipsum[2]\begin{definition}[\bfseries]{abc\\def\\ghijklmnop}\lipsum[1]\end{definition}\lipsum[2]\end{document}
This is similar to Ulrike's solution, but automatically measures the text that must go in the "window". In the optional argument one puts declarations for the text in the "window", that's typeset in a tabular environment.
Explanation.
We reserve a box for doing measurements (\defbox
); in this box we set the text to be shown in the "window" as lines of a one column left aligned tabular; before the tabular we execute possible declaration stated in the optional argument. The mandatory argument should be in a form suitable for tabular, i.e., lines separated by \\
.
Next we measure the height + depth of the material and divide this length by \baselineskip
; we add 1 to leave a space at the bottom: this number says how many lines must be indented.
Now we set the material: (1) we leave a space as the usual theorem-like environments do; (2) we set the hanging indent (20% more than the width of the "window") and the number of indented lines (see later); we say \noindent
and put the tabular already typeset in \defbox
in a zero width box (\llap
) flush with the margin where we typeset the "window" after "smashing" it (so it won't contribute to the size of the line where it appears); (3) we say \ignorespaces
to avoid spurious spaces, as it is necessary to do whenever an environment's start code typesets text.
At the environment's end we leave a space equal to the separation left at the beginning.
\hangindent
takes as argument (not in braces) the desired indentation; \hangafter
specifies when this indentation should come into action: if the number n after it is positive, the indentation will start after n lines; if the number is negative, the indentation will start at the first line and end after line number -n. It's important to remark that these two parameters are reset to zero after the next \par
command (at the same group level).