Path: utzoo!attcan!uunet!olivea!orc!bbn.com!nic!chaos.cs.brandeis.edu!SOMMER@BINAH.CC.BRANDEIS.EDU From: sommer@BINAH.CC.BRANDEIS.EDU Newsgroups: comp.text.tex Subject: Re: Need non-fixed-width parbox in LaTeX Message-ID: <009410A2.333A9240@BINAH.CC.BRANDEIS.EDU> Date: 11 Dec 90 23:55:38 GMT References: <1568@abekrd.UUCP> Sender: @chaos.cs.brandeis.edu Reply-To: sommer@BINAH.CC.BRANDEIS.EDU Organization: Brandeis University Lines: 27 In article <1568@abekrd.UUCP>, garyb@abekrd.UUCP (Gary Bartlett) writes: >I need to format a piece of text in a parbox (because I need to specify >where the line breaks are to occur) but I want the final box to be only as >wide as the largest line of text. I cannot figure out how to achieve this. > >eg - the text to be formatted: > > this is line 1 \\ > this is a longer line 2 \\ > the end > >I will always specify where the line breaks are to occur so I don't need >LaTeX to split the lines for me. Theoretically therefore, I don't need to >specify a width. Unfortunately, \parbox demands a width. I don't know the >width of the longest line before hand either. Can anyone see a way around >this? Don Hosek posted two different solutions. I'm only a LaTeX amateur, but I think this will work, too (see LaTeX manual, p. 95): \newlength{\boxwidth} % or whatever you want to call it \settowidth{\boxwidth}{this is a longer line 2} % your longest line \parbox{\boxwidth}{this is line 1 \\ this is a longer line 2 \\ the end} I think it should work with centering, etc., thrown in, too.