1

I am working in a file document.org, and I have an embedded image, the second page of a file images.pdf.

The org-file shows this correctly (with the code shown below). However, upon exporting it to tex (let's say document.tex), the tex does not indicate that \includegraphics{} should use the second page.

#+attr_org: :width 80% :page 2
#+attr_latex: :width 0.95\textwidth
#+caption: My Caption
[[./images.pdf]]

This shows (in the buffer) the second page of images.pdf. But if I export the org file to tex or pdf, the resulting tex has:

...
\usepackage{graphicx}
...
\begin{document}
...
\begin{figure}[htbp]
\centering
\includegraphics[width=0.95\textwidth]{./images.pdf}
\caption{My Caption}
\end{figure}
...
\end{document}

Which leads to a pdf showing the first page of images.pdf. A natural thing to try was changing the #+attr_latex... line for

#+attr_latex: :width 0.95\textwidth :page 2

But it does nothing. How can I achieve this without cutting images.pdf into many individual files?

Workaround

I was pointed out that ox-latex does know about pages (to export), but the way you tell it about pages is not in #+attr_org, which in my opinion is weird...

#+attr_org: :width 80% :page 2
#+attr_latex: :width 0.95\textwidth
#+caption: My Caption
[[./images.pdf::2]]

Note that the only difference is the ::2 at the end of the filename. The odd thing is that this is telling ox-latex to "export using the second page of images.pdf", but #+attr_org is the one saying "show me here the second page of images.pdf".

So I have to manually keep :page 2 and ::2 synchronized.

5
  • This might help.
    – NickD
    Oct 31, 2023 at 15:23
  • I am indeed using graphicx, and if I modify the tex file, to add the , page=2, it works well. But I cannot get the page number argument by just exporting from org.
    – onlycparra
    Oct 31, 2023 at 21:02
  • 1
    If worse comes to worst, you can use a filter to modify the TeX output. But it may be possible to coerce the exporter to do it - I am looking into that, but I don't know how yet.
    – NickD
    Oct 31, 2023 at 21:06
  • 1
    Until this works, could put the entire \includegraphics TeX source in a LATEX block?
    – mankoff
    Nov 6, 2023 at 3:06
  • hey, thanks. That is certainly an option. However, I found out that there is an easier workaround. I am editing my question right now. Still not ideal (because you need to keep both numbers manually synchronized), but it is not much overhead.
    – onlycparra
    Nov 7, 2023 at 4:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.