Text color & compiling with latex

Hello all,

Is there any way to insert MMD code to change the color of some of the text, and have that convert to latex \textcolor{colorcode}{Text to be colored here} ? At the moment I’m having to use a hack, which is basically surrounding the latex \textcolor code within the code to have it pass through the compile untouched. I did a search online but didn’t really find anything useful. Thanks!

I’m not aware of anything in MMD which would let you specify a text colour and carry that through to latex. The hack you have described is where I would start. However, I would go one step further and set up a bespoke compile replacement.

For example, I could set


to be replaced with

<!-- \textcolor{blue}{$@} -->

The $@ is a placeholder for any text found between the two boundaries (in this case >> and <<), so on compile Scrivener would replace

>>my blue words<<


<!-- \textcolor{blue}{my blue words} -->

giving you the text colour command in your final tex document.

The compile replacement just makes the text more readable while you are writing it, and also cuts down on the number of latex commands you have to type.

Thank you, this is an awesome tip!!

I couldn’t figure out where to configure the compile replacement. Is it somewhere in the Compile options?

There are a few other latex commands I regularly use and would like to replace in the same way, as they do indeed clutter up the text quite a bit. (The one that annoys me the most is math mode - sometimes you just don’t want a space around the $ because it’s inside a parenthesis, so instead I have to resort to the convoluted \( or whatever it is, can’t remember of the top of my head).

In the compile dialogue one of the sections is ‘replacements’. You can define the replacements there, on either a whole project level, or for a particular compile route (e.g. MMD–>latex). If you are only ever going to latex you might as well set them as a project level replacement.

Yes I found it now. Thank you so much!! :smiley: