diff --git a/lib/LaTeXML/Post/XSLT.pm b/lib/LaTeXML/Post/XSLT.pm index 385269cd88..0cda27a5cb 100644 --- a/lib/LaTeXML/Post/XSLT.pm +++ b/lib/LaTeXML/Post/XSLT.pm @@ -76,7 +76,16 @@ sub process { if (my $icon = $params{ICON}) { # Hmm.... what type? could be various image types $params{ICON} = '"' . $self->copyResource($doc, $icon, undef) . '"'; } + + # change directory so that files created by are relative to the destination + my $destdir = $doc->getDestinationDirectory; + my $orig_cwd = pathname_cwd(); + pathname_chdir($destdir); + my $newdoc = $doc->new($$self{stylesheet}->transform($doc->getDocument, %params)); + + pathname_chdir($orig_cwd); + return $newdoc; } my $RESOURCE_INFO = { # [CONSTANT]