tobiasah / mkdocs-caption

MkDocs plugin to add captions and easy element numbering
MIT License
3 stars 2 forks source link

Automatic Link Text Generation in Referencing does not print in PDFs #21

Open Marioheld opened 6 days ago

Marioheld commented 6 days ago

I am trying to use this plugin to reference figures and tables while automating the numbering. This also works without any problems in the website output. However, it does not work in combination with the mkdocs-with-pdf plugin to export a PDF. Manually set link texts are displayed, but not the automatically generated ones.

Figure: Caption Text { #fig_id1 }

![](assets/demo.png)

See [Figure](#fig_id1) above for more details.

image

The example above does work both on the website and the PDF.

Figure: Caption Text { #fig_id2 }

![](assets/demo.png)

See [](#fig_id2) above for more details.

image

The example above does only work on the Website, but not in the PDF.

I am using Version 0.9.3 of the plugin mkdocs-with-pdf

Thanks a lot for any help.

tobiasah commented 6 days ago

thanks for bringing this up. I am not using the mkdocs-with-pdf plugin myself, so I was not aware of this issue.

I quickly tried to reproduce it, and I could see the same problem. From what I can see, it is a problem of priorities. Both plugins implement the on_post_page callback. Apparently, it is crucial that the mkdocs-caption one is called first.

A temporary fix would be to ensure this manually by first declaring the mkdocs-caption plugin and then the mkdocs-with-pdf

plugins:
  caption: {}
  with-pdf: {}

Can you verify if that indeed fixes the issue for you?

If that solves the problem, I will see if I can juggle the priorities around to ensure this happens automatically.

Marioheld commented 6 days ago

Thank you a lot for your help. It does indeed work when changing the order of the plugins. I thought the order would not be relevant, but thats not the case.

tobiasah commented 5 days ago

I'm happy to hear that. I will put it on my agenda to look into it and see what priority is best suited. Getting the priorities right is kind of like winning the lottery.