Help: compiling to LaTex "\" always translated to "$\backsla

Hi. I have a problem with compiling to Latex. Scrivener always convert backslash "" to “$\backslash$” and slash “/” to "\slash " though I used XSLT post-processing and this command “”. So for example:

This:

<!— \begin{figure}[tbp] \centering \includegraphics[width=1\linewidth]or[scale=.5]{./figures/image} \caption{This is the caption} \label{fig1:FigTitle} \end{figure} —>
converted to this:

$<$!--- $\backslash$begin\{figure\}[tbp] $\backslash$centering $\backslash$includegraphics[width=1$\backslash$linewidth]or[scale=.5]\{.\slash figures\slash image\} $\backslash$caption\{This is the caption\} $\backslash$label\{fig1:FigTitle\} $\backslash$end\{figure\}---$>$
I’ve installed MultiMarkdown version 4.6 as well as its support files.

Kindly help.

Double-check your HTML comment syntax. If this is copied and pasted directly out of Scrivener, you should note that you’ve got em-dashes instead of double-hyphens (which in turn are converted to triple-hyphens for LaTeX). A couple of global search & replace runs (Edit/Find/Project Replace) should fix it up, and if you want to disable the em-dash feature (which I recommend for MMD anyway, for this reason as well as the fact that you can use double- and triple-hyphens for en-dash and em-dashes respectively, converted automatically by MMD) you’ll find that option in the Corrections preference pane.

1 Like

It works! :smiley:

Thank you so much AmberV.

Hi. I am a windows user with the same issue. I couldn’t get how I can solve the problem. I think I need to open File/Page Setup menu to open comment syntax part (manual 24.19.1). However, it crashes when I try to open Page setup. The case has reported in the forum.

My question is , is there any solution we can generate for that case. Backslash has highly used for LaTex formulas and when I compile to LaTex create mess. Thanks a lot!

This thread is old enough that it no longer contains good advice. MultiMarkdown moved away from using HTML comments for this sort of thing, and uses a syntax like Pandoc uses for pass-thru. But it’s worth noting that by default Pandoc allows for inline LaTeX in the same way both engines allow for inline HTML.

Here is a post that demonstrates the new method.

Lastly, I don’t know what advice you came across that suggested any of this would be done in Page Setup. That’s very far away from anything involved in this. At its simplest, you just type these things into the text editor, but to avoid the clutter of doing so, styles are a great way to mark text in the editor, which can then have syntax wrapped around the text when compiled.

For a practical example, open File ▸ Compile..., select MMD → LaTeX at the top, double-click on “Article (Memoir)”, and then access the Styles pane in the Format Designer window. Two good examples are the “Index Key” style and the “Raw LaTeX” style. The latter just wraps the pass-thru syntax around the marked text, while the former also adds LaTeX syntax, so all you see in the editor is the indexing keyword. Paragraph styles can go even further than that, putting an environment around the whole range of lines, and then prefixing and suffixing each line.

One last thing to consider, if you only are concerned with producing LaTeX documents with Scrivener, and are finding Markdown in general to be an unnecessary layer of friction between A and Z, then have a look at the General Non-Fiction (LaTeX) project template. This template is aimed at those wanting to write much closer to the source, more like they might in a dedicated .tex file editor, but with the added conveniences that Scrivener provides to avoid having to use syntax all the time. Indeed one could avoid most syntax if they wanted to set up the compiler in an extensive enough fashion.

1 Like

Your detailed response quickly solved the majority of my problem, thank you very much! Yes, I am a LaTeX user and mostly interested for that part. Actually, I have downloaded Scrivener a couple of days ago to test LaTeX compatibility. So I am checking manual, forum and videos and apparently bumping to old fashion solutions. If I can smoothly handle to generate a LaTeX code at the end, I would like to start using Scrivener for my academic projects.

I didn’t know Styles were capable for generating raw LaTeX expressions, that’s perfect. Only problem, I had written all my citekeys in {citekey} format and replaced with \cite{citekey}. In Raw Latex all the {=latex} strings replaced to \cite{=latex}. I think I am gonna simply change my citekey identifiers with {{citekey}} and modify my regex code for replacement. Thanks!

1 Like