TransWikia.com

Unecessary white space around .svg figure

TeX - LaTeX Asked by cephlot on January 4, 2021

I have to write a report for school and I need to include a UML class diagram for a Java assignment. I am using the PlantUML integration within IntelliJ to create a beautiful diagram without any whitespace around it. But when I put it into my LaTeX report I get So much white space that it’s hard to read…

This is my code to include the .svg figure:

begin{figure}[h]
    includesvg[width=textwidth, inkscapelatex=false]{uml}
    caption{Ett UML-diagram över klasserna i systemet.}
    label{fig:uml}
end{figure}

MWE:

documentclass[11pt, titlepage, oneside, a4paper]{article}
usepackage{graphicx}
usepackage{svg}
usepackage{float}

begin{document}
    begin{figure}[h]
        fontsize{11}{13}selectfont
        includesvg[width=columnwidth, inkscapelatex=false]{uml}
        caption{Ett UML-diagram över klasserna i systemet.}
        label{fig:uml}
    end{figure}
end{document}

Result:

enter image description here

This is my goal. I’m using a .png here, which is lower quality and doesn’t store vectors. As you can see the image doesn’t have unnecessary whitespace above the caption:

enter image description here

One Answer

I would've added this as a comment but my reputation is too low to comment:

What I end up doing on such occasians is one of the following things:

  • Use an image editor to manually remove any unwanted whitespace before including the svg in LateX (e.g. Inkscape). Even if you think there is none take a look and verify it.
  • Use an online alternative for cleaning up your svg file (e.g. https://jakearchibald.github.io/svgomg/) even though I do not know if this exact one fulfils your purpose
  • If you can export your diagram as a cropped pdf that usually is another way to try remove the unwanted whitespace.
  • Try any other vector format which you can export to from your framework and try including that in your report.

I know that these are not the "best" solutions and there is probably a native LateX solution but I just wanted to give a little help.

Answered by Robin Schmidt on January 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP