shg / org-inline-pdf.el

Inline PDF previewing for Org
GNU General Public License v3.0
48 stars 8 forks source link

Exporting org with image showing the 2nd page. #13

Open onlycparra opened 11 months ago

onlycparra commented 11 months ago

I am not sure if this is within the scope of org-inline-pdf, it seems it could be the export engine of org-mode. In any case, here it goes:

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:

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

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.

shg commented 11 months ago

Hi @onlycparra

Org-inline-pdf currently does not do anything for latex export. It is handled by ox-latex included in the org distribution. the :page attribute is an extension of org-inline-pdf's own, so ox-latex silently ignores it.

It is actually possible to specify the page of a linked multi-page PDF for exporting. Add double colon and the page number to the link, like [[./images.pdf::2]], and ox-latex will add page=2 as an option of includegraphics in the exported latex file.

I understand that it is confusing that the way org-inline-pdf specifies the page is different from the ox-latex's. I will think of a solution to this problem. As a current workaround, you can specify the page for both inline preview and export by specifying both the :page attribute and the ::n.