[comp.text] \parbox dilemma in LaTeX

greg@jell-o.berkeley.edu (Greg) (02/11/89)

I would like to have \parbox environments with no hyphenation inside.
I want the end product to look like this:

Algebraic      Singular homology and cohomology, the excision theorem,
Topology       long exact sequences from short exact sequences, the
               Kunneth formula

3-Manifolds    Homotopy theory, homotopy groups, covering spaces,
               Van Kampen's theorem,...

The problem is that LaTeX would like to format it like this:

Algebraic Top- Singular homology...
ology          long exact ...

At the moment, I have the following klugey solution in my macro:

\parbox[t]{1in}{{\hyphenation{#1} \bf #1}}

and I have to have an alternate:

\parbox[t]{1in}{{\bf #1}}

because \hyphenation will choke on non-alpha characters.  Is there
a better way?
---
Greg

leichter@cs.yale.edu (02/11/89)

There are two "better ways":

a)  You are making a minor stylistic choice here.  There are going to be in-
stances in which NOT hyphenating looks bad.  Since you are trying to control
things to this level, it might be best to consider this a "final tuneup" and
insert explicit \\'s to get the line breaks EXACTLY where you want them.

(Alternatively, you could wrap the individual words you don't want hyphenated
in \mbox's, but if you do that, you might as well grab full control over the
line breaking.)

b)  If you really want to just forbid hyphenation, the following should work:

	\parbox[t]{1in}{{\hyphenpenalty=10000 \bf #1}}

(You won't find \hyphenpenalty in the LaTeXbook - you'll have to "descend" to
the TeX level.)

The approach of using \hyphenation is worse than you think:  The hyphenation
tables are NOT subject to nesting.  After you've set your "algebraic topology"
label once, neither word will ever be hyphenated in your document again.

							-- Jerry

mrd@sun.soe.clarkson.edu (Michael DeCorte) (02/11/89)

have you tried \raggedright I think it will do what you want.
--

Michael DeCorte // (315)265-2439 // P.O. Box 652, Potsdam, NY 13676
Internet: mrd@sun.soe.clarkson.edu  // Bitnet:   mrd@clutx.bitnet        
---------------------------------------------------------------------------
Clarkson Archive Server // commands = help, index, send, path
archive-server@sun.soe.clarkson.edu
archive-server%sun.soe.clarkson.edu@omnigate.bitnet
dumb1!dumb2!dumb3!smart!sun.soe.clarkson.edu!archive-server
---------------------------------------------------------------------------

greg@jif.berkeley.edu (Greg) (02/11/89)

In article <MRD.89Feb10181808@sun.soe.clarkson.edu> mrd@sun.soe.clarkson.edu (Michael DeCorte) writes:
>have you tried \raggedright I think it will do what you want.

In article <50303@yale-celray.yale.UUCP> leichter@cs.yale.edu (Jerry Leichter)
writes:
>b)  If you really want to just forbid hyphenation, the following should work:
>	\parbox[t]{1in}{{\hyphenpenalty=10000 \bf #1}}

Thanks for your suggestions folks; the right answer turns out to be:

\parbox[t]{1in}{\raggedright \bf #1}

I think my previous problem was that I first tried the following, which
does NOT work:

\parbox[t]{1in}{{\raggedright \bf #1}}
---
Greg

gm@romeo.cs.duke.edu (Greg McGary) (02/11/89)

In article <50303@yale-celray.yale.UUCP> leichter@cs.yale.edu writes:
>There are two "better ways":

Here's a third "better way":

You can increase the "raggedness" by modifying the definition of \raggedright.

Here's the old definition:
\def\raggedright{\rightskip\z@ plus2em \spaceskip.3333em \xspaceskip.5em\relax}

Notice that 2em is hardwired as the amount of raggedness to the rightskip.

Here's a replacement definition that takes an argument.
(I've presented it here in TeXese, modify as required for LaTeXese)
\def\RaggedRight#1{\rightskip\z@ plus#1 \spaceskip.3333em \xspaceskip.5em\relax}

This allows you to specify the raggedness desired at invocation (e.g.
\RaggedRight{4em} will make TeX tolerate lines twice as ragged as normal
before hyphenating)  I've found that this works far better than fiddling
with the \hyphenpenalty.  If you penalize hyphens too severely, then
you'll end up with overfull or underfull \hboxes when problematic line
breaks occur.  With a stretchier glob of glue for the \rightskip, these
don't occur as readily, and when bad breaks arise, you can keep
\hyphenpenalty at a reasonable value so that hyphenation can occur when
it's really needed as a last-resort.

-- Greg McGary
-- 4201 University Drive #102, Durham, NC 27707       voice: (919) 490-6037
-- {decvax,hplabs,seismo,mcnc}!duke!gm                 data: (919) 493-5953
--                                  gm@cs.duke.edu