0

I'm trying to include an image using an absolute path that contains a $-sign, the path looks something like:

\\NETWORKSERVERA\NETWORKDISKB$\FOLDERC\imageD

I've tried encapsulating it in curly brackets, and double quotation marks, but none of this works.

I also tried escaping the dollar sign with \$, this led to the error:

TeX capacity exceeded, sorry [input stack size=5000]

The dollar sign still switches the text to math mode.

MWE

\documentclass[a4paper,twoside,10pt]{article}
\usepackage{graphicx}
\begin{document}
    \begin{figure}
    \centering
    \includegraphics{//NETWORKSERVERA/NETWORKDISKB$/FOLDERC/imageD}
    \caption{}
    \label{fig:figure}
    \end{figure}
\end{document}
7
  • Does this solve your problem?
    – epR8GaYuh
    Feb 1, 2017 at 14:20
  • 1
    @dexteritas, I did not try that, is there a specific reason I should escape a dollar sign with an ampersand?
    – ROIMaison
    Feb 1, 2017 at 14:51
  • @epR8GaYuh, I tried it with the detokenize command, but the dollar sign still activates math mode
    – ROIMaison
    Feb 1, 2017 at 14:58
  • 1
    the $ sign should just work. It would only start math mode if you were typesetting something. Youe "MWE" is not a MWE as it is just a fragment that can not be run Feb 1, 2017 at 15:18
  • $ can be used in the path. Try creating a local directory with a $ sign in it, copy a graphics in it, and include the graphics in your LaTeX file. Do you get an error?
    – user94293
    Feb 1, 2017 at 15:19

1 Answer 1

1

If I set up a test directory like

mkdir 'NETWORKDISKB$'
cp `kpsewhich example-image.png` NETWORKDISKB$

so a directory called NETWORKDISKB$ containing example-image.png

Then the following test document

\documentclass{article}

\usepackage{graphicx}

\begin{document}

    \begin{figure}
    \centering
    \includegraphics[width=0.7\linewidth]{NETWORKDISKB$/example-image.png}
    \caption{}
    \label{fig:figure}
    \end{figure}

\end{document}

works producing

enter image description here

It doesn't work quite as it should: the $ is being seen by kpathsea and generating a warning in the terminal (not in the log file)

warning: kpathsea: NETWORKDISKB$/example-image.png: Unrecognized variable construct `$/'.

But that seems to be harmless.

The log file shows the normal image inclusion log:

<./NETWORKDISKB$/example-image.png>]
2
  • 1
    Thank you for your response. I managed to do it for my case as well. I got confused because my editor saw the $ sign as the start of the math environment, and start formatting the colors accordingly. But the compilation did not result in any errors. I tried to fix the formatting by escaping the dollar sign, but then the error that I mentioned in my question arises. Do you know a way to escape the dollar sign whilst avoiding the Tex Capacity error, or should I ask this in a separate question?
    – ROIMaison
    Feb 1, 2017 at 15:44
  • @ROIMaison that would be an editor specific question, can't help unless the editor is emacs:-) actually the colouring was wrong in emacs as well, but I usually ignore such things Feb 1, 2017 at 16:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .