Hi I have the following code:

\item Copy files from the conf folder in the submission into \path{$SPARK_HOME/conf} folder

I have a dollar sign inside the path, the document compiles as expected, but ShareLatex highlights everything after in green.

How to make ShareLatex ignore $ symbol inside the path?

  • I don't know in ShareLaTeX & this doesn't work in Kile, but in some editors, adding a commented $ will allegedly satisfy the syntax highlighter. Kile tries to be clever and ignores the commented code, so I have to think of something else to avoid an all-magenta document. – cfr Mar 26 '17 at 3:49

Try this:


The part inside \iffalse ... \fi is never executed but should fool your editor that the inline math is ending there.

Another option is to never use $ there in the first place. As \path redefines special characters to typeset them, some more verbosity is needed:

\expandafter\path\expandafter{\dollar SPARK_HOME/conf}

^^d is a TeX variant to input $. So we define a macro that expands to this character but has to take care to expand the macro before \path starts processing its argument, hence the \expandafters.

Another option does not work for the ShareLatex.

  • Thanks a lot, exactly what I was looking for. I assume this is a bug and should be seen by the developers of the ShareLatex? How could we ensure this? @siracusa – Bato-Bair Tsyrenov Mar 26 '17 at 15:25
  • @Bato-BairTsyrenov It'd be nice if ShareLaTeX would catch that, but in general it's impossible for an editor to catch all corner cases without re-implementing the whole TeX engine. For example, consider \@ifnextchar$\doThis\doThat where $ isn't even enclosed in braces and so very hard for an editor to be seen as a macro argument. – siracusa Mar 26 '17 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.