3

While learning with Plain TeX, I am trying to create a framed paragraph. I have started with the following code, which is supposed to limit the paragraph width but still enable the line breaking mechanism to work correctly (so I can later use \vline and \hline to create the frame):

\hbox to 10cm{
    \vbox{
        \hsize 10cm
        test
    }
}
\bye

When I use this code, I get an overfull \hbox error

Overfull \hbox (4.44443pt too wide) detected at line 6
 [] |

When I use longer text, it is correctly divided into individual lines of the width 10 cm.

Why is there an overfull? What am I missing?

1 Answer 1

3

Think of it this way: Spaces or line breaks after braces { and } are not ignored. You need to use % to defeat that:

\hbox to 10cm{%
    \vbox{%
        \hsize 10cm
        test
    }%
}%
\bye

This generates no overfull messages.

Likewise, putting all the code on one line (which generally I don't advise) -- with no spaces or line breaks after either { or } -- will also prevent the problem:

\hbox to 10cm{\vbox{\hsize10cm test}}%
\bye
1
  • Thank you, I absolutely forgot about line breaks being interpreted spaces as well
    – jenda
    Commented Nov 4, 2018 at 14:53

You must log in to answer this question.

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