Graphics, Figures & TablesLatex rendered text in SVG images looks thick

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Deve
Posts: 8
Joined: Mon May 18, 2015 10:12 am

Latex rendered text in SVG images looks thick

Post by Deve »

Hi all,

I create SVG figures with Inkscape containing some Latex rendered text and math. This works quite well, in general. However, the Latex rendered text in the SVG images looks thicker/fatter than the normal running text. My workflow is
  • Create drawing with Inkscape
  • In Inkscape, insert Latex rendered text using the plugin Textext. Textext uses pdflatex and pdf2svg in the background to convert Latex code to SVG elements.
  • Insert the SVG file into the Latex document with the graphicx package
  • Create the final document with pdflatex.
Here is an MWE, the required image files are attached.

Code: Select all

\documentclass[a4paper]{scrartcl}
\usepackage{graphicx}

\begin{document}
\begin{tabular}{|c||c|}
\hline 
Latex & Inkscape+Textext\tabularnewline
\hline 
\hline 
This is a phrase & \includegraphics{phrase}\tabularnewline
\hline 
$x=a^{2}(t)$ & \includegraphics{math}\tabularnewline
\hline 
\end{tabular}
\end{document}
In the compiled output the difference between the "normal" Latex text and the according SVG images is barely visible on screen. On a printout, however, the difference is much more prominent. To demonstrate this I have attached a scan of a more complex example:
Scanned PDF printout showing the difference between Latex and SVG
Scanned PDF printout showing the difference between Latex and SVG
scan_mod.jpg (74.22 KiB) Viewed 12672 times
The magnified regions show Inkscape/Textext created math and normal Latex. Its clearly visible that the Latex text contained in the figure looks fatter. It would be nice if the difference was not visible. This would also increase readability for very small texts.

I realize that it might be too much to ask that after pdflatex > pdf2svg > svg2pdf > pdflatex the output should look exactly the same as after a simple pdflatex run. ;) But I thought I still ask here if someone has an idea about how to alleviate this problem?

Please note that I don't look for solutions like PDF + Latex code export from Inkscape. I would like to arrange the Latex text directly in Inkscape. Other ideas? Thanks in advance!
Attachments
svg_images.zip
Contains phrase.svg and math.svg
(6.05 KiB) Downloaded 308 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Latex rendered text in SVG images looks thick

Post by Stefan Kottwitz »

Hi Deve!

I would create such images using TikZ. The TikZ gallery shows some what's possible.

Both here and also on TeXwelt.de (in German!) we gladly support TikZ. Have a quick look: TikZ TeXwelt examples.

Stefan
LaTeX.org admin
Deve
Posts: 8
Joined: Mon May 18, 2015 10:12 am

Re: Latex rendered text in SVG images looks thick

Post by Deve »

Hi Stefan,

thanks for your reply. I'm aware of Tikz and I use it for plots (Pgfplots, actually). I know it's a very powerful and versatile tool and allows creating high quality drawings. But personally, I find it too time consuming and abstract for an efficient workflow. Additionally, I've almost finished all drawings of my work already. I won't start to convert them to Tikz now ;)

Deve
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Latex rendered text in SVG images looks thick

Post by Stefan Kottwitz »

You could convert SVG to TikZ (pgf) and use it quite natively, so the font should be ok. I did it here: Tux in TeX with TikZ.

Stefan
LaTeX.org admin
Deve
Posts: 8
Joined: Mon May 18, 2015 10:12 am

Re: Latex rendered text in SVG images looks thick

Post by Deve »

That sounds interesting, I might give it a try. However, I would have to remove all text and math elements from the SVG file first and later readd them to the Tikz file "by hand". I'm afraid this would also involve fiddling around a lot with text positions, which is what I wanted to avoid in the first place by inserting rendered Latex text and placing it visually.

But it's good to know that such a solution exists. Inkscape supports native Pstricks export, but not Tikz export.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: Latex rendered text in SVG images looks thick

Post by Stefan Kottwitz »

You could check if it already looks ok after conversion to pgf/TikZ code. Hopefully there's no "bold" command introduced, and even if, it's easy to remove or to disable.

You would have native LaTeX commands, not a PDF or SVG image, that's why I think you would have the original LaTeX font used and not some converted thing.

Stefan
LaTeX.org admin
Deve
Posts: 8
Joined: Mon May 18, 2015 10:12 am

Re: Latex rendered text in SVG images looks thick

Post by Deve »

The Textext plugin I use converts Tex code into an SVG path and inserts this path to the SVG/Inkscape document. The original Tex code is stored somewhere, so that it can be changed later, but the object itself is a path created with pdf2svg. If I convert this SVG to Tikz, it won't contain the original Tex code, I bet.
Brian_D
Posts: 28
Joined: Thu Apr 23, 2015 12:01 pm

Re: Latex rendered text in SVG images looks thick

Post by Brian_D »

Perhaps save your SVG file as a PDF then insert the PDF version into the LaTeX. Be sure to use the .pdf suffix so that the correct file is included.
Brian Dunn
BDTechConcepts.com
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Latex rendered text in SVG images looks thick

Post by Johannes_B »

Usually the file ending isn't inportant. LaTeX picks the fist picture with a name that matches the basename. Using \DeclareGraphicsExtension you can define the order of preference.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply