While trying to figure out what is going on with material swapped with \subsection in AMS document classes I finally looked at the definition of \@startsection in latex.ltx. My best understanding of what it does when creating a run-in header (like that which is used for amsart's \subsection) is something like this:

Instead of printing the header directly, it saves the information on what it will print as the header, and prints it at the beginning of the first paragraph to follow.

Question 1 What is the advantage of doing things this way? (As opposed to immediately printing the header and processing the tokens to follow?)

Question 2 One side effect is seen in the linked question above. When using the framed package, if you build a framed box using \begin{framed}...\end{framed} immediately after the start of a run-in section, it appears that the \everypar in the definition of the section command is never triggered until after the framed box is printed. (Though I admit I don't know exactly what's going on that causes the framed box to be printed first.) What are the best practices to avoid things like this?

(In practice it appears you can flush the header out by manually \leavevmode\par to start and end a paragraph, and this dumps the text back out. But this feels hackish?)

  • \paragraph will work even is there is an empty line before the following text. This means you can without problem switch the style. May 19, 2021 at 21:14
  • a run in header is inserted in the following paragraph, like your Question 1 header above. If you use \leavemode\par you would break that and it would look like a badly spaced display header rather than run-in. May 19, 2021 at 21:15
  • @UlrikeFischer: I don't entirely understand your comment. Can you expand on it a bit more? May 20, 2021 at 11:44
  • @DavidCarlisle: in practice people do sometimes start sections with run-in headers with lists or quotes. I understand that it doesn't look the nicest. But in the case of framed, I would rather see a poorly spaced display header that shows before the following material, than a header than shows up too late. May 20, 2021 at 11:51


You must log in to answer this question.

Browse other questions tagged .