[Tex/LaTex] How does plain TeX \insert work

plain-tex

My question is about Plain TeX command \insert.

I understood that every insert series has a dedicated box. But I didn't understand if the use of \insert adds content to the box, or if the box is constructed at the end of the page, from a list.

If the second answer is true, my question is: are the elements in the list of insert (for one series) concatened in one hbox, or are they concatened in vbox, with a paragraph break between them.

My problem is for the some change in ledmac.

Actually, ledmac provide some "paragraphed" notes, which are ultimately producted by

\insert\paragraphednote
\bgroup
\hbox{content of my note}
\egroup

That puts all notes in the same paragraph. But as you know, an hbox can't be broken. An so, it's problematic.

But if I just put the content without \hbox, my notes are not in the same paragraph, but I obtain one paragraph per note.

I hope to be clear.

You find the real code on github

Best Answer

\insert is a TeX primitive not a plain TeX command.

If you go

\insert\boxregister{ 
  .... vertical mode material ...
}

then two things happen, the vertical mode material is saved away and an insert node is placed in the current list.

If the current list is a horizontal list in a paragraph the node "migrates" to the surrounding vertical list.

Any insert nodes that end up being inside a box are essentially lost.

Insert nodes that end up on the main vertical list affect the page breaker in several ways.

depending on \count\boxregister and \skip\footins the output routine leaves space for the inserts when chopping off the page.

Inside the output routine \box\boxregister contains the contents of the insertion boxes u to a maximum of \dimen\boxregister. Any additional inserts are held over on to the next page (and the last insert on the page may be split if it doesn't fit (and is splittable)

so in your example the output routine will be handed \box\paragraphednote which will be a vbox with a sequence of hboxes. the output routine is responsible for adding (or not) those boxes to the page before it is shipped out, it could unbox the contents or process them in any way or it could decide not to make any inserts on the page being shipped out and re-insert them into the material returned to the main vertical list.

You probably need to add an actual runnable example showing any problem. The code you link to is rather long to take in by eye but as far as I can see the intention is that teh boxing is only temporary and the \removehboxes macro is invoked to unbox and re-package the notes.

You say that \hbox prevents line breaking but that does not appear to be the intention of the code.

Related Question