-
Notifications
You must be signed in to change notification settings - Fork 93
Installation and Usage
On Mac, run the following:
brew install cairo pkg-config gobject-introspection
Then, you can
pip install svg2tikz
First, download the repository as a zip or git clone to a location on your machine. Now its time to find out where you can put this extension. Usually there is a custom location to add your own extensions. This can be found Edit > Preferences > System: User extensions
. More details can be found on the big black header block on this page. If everything went well then you should see this.
Play around with the settings to export your "tikz" image. However, there are some important values that you have to know better before using this extension to export "tikzfigures" with images inside.
Tikz is useful to draw vector type drawings in your latex document. However, tikz can be used for creating figures other than graphs or flowchart. Sometimes it is necessary to illustrate a figure using both vector shapes and raster images combined and also fit it inside a tight space. In such a scenario it is useless to scale a tikz image using \resizebox
command in your latex document. This completely defeats the purpose of using tikz figure as it will scale all the vector and text elements. The beauty of tikz is that when scaled it will scale the coordinates of the vector elements instead of blindly resizing them. However, in a tikzfigure with an image this will bring undesired results. So the Global Scale Value can be given the scale value (normalized) that will be used to scale the document and individually scale the images in each \includegraphics
. A variable \globalscale
is created in your latex document that can be fine-tuned to fit an image inside a tight space.
There are two other important settings Path comply for tikz mode
and Remove from path
. If the Path comply for tikz mode
is enabled then Remove from path
will come into effect while exporting your tikz document. A typical workflow is to add the images from your latex project as link (embed options is not supported yet) instead of embedding inside the SVG document inside Inkscape.
This way when exporting the tikzfigure all the images will be added under a \node
combined with \includegraphics
with a path that is absolute. This is not useful if you want to directly export and compile the tex document as the next step. Every time you make changes to SVG and export a tikzfigure you have to change all these absolute paths to relative paths to compile your full latex document. To avoid this manual labor you can say the part of the path that needs to be removed from the absolute path of the images. Remember this workflow assumes that /somedirectory/mylatexproject/
is your main directory that contains the tex file and the folder for images used in your latex document. For example,
-
/somedirectory/mylatexproject/mylatexproject.tex
- This is the main latex document -
/somedirectory/mylatexproject/Figures/E1.png
- An example image 1 used in your svg -
/somedirectory/mylatexproject/Figures/E2.png
- An example image 2 used in your svg
Ideally, the value for Path comply for tikz mode
is enabled and Remove from path
will have /somedirectory/mylatexproject/
. This way in your final exported tikz file can be used directly without making any changes.