2

I have the following groff source using the mom macros:

.PRINTSTYLE TYPESET
.CAPTION_AFTER_LABEL IMG
.START
.PDF_IMAGE img/uc1.pdf 657p 152p SCALE 70 CAPTION "Figure 1: Activity diagram for UC1"
.PP
Placeholder text 1
.PDF_IMAGE img/uc2.pdf 345p 61p CAPTION "Figure 2: Activity diagram for UC2"
.PP
Placeholder text 2
.PDF_IMAGE img/uc3.pdf 517p 301p SCALE 75 CAPTION "Figure 3: Activity diagram for UC3"
.PP
Placeholder text 3
.PDF_IMAGE img/uc4.pdf 540p 470p SCALE 75 CAPTION "Figure 4: Activity diagram for UC4"
.PP
Placeholder text 4

It renders like this:

example incorrect render

Since the third image cannot fit on the first page, the third image is pushed onto the next page, which is fine. However, the problem is Placeholder text 3 and Placeholder text 4 should appear after the third image and fourth images respectively on the next page, rather than immediately after the second image on the first page. I.e., I want the paragraphs to appear after the preceding image in the generated PDF, in the same order as in the groff source.

None of the arguments to the PDF_IMAGE macro look like they would fix this problem.

I tried using the ALD macro to move the vertical position on the page, thinking that the PDF_IMAGE macro was throwing off the vertical position, but that just caused a large vertical gap of whitespace before the paragraphs.

How can I fix this?

How I compile the PDF

pdfmom example.mom > example.pdf

1 Answer 1

2

troff has the concept of a floating keep. In mom this is provided by the .FLOAT macro. Content between the start and end of the float is kept on the same page, but may slide over other output to achieve this. The option FORCE avoids this. The macro resets the text justification to no fill, so you would need to use .JUSTIFY within the float to undo this, but you already have a .PP which should include this. Example:

.FLOAT FORCE
.PDF_IMAGE img/uc1.pdf 657p 152p SCALE 70 CAPTION "Figure 1: Activity diagram for UC1"
.PP
Placeholder text 1
.FLOAT OFF
7
  • Thanks for your help! Unfortunately, I get an environment stack overflow error. Please see my updated question. Jan 21, 2021 at 17:13
  • Apart from the error message, does it seem to work?
    – meuh
    Jan 21, 2021 at 17:50
  • No, it doesn't fix the problem. The resulting PDF looks the same. Jan 21, 2021 at 18:02
  • Did you put a .FLOAT FORCE .FLOAT OFF around each image and the placeholder text that follows? I don't have your pdf images and so on, but I tried with some pdf's on my old groff version 1.22.3 and it seemed to work, moving the text on to below the image. I also got the error messages though. What version are you using?
    – meuh
    Jan 21, 2021 at 18:11
  • 1
    I agree. It feels like a bug. The documentation says that since some version each image is now automatically in a float. So we have a float in an implied float, which may not have been well tested. But the doc does suggest that it should work.
    – meuh
    Jan 21, 2021 at 19:20

You must log in to answer this question.

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