-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If Markdown input contains image, then \includepdf{some.pdf}
output scales down far too much.
#2856
Comments
This seems more like a LaTeX issue. Pandoc is really just generating a .tex file, then running that through LaTeX. You can generate the tex and have a look:
If you can tell us what exactly is wrong with the tex file generated, we might be able to fix it in pandoc... |
Thanks for the tipp, mb21. However, I did this already, but couldn't see what may be causing it. Hence I supplied a step-by-step instruction with an MWE so somebody more knowledgeble than may may look into the Pandoc and the LaTeX side of the process. (My PDF source code reading skills are good enough however to analyze what's going on in there -- see further below.) My bet still is on the LaTeX code Pandoc generates. There may be a $something in Pandoc's LaTeX template that needs modification -- like order of loading for Because I cannot be the first person to ever use this function, and I remember it used to work for me. So it must be some new bug introduced alongside the recent improvements/changes to the LaTeX template or the added image attributes... I cannot complete the analysis, but I can give you these hints: LaTeX codeHere are the contents of the "only PDF figure included" LaTeX document code: \includepdf{mwe-in.pdf} Here are the contents of the "PDF figure plus pixel image included" LaTeX document code: \begin{figure}[htbp]
\centering
\includegraphics{mwe-in.png}
\caption{}
\end{figure}
\includepdf{mwe-in.pdf}
And here is what the "PDF plus image" LaTeX pre-amble has added when compared to the "PDF-include only" LaTeX preamble. It has added, in lines 29-37: 29 \usepackage{graphicx,grffile}
30 \makeatletter
31 \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
32 \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
33 \makeatother
34 % Scale images if necessary, so that they will not overflow the page
35 % margins by default, and it is still possible to overwrite the defaults
36 % using explicit options in \includegraphics[width, height, ...]{}
37 \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} There is no other difference in the pre-amble. If I just comment out or remove lines 30-37 and compile this modified LaTeX to PDF, both pages look "saner" (however, both images no longer honor the page margins). If you just comment out or delete line 37 (WARNING: I don't know what I'm doing!), so that it reads: 37 % \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
PDF codeNow for the PDF code... I'll pinpoint to the differences which cause the mwe-image-plus-pdfinclude-is-buggy.pdf to render differently as compared to mwe-pdfinclude-only.pdf. First, unpack the compressed streams with the help of the
Then look at the PDF code in an editor. Line numbers 169-183 read: %% Contents for page 1
%% Original object ID: 11 0
13 0 obj
<<
/Length 14 0 R
>>
stream
1 0 0 1 301.85 391.02 cm
q
.00932 0 0 .00932 0 0 cm
q
1.78056 0 0 1.78056 0 0 cm
q
1 0 0 1 0 0 cm
/Im5 Do
Fixing it on the PDF sideSo, you can do the following:
So the question remains:
|
The default latex template contains:
I'd suggest using a custom template without these lines. See |
@jgm: Due to what I described in my comment from April 17 13:00 UTC, I'm using a different template already (well, it's the default one for 1.17.3, but with line 131 commented out). That's for now good enough, because it shows me roughly the state of my draft document. However, as I wrote in the comment above...
So, yes, _this line does make the difference_, as I said above already... I have to correct point 1. above, though. The _appearance of the raster images also changes_. I just didn't initially notice with the one I mainly tested it. When I use a different (esp. larger) test image, the difference is better visible. |
So far the only thing you can do is to reset these settings for each
(Hope this works. I cannot test it, since I do not have a recent pandoc install.) |
@AndreasMatthias: Thanks for your input. When I looked in the pdfpages manual, it didn't mention What does the exclamation mark do in Also, I cannot follow your argument (but then, I know next to nothing about LaTeX or TeX): "if you change the default options for You may be right in theory -- but to me it looks like the default options for |
The exclamation mark is the default value, meaning that the picture should not be scaled in this direction. Anyway, after pondering this issue I think that |
Thank you for your patient explanation. When I (selectivly) studied the pdfpages manual (which I didn't fully comprehend anyway -- I'm a LaTeX user only by way of using Pandoc) I didn't notice Also thanks for your "exclamation mark" -- this might be useful for me in the future. I have to test it. 👍 Also thank you very much for your awesome work on pdfpages too :-) 👍 |
Version 0.5f of pdfpages fixes this issue. The new version is already installed on CTAN and should be available on other CTAN mirrors soon. |
Great, @AndreasMatthias ! I'm looking forward to take it to a testdrive with my current document creating project. |
Steps to reproduce:
Select a simple, 1-page PDF from your stock for testing.
If you don't have one handy, use this Ghostscript command to create one:
This should have created a PDF,
mwe-in.pdf
.Select a simple PNG or JPEG image from your stock for testing.
If you don't have one handy, use this ImageMagick command to create one:
This should have created a PNG image,
mwe-in.png
.Create a first simple Markdown file,
mwe1.md
, with this content:You can achieve this by running this command in a terminal:
Create a second simple Markdown file,
mwe2.md
with this content:You can achieve this by running this command in a terminal:
Last, run these commands to create different PDF files from the two Markdown input files:
Results:
mwe-image-only.pdf
is a one page PDF showing the imagemwe-in.png
.This output is as expected.
mwe-pdfinclude-only.pdf
is a one page PDF which included the PDFmwe-in.pdf
as a page.This output is as expected.
mwe-image-plus-pdfinclude-is-buggy.pdf
is a two page PDF where one page shows the imagemwe-in.png
, while the other page shows the included PDFmwe-in.pdf
. However, the included PDF is scaled down to an extremely small size (allmost invisible).The scaling-down of the included PDF is totally un-expected.
More info
My Pandoc version is 1.17.0.3 (on OS X).
It doesn't help to include pdfpages options into the header-includes, such like
"\usepackage[noautoscale=true]{pdfpages}"
or"\usepackage[fitpaper=true]{pdfpages}"
.I'm aware that this may be a LaTeX bug, but I'm not sure. Hence I report it here first.
The text was updated successfully, but these errors were encountered: