[comp.text.tex] an interesting problem

djmcclur@cs.toronto.edu ("David J. McClurkin") (12/06/90)

There are 2 things that I need to be able to do, and I'm
hoping that some knowledgeable TeX user will be able to help me.

1) I need to create a macro that will display text as follows:

        |<----- preceeding text goes from here to here -------------->|

        Both of these boxes contain         The right boundary
        flush left text.                    of this box (i.e. the right
	The left margin of this             end of the longest line)
        box is aligned with                 is aligned with the
        the normal left                     normal right margin.
        margin

The problem seems to be that one cannot create a vbox or parbox whose
width is simply that of the longest line inside (its "natural" width).

2) I want to use headings that look like:

   4.1 This is the Heading.  This is the following text of the section...

by using a command like

   \subsection{This is the Heading}
   (blank line here)
   This is the following text...

In other words I need to be able to skip over blank lines between
the \subsection command and the actual text of the subsection, without
beginning a new paragraph.  \ignorespaces doesn't seem to ignore
carriage returns, just space tokens.  Is there an analog that will
ignore carriage returns as well; of can we redefine the catcode for
cr and somehow return it to normal when the actual text of the
subsection begins?

I'm hoping that the answers to both questions are trivial.
Thanks in advance for helping me.

Dave McClurkin

eijkhout@s41.csrd.uiuc.edu (Victor Eijkhout) (12/07/90)

djmcclur@cs.toronto.edu ("David J. McClurkin") writes:

>1) I need to create a macro that will display text as follows:

>        |<----- preceeding text goes from here to here -------------->|

>        Both of these boxes contain         The right boundary
>        flush left text.                    of this box (i.e. the right

>The problem seems to be that one cannot create a vbox or parbox whose
>width is simply that of the longest line inside (its "natural" width).

I fail to see what the problem and the above statement have to do
with each other.  What is the `preceding text'? If that is the last line of a 
paragraph I agree that you have a small problem. Otherwise, it
is something that you put there, so you know how big it is.
Give me some more info.

>2) I want to use headings that look like:

>   4.1 This is the Heading.  This is the following text of the section...

You are using LaTeX? Macros \section, \subsection, et cetera
are implemented in the style files in terms of a primitive
\@startsection that is specified as follows:
% \@startsection {NAME}{LEVEL}{INDENT}{BEFORESKIP}{AFTERSKIP}{STYLE}
%            optional * [ALTHEADING]{HEADING}
%    Generic command to start a section.
%    NAME       : e.g., 'subsection'
%    LEVEL      : a number, denoting depth of section -- e.g., chapter=1,
%                 section = 2, etc.
%    INDENT     : Indentation of heading from left margin
%    BEFORESKIP : Absolute value = skip to leave above the heading.
%                 If negative, then paragraph indent of text following
%                 heading is suppressed.
%    AFTERSKIP  : if positive, then skip to leave below heading, else
%                 negative of skip to leave to right of run-in heading.
%    STYLE      : commands to set style
You see that reversing the skip given as AFTERSKIP will
give you the effect you are after. Dig around in the style files a
bit.

>I'm hoping that the answers to both questions are trivial.

'Fraid not.

>Thanks in advance for helping me.

You're welcome.

>Dave McClurkin

Victor.

steve@Advansoft.COM (Steve Savitzky) (12/07/90)

In article <90Dec5.204808est.6898@neat.cs.toronto.edu> djmcclur@cs.toronto.edu ("David J. McClurkin") writes:

   1) I need to create a macro that will display text as follows:

	   |<----- preceeding text goes from here to here -------------->|

	   Both of these boxes contain         The right boundary
	   flush left text.                    of this box (i.e. the right
	   The left margin of this             end of the longest line)
	   box is aligned with                 is aligned with the
	   the normal left                     normal right margin.
	   margin

   The problem seems to be that one cannot create a vbox or parbox whose
   width is simply that of the longest line inside (its "natural" width).

If you're willing to mark the line breaks yourself (as you seem
willing to do), the way to do this is to set each of the boxes as a
table.  I frequently resort to this when setting poetry, where you
want to center a box-full of left-justified lines.
--
\ --Steve Savitzky--  \ ADVANsoft Research Corp \ REAL hackers use an AXE! \
 \ steve@advansoft.COM \ 4301 Great America Pkwy \ #include<disclaimer.h>   \
  \ arc!steve@apple.COM \ Santa Clara, CA 95954   \        408-727-3357      \
   \__ steve@arc.UUCP _________________________________________________________