惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
MyScale Blog
MyScale Blog
博客园 - Franky
The Cloudflare Blog
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
博客园 - 聂微东
WordPress大学
WordPress大学
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
The Blog of Author Tim Ferriss
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
Google DeepMind News
Google DeepMind News
P
Proofpoint News Feed
Martin Fowler
Martin Fowler
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
腾讯CDC
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
博客园 - 【当耐特】
美团技术团队
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Fixing SVG Figure Alignment Issues Between Inkscape and O...
Tahzib Mahmu · 2026-05-01 · via DEV Community

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.