LaTeX introduces non-existent excess space on pdf insertion - pdf

I try to insert a PDF file into my LaTeX document. It is properly cropped (by using the "Inkscape trick") and should easily be inserted without a problem.
LaTeX however, introduces a huge white space in the document which forces itself to create a "blank" extra page just to fit the PDF to the pages.
Just like this:
This is the code creating the problem.
\end{minipage}
... % Other code
\pagebreak
\subsection[Diagramm]{\uline{Diagramm}}
\vspace{-15pt}
\begin{figure}[H]
\centering
\includegraphics[height=0.98\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
\caption{ASMD-Diagramm}
\label{Fig ASMD-Diagramm}
\end{figure}
... % Other code
\pagebreak
Now I have another PDF which is inserted properly and exactly as expected.
I have tried the following already:
Recrop the PDF
Using the trim command of \includegraphics
Resizing
Using other file formats (all were not satisfactory)
To be honest I don't know much about LaTeX and am more of a beginner-intermediate user than someone who really know this stuff. But this bothers me and has bothered me for quite a long time already. Anyone has any idea on how to fix this or what I am doing wrong?
Thank you!

Solved the problem. As discussed with samcarter, the space around the pdf file in the document seems to have been too small, so LaTeX couldn't accomodate for the caption, header, etc.
By trial and error, I just changed the size from:
...
\includegraphics[height=0.98\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
...
to
...
\includegraphics[height=0.95\textheight]{Abbildungen/ASMD_Diagramm_v2_X.pdf}
...
and now it fits quite well on the page.

Related

Intellij is incorrectly formatting my `.yml` file, I cannot see any errors in my style settings. how can I fix it?

Intellij keeps formatting my spotbugs.yml file incorrectly, and so breaking the github action.
I cannot figure out why it's doing this:
It was working fine last week, I haven't made any changes to the formatting config, but now, every time I change focus from the file Intellij auto-formats like this, then saves it. How can I fix it?
The thing I don't get is what it's formatting to appears to be invalid yaml, right?
YAML has a syntax that makes it incompatible with indentation that is not 2 spaces. With 4 spaces, you have:
droggel:
jug:
- sequence item: with indentation
this line: isn't aligned to four spaces
nor are further indented lines:
if you indent relative four spaces
spam:
- same: problem
without: indenting the sequence item
This makes it hard for code formatters to get it right. Proper alignment would mean:
droggel:
jug:
- three spaces after the sequence item indicator.
that's horrible, nobody does that.
spam:
- alternatively this.
nobody does this either and it breaks
- - with nested sequences
I assume some bug in IntelliJ causes the formatter to be confused because of this. Generally it would be better to just use 2 space indentation which seems far more natural due to the problems described above. That should avoid confusing the formatter.

How can I replace a single PDF page using Imagemagick?

I have a multi-page PDF document, and I want a version of the document with one of the pages in the middle with a scanned-in copy, as I needed a physical signature in the document. How can I do this with ImageMagick? I'm aware that ImageMagick may not necessarily be the best tool for the job. However, the resulting PDF does not need to be high quality or a high fidelity copy, so it should be sufficient for my needs.
As a specific example, I have a 9 page my-file.pdf, and I want to create a copy of the PDF with the 8th page replaced with page-8.png. It looks like I should be able to achieve this goal with the convert tool, though it's not immediately obvious what the syntax would be. How can I achieve this goal?
If I merely wanted to append the new page to the end of the file, I know I can do the following:
convert my-file.pdf page-8.png output-file.pdf
However, this end up with the original pages 1-9, then the new page 8. What I actually want is to replace the original page 8 with the new page 8. My desired output is:
[original pages 1 - 7],[new page 8],[original page 9]
A specific page or range of pages can be specified using the bracket syntax with zero-based indexing. For instance, [8] will refer to the ninth page, and [0-6] to the first seven pages. Using this, a duplicate of the PDF with the 8th page replaced can be achieved as follows:
convert my-file.pdf[0-6] page-8.png my-file.pdf[8] output-file.pdf
As indicated in the question, as well as a comment, Imagemagick is not a great tool for this task, as it rasterizes the output of the PDF. An alternate solution that avoids this would be to use pdftk to replace the page. While the inserted page will still be an image, the replaced pages will not be rasterized.
First, save the scanned-in page as a PDF using an application capable of this. Then, use the pdftk cat operation to combine the PDFs:
pdftk A=my-file.pdf B=page-8.pdf cat A1-7 B A9 output output-file.pdf

Knitr Spin and Rmarkdown Fig.cap (figure caption). Producing double numbering pdf document

I am referring to this Suppress automatic figure numbering in pdf output with r markdown/knitr
which I don't think was answered fully.
Essentially, I am using knitr::spin and rmarkdown to produce word, pdf and html documents.
For word, there appears to be no numbering when one puts in
+fig.1, fig.cap = "Figure name"
You only get an output Figure name in the caption.
To solve that, I used captioner class.
figs = captioner("Figure")
That works fine for word
But I am not faced with rewriting the script for pdf document as the caption turns up as figure 1: figure 1: The name
I am using knitr::spin to actually generate the RMD document for forward outputs in word and pdf.
I am not sure I can use hooks in knitr::spin, as I have tried it as advertised but can't get it to work.
I also tried
header-includes: \usepackage{caption} \usepackage{float}
\captionsetup[table]{labelformat=empty}
\captionsetup[figure]{labelformat=empty}
as suggested somehere to surpress the prefix for pdf but I get errors from pandoc. It uses pdf2latex.
I am not sure how one would query the output format in knitr::spin to actually produce different actions for different formats which could be a solution although cumbersome.
Thank you so much for your help from a novice.

SPSS tables to latex (PDF) without creating an A4 page

This may be a stupid question, but I can't figure it out.
I have made some tables in SPSS. Now I want them over to my latex document.
What I do, it that I right-click the table in SPSS, and press export.
Here I can choose between PDF or .doc. BUT the PDF-file created, generates a file with the table on top of a page (A4 size, with "page 1" at the bottom). I do not want this, I only want the table.
example how it turns out:
Example how I want it to turn out:
If I export to word, I can further save as PDF, but same problem occurs.
Screenshot works, but does not give me the same picture-quality that I prefer.
Do anyone of you have any tips for me?
Thanks :)
Unfortunately SPSS does not provide native table export to Latex. It does provide table export to html and xls, which can post-hoc be converted to Tex tables. PDF output for everything forces to export the full page (very annoying for graphics as well) - but you probably don't want to insert the image of the table (you could crop the PDF if need be), but have a Tex table (in the same font) as your document anyway.
One thing I have done in the past to make the export to text tables with specific markup is to use the PRINT or LIST commands to print the text table to the output (or to a text file) that is closer to the end goal. In this NABBLE post I have some syntax that makes pandoc flavored pipe style markdown tables - it should be pretty clear how that same approach could be used for Tex tables (actually Tex tables should be much simpler).
Here is an example of some code using LIST to make a the markup closer to Tex tables.
DATA LIST FREE / Variable (A1) Mean Median (2F4.2).
BEGIN DATA
A 3.25 2.00
B 2.56 2.50
C 9.87 10.20
END DATA.
*Using LIST to make Latex style table.
STRING Mid (A1) End (A2).
COMPUTE Mid = "&".
COMPUTE End = "//".
LIST /VARIABLES = Variable Mid Mean Mid Median End.
And here is a screen shot of the produced output on my machine.
So here I would still have to copy-paste the text output into my Tex document, (and make the header row).
You can also use OMS to save designed items in a variety of formats, including XML and then use an xml-to-Latex tool such as xmltex. You could probably even generate such a conversion with XSLT from the XML.
From the Viewer, you could also retrieve the table with Python scripting and use a Python-based converter tool.

Is this Adobe Postscript?

I am doing a massive set of file conversions and several of them happen to be ".dat" files. When I open them I see that the first line is "%!PS-Adobe". Here's an example.....
%!PS-Adobe
^M%c$in
^M/c$in {72.0 mul} def
^M%DEFINE MARGINS
^M/C$LMAR .2 c$in def %LEFT MARGIN
^M/C$RMAR 8.4 c$in def %RIGHT MARGIN
^M/C$TMAR 10.8 c$in def %TOP MARGIN
^M/C$BMAR .2 c$in def %BOTTOM MARGIN
^M/C$CF /Courier def %saves /Courier as C$CF
etc...
Am I correct in assuming that these are indeed Adobe Postscript files and ** NOT ** PDFs?
How hard is it to convert these to PDF? I was thinking command line perl via ImageMagick or something but right now I'm a little stumped about what's been handed to me.
Thank you SO Much...
Janie
You can convert these to PDF using Ghostscript and the pdfwrite device, or for simplicity the ps2pdf script supplied with Ghostscript.
Yup, that's Postscript. A PDF would start with "%PDF". If the text "^M" is literally there like that, then it was created on a Mac and got screwed up being copied to or edited on other platforms. (Maybe it was when the sample was pasted into the S.O. edit box?) It defines some variables with dollar signs in their names, which makes it look funny.
%!PS-Adobe is the signature for conforming Postscript files. (Non-conforming Postscript can get by with %!.) The signature for PDF files is %PDF-.