u-fischer / newpax

12 stars 3 forks source link

Add support for sub directories containing the same file names #5

Closed koppor closed 3 years ago

koppor commented 3 years ago

When using the same file name for files in different sub directories, newpax creates uses the parsed content of the last file where writenewpax was used.

I think the reason is that the .newpax files are created in the directory of the main .tex file instead of creating them next to the .pdf file included.

test.tex

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress}
\documentclass{article}
\directlua{require("newpax")}
\directlua
{
newpax.writenewpax("doc-input3")
newpax.writenewpax("graphics/doc-input3")
}

\usepackage{pdfpages,xcolor}
\usepackage{hyperref}
\hypersetup{linkbordercolor=blue}
\usepackage{newpax}

\begin{document}
\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{doc-input3.pdf}

\includegraphics[scale=0.5,trim=4cm 15cm 8cm 3cm,clip,page=1]{graphics/doc-input3.pdf}
\end{document}

doc-input3.tex

% !Mode:: "TeX:UTF-8:Main"
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress}
\documentclass{article}
\usepackage{hyperref}

\hypersetup{pdfborderstyle={/S/U/W 1},
   pdfauthor=Author,pdftitle=title,pdfcreator=creator}

\ExplSyntaxOn
\pdfmanagement_add:nnn {Page} {TrimBox}{[0~0~300~350]}
\pdfmanagement_add:nnn {Page} {BleedBox}{[0~0~300~350]}
\ExplSyntaxOff

\begin{document}
Look for MADR at \url{https://adr.github.io/madr/}
\end{document} 

graphics/doc-input3.tex

% !Mode:: "TeX:UTF-8:Main"
\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress}
\documentclass{article}
\usepackage{hyperref}

\hypersetup{pdfborderstyle={/S/U/W 1},
   pdfauthor=Author,pdftitle=title,pdfcreator=creator}

\ExplSyntaxOn
\pdfmanagement_add:nnn {Page} {TrimBox}{[0~0~300~350]}
\pdfmanagement_add:nnn {Page} {BleedBox}{[0~0~300~350]}
\ExplSyntaxOff

\begin{document}
Look for ADR at \url{https://adr.github.io/}
\end{document} 

typeset

cd graphics
lualatex doc-input3
cd ..
lualatex doc-input3
lualatex test

result

The first link in test.pdf points to https://adr.github.io/ instead of https://adr.github.io/madr/. Also the string madr/ is not hyperlinked at all.

u-fischer commented 3 years ago

newpax should also be able to handle files found per kpathsea, so writing the newpax file into the source directory is not really an option.

With lualatex you could move the luacall before the relevant graphics, with the other engines one will probably need some option to change the name or the extension.

koppor commented 3 years ago

Then it's just a documentation issue 🎉