1

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:

Image of how I include my files in the local folder ./pdftex/

I then include it in my code in the following fashion:

How I include the figure in my code

And Overleaf produces the following output:

What is output by the program

Any thoughts on why this is happening and how to fix it?

Thank you.

mvh28
  • 11
  • 2
  • @samcarter_is_at_topanswers.xyz `\documentclass{article} \usepackage{import} \usepackage{pdfpages} \newcommand{\incfig}[1]{% \def\svgwidth{\columnwidth} \import{./figures/}{#1.pdf_tex} } \begin{document} \begin{figure}[h!] \centering \incfig{my-image} \caption{An image} \label{fig:my-image} \end{figure} \end{document}` – mvh28 Feb 04 '23 at 12:44
  • Please add it to your question. As you can see comments don't allow line breaks and mess up the code. – samcarter_is_at_topanswers.xyz Feb 04 '23 at 12:48
  • @samcarter_is_at_topanswers.xyz if all is well there is an example right now. However, I'm unable to provide a file with *.pdf_tex format, sorry about that. Thank you for looking into this. – mvh28 Feb 04 '23 at 18:52
  • Thanks for the update! The tex code as such works fine. Can you post a screenshot of your `figure` folder so we can see if it has both the `.pdf_tex` file as well as the corresponding `.pdf` file? – samcarter_is_at_topanswers.xyz Feb 04 '23 at 19:09
  • @samcarter_is_at_topanswers.xyz images are included. I have since attempted with figure HBRIDGE-CIRCDIAGRAM, in local folder `./pdftex/`, where, in the `/incfig` command I have changed the folder name to `./pdftex/`. Thank you! – mvh28 Feb 05 '23 at 15:02
  • If the figure folder is in another folder, don't you need something like `\import{./pdftex/figures/}{#1.pdf_tex}` ? – samcarter_is_at_topanswers.xyz Feb 05 '23 at 15:28
  • "but instead the program recognizes it as a *.pdf file instead" no, it does not recognise it is pdf, it has trouble finding the pdf_tex file, prints the filename instead to indicate where the file was supposed to go if it were found and while printing the file name gets confused by the math only character `_`. – samcarter_is_at_topanswers.xyz Feb 05 '23 at 15:30
  • @samcarter_is_at_topanswers.xyz Should have clarified, I have the files in a folder called `pdftex`, which is why I use `\import{./pdftex/}{#1.pdf_tex}`. Using folder name `figures` was simply to make it easily reproducible. I understand that it gets confused by the character `_`, but it still confuses me why this is the case as the file format is defined, since you mentioned the TeX code works fine for you. – mvh28 Feb 06 '23 at 09:06
  • It gets only confused by the `_` because it for some reason does not find your graphic and thus has to print the name. The `_` is not problem if it finds the file. Can you show your .log file? Here a dummy project which works fine https://www.overleaf.com/read/xqbpsbbkgcym – samcarter_is_at_topanswers.xyz Feb 06 '23 at 10:51

0 Answers0