GithubHelp home page GithubHelp logo

Text scaling issues about svg HOT 17 OPEN

mrpiggi avatar mrpiggi commented on August 29, 2024 1
Text scaling issues

from svg.

Comments (17)

pietrocolombo avatar pietrocolombo commented on August 29, 2024 8

I solved it like this:

\begin{figure}[ht]
    \centering
    \includesvg[inkscapelatex=false, scale=0.6, keepaspectratio]{plot/number_trip_week_day.svg}
    \caption{caption}
\end{figure}

from svg.

pietrocolombo avatar pietrocolombo commented on August 29, 2024 6

Before:
before
After (inkscapelatex=false):
after

from svg.

MayeulC avatar MayeulC commented on August 29, 2024 1

@major-mayer Your title is probably not centered. It's actually the text-anchor css property that has to be set to middle on the parent xml element. There is actually an inkscape export bug related to this: https://gitlab.com/inkscape/inkscape/-/issues/1170

Long story short: open the svg in inkscape, press "T" to enter text edit mode, click on your title, then in the toolbar, select the "center" option. Do not select text while doing so, or it will set the alignment to the wrong xml element, and it will get ignored during export.

You'll see a small square box in inkscape, positioned at the middle of your text box. That is the anchor, text will be centered around it. Move the title around to the desired position.

Regarding the font size, you can probably prefix it with \large in the svg, though I haven't tried it.

from svg.

schtandard avatar schtandard commented on August 29, 2024 1

Let me give my two cents regarding this: The main advantage of using inkscapelatex (besides being able to use macros and format math) is that the text font and size in the image will match the rest of the document. If \tiny text is still too large for the image, this is a sign that the image needs to be reworked, as \tiny is already too small to be easily readable. I regard the fact that it is non-trivial to realize microscopic text to be a feature, not a bug. (This, by the way, is not really a feature of the svg package but of LaTeX itself. All the methods to realize those font sizes that work in the rest of the document still work with svg.)

Thus, I would vote against including somethign like \includesvgextracted in this package. Hacks like this are not good practice and should thus not be encouraged. If someone really wants to use it, they can explicitely introduce the hack in their document.

Now, the fact that many people are confused about how text in the svg file translates to the typeset text in their document may suggest that this should be documented in a more visible manner by incorporating the relevant information from svg-inkscape (which is already linked to from the documentation). Or maybe just referencing it more explicitly ("for a detailed description of how text in the svg file translates to text in the typeset document see there") would be enough?

from svg.

mrpiggi avatar mrpiggi commented on August 29, 2024 1

I totally agree with you there. I will place a clear notice at the beginning of the documentation for the next release. I had already started working on v2.03 a long time ago. Due to lack of time, however, the work has come to a complete standstill and at the moment I cannot make any reliable statement as to when I will be able to continue working on it.

from svg.

mrpiggi avatar mrpiggi commented on August 29, 2024

If I get you right you are trying to extract a large picture, where the text actually is in the right size but the resulting image has to be scaled down for inclusion in the document, right? Well, currently not an easy task but could be done with something like

\documentclass{scrartcl}
\ifpdftex{
  \usepackage[T1]{fontenc}
}{
  \usepackage{fontspec}
}
\usepackage{svg}
\usepackage{svg-extract}

\begin{document}
\section*{This is a test}
\begin{figure}
\centering
\includesvg[%
  exclude,
  extractpath=basedir,extractname=filename,%
  pretex=\Huge,
  extractwidth=50cm
]{svg-example}
\IfFileExists{svg-example_svg-tex-extract.pdf}{%
  \includegraphics[width=\textwidth]{svg-example_svg-tex-extract.pdf}%
}{}
\end{figure}
\end{document}

As you can see, this is a combination of using \includesvg for extraction and \includegraphics afterwards.

I will try to create a new command \includesvgextracted but this will probably will last some time as I have to think about how this could be implemented regarding for example the handling of passed parameters, extracted file type and more.

Included SVG file
Result

from svg.

mitar avatar mitar commented on August 29, 2024

Awesome!

from svg.

mitar avatar mitar commented on August 29, 2024

Just to give you an example which was tricky:
pipeline-test.zip

from svg.

mitar avatar mitar commented on August 29, 2024

I think this works when image is not really really huge.

from svg.

mitar avatar mitar commented on August 29, 2024

Try with an example I attached above.

from svg.

pietrocolombo avatar pietrocolombo commented on August 29, 2024

With the example I obtain this:

\documentclass{scrartcl}
\ifpdftex{
  \usepackage[T1]{fontenc}
}{
  \usepackage{fontspec}
}
\usepackage{svg}
\usepackage{svg-extract}

\begin{document}
\section*{This is a test}
\begin{figure}
  \centering
  \includesvg[inkscapelatex=false, scale=0.13]{pipeline-test.svg}
  \caption{}
\end{figure}
\end{document}

Screenshot 2020-01-20 at 21 04 10

This is without inkscapelatex=false

Screenshot 2020-01-20 at 21 04 42

from svg.

mitar avatar mitar commented on August 29, 2024

Oh, yes, but with inkscapelatex=false then one cannot enter math formulas and stuff for text, no?

from svg.

pietrocolombo avatar pietrocolombo commented on August 29, 2024

I have never tried with math formulas

from svg.

mitar avatar mitar commented on August 29, 2024

I mean, this is the mean reason why to use this package, no? Otherwise I can just export SVG to PDF myself and embed it as PDF into my LaTeX document? If I understand correctly, setting inkscapelatex=false does that?

from svg.

mrpiggi avatar mrpiggi commented on August 29, 2024

I mean, this is the mean reason why to use this package, no? Otherwise I can just export SVG to PDF myself and embed it as PDF into my LaTeX document? If I understand correctly, setting inkscapelatex=false does that?

On the whole, yes, but with a few little things added (like the path search or the automatic invocation of the Inkscape export after an update of the SVG file).

from svg.

major-mayer avatar major-mayer commented on August 29, 2024

I have a problem that seems related to this issue.
If i include a SVG using the option inkscapelatex=false the chart looks like this:
grafik

If i use pretex=\relscale{0.55} instead, the result looks more or less okay, but the title of the chart is far too small and moved to the left ...?
grafik

If i completely remove the pretex option the font is way too large:
grafik

I guess for now i just use the inkscapelatex=false, but it's not perfect, because the font type doesn't match with the rest of the document.
If you got other ideas please tell me

from svg.

mrpiggi avatar mrpiggi commented on August 29, 2024

Thanks @MayeulC for the info. There was a similar bug report on tex.se some weeks ago. I will place the appropriate notices in both places.

from svg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.