DEV Community

Cover image for Fixing SVG Figure Alignment Issues Between Inkscape and Overleaf
Tahzib Mahmud Rifat
Tahzib Mahmud Rifat

Posted on

Fixing SVG Figure Alignment Issues Between Inkscape and Overleaf

Fixing SVG Figure Alignment Issues Between Inkscape and Overleaf

When preparing a research paper, figures often look perfect in Inkscape but shift after being uploaded to Overleaf. This happened to me while preparing a gas-cost sensitivity chart for a blockchain-based e-voting system.

The chart looked fine in Inkscape, but after adding it to Overleaf, some labels moved out of position. The bar values shifted, the log-scale tick labels did not align properly, and the rotated function names looked different from the original SVG.

This post explains how I diagnosed the page layout, calculated the correct figure size, and fixed the SVG rendering issue.


1. Finding the exact page layout in Overleaf

The first step was to find the actual page size, text width, margins, and font size used by the LaTeX class.

In Overleaf, I temporarily added a layout-debug block in the preamble. After recompiling, the values appeared in the raw log file.

The important values were:

Paper width  = 546.29291 pt
Paper height = 745.4622 pt
Text width   = 468.3324 pt
Text height  = 637.34175 pt
Font size    = 10 pt
Baseline skip = 12 pt
Left margin  = 38.98026 pt
Right margin = 38.98026 pt
Top text margin = 54.06023 pt
Enter fullscreen mode Exit fullscreen mode

After converting the values to millimeters, the final layout became:

Page size:
Width  = 192 mm
Height = 262 mm

Text area:
Width  = 164.6 mm
Height = 224 mm

Margins:
Left   = 13.7 mm
Right  = 13.7 mm
Top    = 19 mm
Bottom = 19 mm
Enter fullscreen mode Exit fullscreen mode

So the inner writing area of the paper was:

164.6 mm × 224 mm
Enter fullscreen mode Exit fullscreen mode

This was the most important value for figure placement.


2. Understanding figure width in LaTeX

In LaTeX, this command:

\includegraphics[width=0.9\textwidth]{figure}
Enter fullscreen mode Exit fullscreen mode

does not mean “use 90% of the original image width.”

It means:

Use 90% of the paper text width.
Enter fullscreen mode Exit fullscreen mode

Since my text width was:

164.6 mm
Enter fullscreen mode Exit fullscreen mode

then:

0.9 × 164.6 mm = 148.1 mm
Enter fullscreen mode Exit fullscreen mode

So the final figure width in the PDF would be:

148.1 mm
Enter fullscreen mode Exit fullscreen mode

This also means the figure would leave:

164.6 mm - 148.1 mm = 16.5 mm
Enter fullscreen mode Exit fullscreen mode

of empty space inside the text area.

Since the figure is centered, the blank space becomes:

Left blank space  = 8.25 mm
Right blank space = 8.25 mm
Enter fullscreen mode Exit fullscreen mode

The figure starts at:

Left page margin + blank space
= 13.7 mm + 8.25 mm
= 21.95 mm
Enter fullscreen mode Exit fullscreen mode

and ends at:

21.95 mm + 148.1 mm
= 170.05 mm
Enter fullscreen mode Exit fullscreen mode

So the figure should sit horizontally between:

X = 21.95 mm and X = 170.05 mm
Enter fullscreen mode Exit fullscreen mode

3. Setting the SVG size in Inkscape

After calculating the figure width, I opened the SVG in Inkscape.

For a figure inserted with:

\includegraphics[width=0.9\textwidth]{figure}
Enter fullscreen mode Exit fullscreen mode

I used:

Figure width = 148.1 mm
Enter fullscreen mode Exit fullscreen mode

The height should not be forced manually unless the aspect ratio is locked. Otherwise, the figure may stretch.

The safer method is:

  1. Select the figure.
  2. Turn on the lock icon for aspect ratio.
  3. Set the width to 148.1 mm.
  4. Let Inkscape automatically adjust the height.

For my chart, the height was around:

73 mm
Enter fullscreen mode Exit fullscreen mode

So the final figure size was approximately:

148.1 mm × 73 mm
Enter fullscreen mode Exit fullscreen mode

4. Why the SVG looked different in Overleaf

The main issue appeared after uploading the SVG to Overleaf.

In Inkscape, everything looked correct. But in Overleaf:

  • bar value labels shifted,
  • log-scale labels moved,
  • rotated x-axis labels changed position,
  • some text spacing became inconsistent.

This happened because SVG text rendering is not always consistent between Inkscape and LaTeX/Overleaf. Overleaf may use a different SVG conversion engine, font rendering method, or baseline calculation.

This is especially common when the SVG contains:

  • rotated text,
  • superscripts,
  • log-scale tick labels,
  • custom fonts,
  • tightly positioned labels.

So the problem was not the chart itself. The problem was that the text was still live editable text inside the SVG.


5. The fix: convert text to paths

The solution was to convert the text into vector paths before uploading the SVG to Overleaf.

In Inkscape:

Select all → Path → Object to Path → Save as Plain SVG
Enter fullscreen mode Exit fullscreen mode

Step-by-step:

  1. Open the final SVG in Inkscape.
  2. Press Ctrl + A to select everything.
  3. Go to:
Path → Object to Path
Enter fullscreen mode Exit fullscreen mode
  1. Save a copy as:
Plain SVG
Enter fullscreen mode Exit fullscreen mode

After this, the text is no longer treated as editable font text. It becomes vector shapes.

That means Overleaf cannot replace the font, move the baseline, or change the rotated labels.

The visual appearance becomes stable.


6. Recommended workflow

The best workflow is to keep two versions of the figure:

figure_editable.svg
figure_final_plain.svg
Enter fullscreen mode Exit fullscreen mode

Use the editable SVG for future changes.

Use the plain SVG in Overleaf.

The editable version keeps text editable in Inkscape. The final plain version is safer for LaTeX submission.


7. Adding the final SVG to Overleaf

After saving the fixed figure as Plain SVG, upload it to the images folder in Overleaf.

Then include it like this:

\begin{figure}[htbp]
    \centering
    \includegraphics[width=0.9\textwidth]{images/gas_cost_sensitivity_chart_final.svg}
    \caption{Transaction cost of the proposed system's smart-contract functions under different gas-price scenarios.}
    \label{fig:gas_cost_sensitivity}
\end{figure}
Enter fullscreen mode Exit fullscreen mode

If SVG support is unstable in your Overleaf setup, export the final figure as PDF instead and use:

\includegraphics[width=0.9\textwidth]{images/gas_cost_sensitivity_chart_final.pdf}
Enter fullscreen mode Exit fullscreen mode

PDF is often safer for journal submission.


8. Useful final checklist

Before submitting a paper, check the following:

1. Find the actual text width from Overleaf logs.
2. Decide whether the figure should be \textwidth or 0.9\textwidth.
3. Calculate the final figure width.
4. Set the figure width in Inkscape.
5. Keep aspect ratio locked.
6. Use readable font sizes.
7. Convert text to paths before final export.
8. Save as Plain SVG or PDF.
9. Upload to Overleaf.
10. Recompile and check the final PDF carefully.
Enter fullscreen mode Exit fullscreen mode

For my case:

Text width = 164.6 mm
Figure width = 0.9 × 164.6 mm = 148.1 mm
Approximate figure height = 73 mm
Main paper font size = 10 pt
Enter fullscreen mode Exit fullscreen mode

Final thought

SVG is excellent for editing figures, but it can behave unpredictably in LaTeX if the text remains editable. For final paper submission, converting text to paths is a simple and reliable fix.

The key idea is:

Edit as SVG.
Finalize as Plain SVG or PDF.
Use path-converted text for stable rendering.
Enter fullscreen mode Exit fullscreen mode

This small workflow saved me from misaligned chart labels and made the final figure consistent between Inkscape and Overleaf.

Top comments (0)