There are a couple of questions asking for a description environment where the width of the label-portion is the width of the widest label:

Label:         Text text text text text text
               text text text text.
Longer label:  Text text text text text text
               Text text text text.

One solution is to use enumitem to set the label width manually (also here). Another approach is to specify the widest label manually (also here).

I am working on a dictionary that will be hundreds of pages in length. Presumably, the widest word in the whole dictionary will be something of an outlier. I would like instead the label width to be appropriate for the longest word on the page. (I'm guessing this would take two LaTeX runs, along the lines of longtable or something like that.)

So for example, the alignment of ‘Nam gui ligula’ would match on each page in the example below. It would match the width of ‘Lorem ipsum’ on the first page, but ‘Lorem ipsum dolor sit’ on the second page, etc.

\item[Lorem] \lipsum[2-3]
\item[Lorem ipsum] \lipsum[2-3]
\item[Lorem ipsum dolor] \lipsum[2-3]
\item[Lorem ipsum dolor sit] \lipsum[2-3]
\item[Lorem ipsum dolor sit amet] \lipsum[2-3]

I have tagged this for the description environment, but I'm open to any solution. Here is an MWE without any list-like environment. I'd be looking for a way to compute \ComputedWidth for each page.

\def\FixedWidthBox#1{\fbox{\hbox to \ComputedWidth{#1\hfill}}}

\FixedWidthBox{Lorem} \lipsum[2-3]

\FixedWidthBox{Lorem ipsum} \lipsum[2-3]

\FixedWidthBox{Lorem ipsum dolor} \lipsum[2-3]

  • 1
    It would be helpful if you could add a minimal working example that people can work from.
    – user30471
    Commented May 2, 2016 at 4:15
  • if you expect description of items (i.e. \lipsum[2-3]) to be breakables cross pages this will be difficult.
    – touhami
    Commented May 2, 2016 at 7:43
  • Imho it will look odd if the text width differs on every page, even more if the document is twoside. Beside this you will run into problems if page breaks can happen in the description text, as paragraphs are made before tex decides where to insert the page break. Commented May 2, 2016 at 7:54
  • Yes, I agree with you there. This is for a dictionary, though, and the idea is to have all of the pronunciations aligned, no matter the width of the head word. If I could get the maximum width of each word per page, I could even just put all the headwords into hboxs with that width.
    – adam.baker
    Commented May 2, 2016 at 9:51

1 Answer 1


Here is a working solution. After the first run things aren't aligned. The second time through they are.


\IfFileExists{\jobname .ali}{\input{\jobname .ali}}{}

\immediate\openout\AlignmentOutput=\jobname .ali



    \ifcsname WidestBoxOnPage\thepage\endcsname% 
        \setlength\Width{\csname WidestBoxOnPage\thepage\endcsname}%
    \fbox{\hbox to \Width{#1\hfill}}%

\AtBeginShipout{\immediate\write\AlignmentOutput{\string\expandafter\string\def\string\csname\space WidestBoxOnPage\thepage\string\endcsname{\the\WidestWidth}}%

\FixedWidthBox{Lorem} \lipsum[2-3]

\FixedWidthBox{Lorem ipsum} \lipsum[2-3]

\FixedWidthBox{Lorem ipsum dolor} \lipsum[2-3]

\FixedWidthBox{Lorem} \lipsum[2-3]

\FixedWidthBox{Lorem ipsum} \lipsum[2-3]

\FixedWidthBox{Lorem} \lipsum[2-3]

Update This solution ‘works’ in the sense of answering the question. I've found that practically, however, it's unworkable. The (occasionally) large changes in the size of the box change the number of lines in the paragraphs, which changes the pagination, which leads to TeX remembering the wrong box sizes between runs. I would guess that this solution could work if the page consisted of short paragraphs (especially one-liners), but I had to abandon this approach for my dictionary, which included longer paragraphs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .