serhii.net

In the middle of the desert you can say anything you want

04 Jul 2024

Cropping PDF files with Latex and inkscape

Context: in a paper, using PDF graphics is much better than e.g. PNG, because antialiasing (230628-1313 Saving plots matplotlib seaborn plotly PDF). Assume you need to crop one, and taking a PNG screenshot won’t cut it, because it would defeat the entire purpose.

LaTeX

TL;DR: in \includegraphics, trim=left bottom right top (in cm)

positioning - How can I crop included PDF documents? - TeX - LaTeX Stack Exchange:

includegraphics[clip, trim=0.5cm 11cm 0.5cm 11cm, width=1.00\textwidth]{PDFFILE.pdf}

BUT! If I’m ever in this situation, inkscape can really nicely open a PDF and export only the selected things, also as PDF.

Inkscape (much better)

  1. When importing, “Replace text with closest available font”
    • e.g. OpenSans gets matched to Open Sans and it works out usually
    • the full list of fonts is shown in the import window
  2. Select the part I want to crop
    1. or create a shape over it and select that shape or something
  3. Export selection only as PDF; play with export settings as well if needed but for me the defaults worked this time

And either way

… test the results by downloading the PDF from overleaf and opening it locally, because antialiasing w/ imported vector pictures can be broken from within the preview window.

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus