Importing SVG file into Overleaf with *.pdf_tex results in searching for *.pdf instead - svg

I'm trying to write a paper in Overleaf and trying to follow Gilles Castel's format of importing SVG files into my TeX document. I understand he used VIM to program his TeX documents, but the fundamental should be the same. However, when compiling the file I'm trying to include is recognized as a *.pdf instead of *.pdf_tex, which results in a blank figure box to appear in my document with the text which is included in the figure, but not any of the graphic art drawn.
Below is a minimal reproducible example of how I attempted to import the image.
\documentclass{article}
\usepackage{import}
\usepackage{pdfpages}
\newcommand{\incfig}[1]{%
\def\svgwidth{\columnwidth}
\import{./figures/}{#1.pdf_tex}
}
\begin{document}
\begin{figure}[h!]
\centering
\incfig{myfigure}
\caption{A figure.}
\label{fig:myfigure}
\end{figure}
\end{document}
My SVG files are stored in a local folder ./pdftex/ and has figure name HBRIDGE-CIRCDIAGRAM. However, to reproduce, you can choose whichever filename with *.pdf_tex.
I'm expecting that the file name is recognized and pulled from ./figures/ but instead the program recognizes it as a *.pdf file instead, resulting in a blank image.
Below is an image of how I have the files set up in my folder:
I then include it in my code in the following fashion:
And Overleaf produces the following output:
Any thoughts on why this is happening and how to fix it?
Thank you.

Related

apply same curve-color to tiff in batch in GIMP

I would like to apply a specific color curve to some 2000 .tif files.
I am a Windows user and so far I have used GIMP for photo editing.
Using Gimp 2.10 I was able to perform such task working on .JPG files using the batch Image Manipulation plug-in (bimp v 2.6; https://alessandrofrancesconi.it/projects/bimp/).
Work flow so far for Jpegs in GIMP-2.10:
Using I created a color curve working on a jpg file (Colors-> curves).
once happy with corrections I saved the curve in an external file ("myset") which hasbeen saved in '\User\appData\roaming\gimp\2.10\curves'
using bimp plug in I choose Add->color correction
in the new window that pop-up I then select only the checkbox "change the color curv from external file" (or similar, menus are not in english...sorry) and navigate to my "myset" curve file.
finally run the batch
When I tried to do the same BUT WITH the .tif files, I got warnings of the kind "unknown filed tag encountered" at the step of importing in bimp the images to process.
That said, I can open the individual tif files in Gimp (File -> open...).
When I do, I still get the warnings "unknown filed tag encountered", but i can click "OK" on the message window and continue importing the file.
Now the "import TIFF" window show me a "Page 1" icon in the top part, then I can choose if opening the file as "levels" or "image". Both choices seem to give the same result.
At that point I can apply my "myset" curve to the file from the tool Colors-> curves.
One potential solution I've been thinking of is to write a script to do this and call it from the command line. I found something along that line here: https://www.gimpusers.com/forums/gimp-user/11100-curves-spline-batch .
Unfortunately:
I have no experience in writing script-fu scripts and very few on command line.
looking at the example in the above link I cannot figure out how/where to point to the "myset" curve in the script.
looking into the Procedure Brouser I do not know which is the one corresponding to the Color->curve tool. ( possibly someting like gimp-drawable-curves-splines, but again I dont know how to have that refer to "myset")
A copy of my "myset" curve and a some .tif esample files can be found here.
Dows anyone have suggestion on perform batch curve color changes on these tif files similarly to what I describe for the jpg? I am open to other solution then GIMP (but for example I cannot open those tif in rawtherappe - don't know why - so that is less of an option)
IMPORTANT: the I need to preserve the tiff metadata (they're georeferenced)

Why won't my .stl file show the correct information in a text editor?

I am quite new to work working with .stl files and in my research, I found they can be opened in a text editor where faces and vertices were clearly written out and easy to read. However, whenever I download a .stl file and open it with a text editor, I get a series of random characters. The same thing happens when I take a .blend file and export it to a .stl file. In spite of this, the .stl files still render correctly. I have attached a picture of what my problem looks like. If anyone could help me out, I would appreciate it.
Thanks.
The random characters when I open .stl files in a text editor.

How to convert vector image files to SVG with inkscape, when I don't know the extension

TL;DR: Is there a way to tell Inkscape on the command line, what the file extension is of the parameter --file=?
I have a case where I have to convert vector image files to SVG, using Inkscape command line tool. Current code is targeted at PDFs, so the following works fine:
inkscape --without-gui --file=source_file.pdf --export-plain-svg=result_file.svg
My problem is that I have to apply the same to new files, that are stored without extension, so my command would look like this:
inkscape --without-gui --file=some_stored_file --export-plain-svg=result_file.svg
When I run this command I get an error: "Specified document some_stored_file cannot be opened (does not exist or not a valid SVG file)"
I think this happens because the file doesn't have an extension and Inkscape can't guess the format.
What I can do is: get the format somewhere else, copy the stored file to a temp file with extension (some_temp_file.pdf) and then convert that to SVG, then remove the new temp file.
While this works fine, I would skip the otherwise unnecessary file copying just to have an extension.
Is there a way to tell Inkscape what the file extension is, other than having a file extension explicitely?
Well, I didn't found an answer to my question so what I did is symlinking the file (instead of copying), adding the extension on the symlink. Still better than copying the file and works fine.

Inkscape doesn't allow to edit svg text lines once it has been saved as plain svg or treated with scour

I was for several days trying to find a solution to the following problem :
Create a svg with text (simply click with the text tool to add text, do not drag to open a frame)
Type enter to create a multiline text, add several lines of text
Save as plain svg or optimized svg
Or treat with scour in command-line
Reopen with Inkscape : you cannot edit the text, it shows it properly but when you go to the next line (with the mouse or keyboard arrow down) the cursor stays on the first line.
This is an annoying bug running for some time in Inkscape and doesn't help with web edition.
But there are solutions... See the following thread to manually (in vim) replace all tspans :
Vim search replace regex + incremental function
And see my answer below to correct the svg code in order to get your Inkscape files back in working order !!!
SVG files do not currently support multi-line text. Inkscape uses custom XML attributes to keep track of which spans of text are part of that block of text.
When you save as Optimized SVG, Inkscape strips out all its custom XML attributes and writes a vanilla SVG file. So the sense of what is a block of text is gone.
Sed is very useful in order to correct your files in a batch:
cd /home/user/my/svg/files
sed -i.bak 's|<svg|<svg\nxmlns:xlink="http://www.w3.org/1999/xlink"\nxmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"|g' *.svg
This runs on all svg files in the current folder and :
Creates a .bak file which you can rename to svg in order to get your original files (but I nevertheless strongly advocate to duplicate your working folder in order to avoid terrible mistakes when fiddling with sed)
Adds the correct namespaces with newlines (\n)
Then:
sed -i.2.bak 's|<tspan|<tspan sodipodi:role="line" |g' *.svg
This appends sodipodi:role="line" to all tspan tags in the current folder and creates file.2.bak backups.

In LaTeX is there a way to include the filename of a graphic into a caption?

I have a LaTeX document with a large number of drawings included from external files with \includegraphics{bla.pdf}. The drawings are done in Inkscape. This all works fine. However sometimes it is hard to keep track of all the drawings and their source files. Hence I'm looking for a way to include the source file name, in the example bla.pdf, into the caption. Not being a LaTeX expert I haven't found a way to automatically access the filename string from the caption. Using Google-foo didn't yield a result either. Is there an existing way to refer to the filename and include it in the caption, like \caption{A fancy drawing of bla (\filename}?
You can capture the image filename by patching a part of the nested calls inside \includegraphics:
\documentclass{article}
\usepackage{graphicx,etoolbox}
\makeatletter
\patchcmd{\Gin#setfile}% <cmd>
{\ProvidesFile}% <search>
{\xdef\imgfilename{#3}\ProvidesFile}% <replace>
{}{}% <success><failure>
\makeatother
\begin{document}
\begin{figure}
\centering
\includegraphics[width=.5\linewidth]{example-image}
\caption{Image: \imgfilename}
\end{figure}
\end{document}
\imgfilename will contain the filename used in \includegraphics only after it's used.
Redefine \includegraphics. For the case of no arguments (width=3cm, scale=2 or something like this) we have
\let \saveinclude \includegraphics
\def \includegraphics#1{\def\filename{#1}\saveinclude{#1}}
The use
\includegraphics{bla.pdf}
\caption{A fancy drawing of bla (\filename)}

Resources