Including Latex code when compiling MMD --> Latex in Scrivener 3

It seems to be something to do with how I selected the text when defining the style – if I make sure the paragraph style wraps onto the next blank line, it works.

Okay, got it. Yes, there are some awkward aspects of selection and formatting, especially around newlines.

So, I spoke too soon. Full-paragraph Latex blocks are working, but inline Latex is not. I have text like:

Here’s figure \ref{fig:myfigure}.

where the Latex bit is marked as style Inline Latex. In the compile settings, under styles for Inline Latex, I have

Prefix: `
Suffix: `{=latex}

Yet when compiling, the .tex file has:


I’ve tried many variations of the prefix and suffix but cannot figure out what is going on. I created a minimal scrivener project that reproduces the problem, attached. Thanks for any help!
scrivener (17.4 KB)

1 Like

Thanks for providing a test, that made the problem easy to spot. If you fix the name of your style in the project, to “Inline Raw Latex”, then you should find it works fine (either that, or change the name of the style in the compile Styles pane; one way or another they need to match).

As always it is a good idea to test with plain .md when running into conversion problems. as that can help you determine whether it is a Scrivener setup issue or perhaps something further down the line in how MMD works. In this case you could see it was a setup issue and that the prepared compile style was not being used, as the .md file looks like:

Base Header Level: 3
BibTeX: library
Title: scrivener test

Hello world

I am a figure \ref{fig:myfigure}.  

Wow, that's nice.

Well spotted, thank you.

Last (?) thing – I think I am working out the kinks: it now seems like everything is working in general, but some of the references work while others don’t. I tried re-removing and re-assigning the style, doesn’t seem to work…what does work is deleting the text, typing it out again, and assigning the style again – basically, starting from scratch. I have the feeling that these are cases where maybe I typed the reference, added the style and then edited the reference text in some way, which seems to maybe break the application of the style (e.g. the style is not applied continuously to each character but is somehow cut up into more than one block of style, if that makes any sense). The solution seems to be just to re-type things which is fairly straightforward, but any idea what causes this behavior?

I have not seen that particular result before, no, and I use styles with prefix/suffixes all of the time. Does it happen whenever you edit text that has been styled, or did it only happen to some in the past? I’m wonder if how they were edited makes a different, like maybe search and replace could have done something strange?

Not sure, I’ll keep an eye on it and see if I can figure out. Definitely not search and replace. I was fiddling with the styles A LOT trying to get everything working and I must have broken something somehow.

1 Like