Skip to content

latex export does not respect text centering if set on svg:tspan instead of svg:text

Summary:

I come here from: https://tex.stackexchange.com/questions/205659/ensure-position-of-latex-code-in-inkscape-graphic

The latex exporter does not seem to honour text alignment options as set with inkscape.

Here is an illustration (I converted back the output to svg to include it here, Firefox seems to have a bug and alters the shape of the circle, that disappear if you zoom in/out or open the file elsewhere and is not the issue at hand here):

input output
example.svg test.svg
example.svg test.pdf

The top circle is obviously not centered, the bottom one is much better.

Steps to reproduce:

  • Download example.svg (above)
  • Export it to pdf+latex: inkscape --export-type=pdf --export-latex example.svg
  • Run pdflatex or any other compiler with a barebones file including the output:
    % file test.tex
    \documentclass{article}
    \usepackage{graphicx}
    
    \begin{document}
    
    \input{example.pdf_tex}
    
    \end{document}
    pdflatex test.tex
  • Open test.pdf and observe how alignment options were not respected on the top circle.

What happened?

I used Inkscape to draw the circle, then to write some centered text. I then aligned both with "center and distribute".

On the second circle, I manually copied the style attributes text-align:center;text-anchor:middle on the parent <svg:text> tag instead of the child <svg:tspan> as Inkscape does it.

The latex exporter did not see the style attributes in the innermost tag of the top circle.

What should have happened?

Obviously, I shoudn't have to do that.

The exporter should apply the style from the child node if that works in Inkscape, I believe it only checks <svg:text>.

Version info

Inkscape 1.2 (dc2aedaf03, 2022-05-15)

    GLib version:     2.72.2
    GTK version:      3.24.34
    glibmm version:   2.66.4
    gtkmm version:    3.24.6
    libxml2 version:  2.9.14
    libxslt version:  1.1.35
    Cairo version:    1.17.6
    Pango version:    1.50.7
    HarfBuzz version: 4.3.0

    OS version:       Arch Linux

More reporters on the linked stackexchange thead, with more affected versions:

  • 0.48.0, 0.48.2, 0.48.5, 0.93pre3 were reportedly affected
  • A user reports the bug appeared between 0.48.4-1ubuntu3 and 0.48.4-3ubuntu2 for them.
Edited by Mayeul C.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information