associate latex content to styles?

I’m not sure how to even ask this question since I’m a little uncertain about the proper nouns used to describe what I want to do.

Having some wine with my dinner this evening may also have something to do with my lack of clarity.

I’ve made a custom XSLT file (based on 6x9book.xslt). In there I’ve been slowly developing my own enhancements and tweaks. Here’s the section related to my question:

\begin{minipage}{\columnwidth - 2em}

The idea of course is that in the TEX document I will want to have something like this:
Special section of text goes here.

I’m already using a template in my XSLT file that superbly handles blockquote sections:
<xsl:template match=“html:blockquote”>
<xsl:apply-templates select=“node()”/>

And then in my Scrivener document I can do this:

This work may seem…

But I’m looking for a way for my Scrivener document to reference the {note} definitions from the XSLT file. I tried embedding it in my Scrivener document as an html comment like this:

text goes here

But that didn’t work.

Then I started to wonder if maybe I could assign some attribute to the section of text I want identified for my {note}. For example, could a style assignment work? I started to create a style called “note” and then was hoping I could assign that style to a selection of text. And then maybe write some kind of xsl:template match technique to detect it?

I feel like I’m close but not quite getting it.

Can anyone provide a good lead here for me to follow? Does my request make sense? I can make this work by typing latex directly in TexShop, but want to do this from inside Scrivener.

Thank you in advance,

  • Steve

Unfortunately styles (which are just rich text adjustments) are completely lost upon export. Scrivener makes no attempt to parse rich text commands into Markdown commands, and rightly so, as rich text is a front-end model not a semantic model. It’s like a web page created and maintained for years in GoLive as opposed to a web page that has been hand written in a text editor. One is going to be a semantic nightmare internally, and the other will be precisely what is required to display the page (generally speaking of course).

However there is one exception! Scrivener annotations are exported as XHTML spans with inline styles dictating their colour. Since XSLT can do matches based on attribute values, if you use standardised annotation colours in Scrivener to mean certain things semantically, you can then use those hex encoded colour values as matching values in the XSLT, doing different things with them. If you wish to retain one colour for non-exportable Scrivener annotations, you can just instruct the XSLT to ignore that colour.

Personally, I think this would be easier than typing in pass-through LaTeX blocks everywhere, since annotations have short-cut keys and work like ordinary formatting in regards to selection and implementation. Additionally, Scrivener has useful facilities for sorting through annotations, even listing them all out in a single document.

Does that answer your question, or perhaps point you in a useful direction? A simplified version of this proposal would be to just use all annotations as {note} in the XSLT.


Thank you for the prompt response.

Yea, I think you caught what I am trying to do. I’ll actually need more than one kind of note section ability: {note}, {largeNote}, {code}

If I understand what you recommend, I can define unique annotation colors for these kinds of note sections. And then Scrivener/MMD will create the note sections with whatever I define as their behaviors in the XSLT file. And apparently there’s a technique to allow annotations to exist too.

All that sounds a lot smarter than I feel right now. But it looks like I’m going to be learning about Scrivener annotations management real soon. I’m not certain how to write the “match” portions for the XSLT. But, one thing at a time.

  • Steve

Right. Easiest way to handle colours is to create a set of favourite swatches in the palette tool, that way you know the hex number will always be the same. For XSLT syntax tips, see this thread.


Got that working with 3 kinds of note styles. I’m pretty happy.

The only issue I encountered was that for some reason my quoted text and contractions were all being converted to unicode and causing TexShop to have fits. I had to tinker with the text quite a bit to get that working. I’m wondering if annotations have their own formating rules that I need to adjust somewhere?

  • Steve

Hmm, you might want to try using the compile options in the second tab that force quotes to “dumb” (as well as ellipses and em-dashes just to be safe). Does that fix the problem for you? I wasn’t aware of annotations going through any pre-processing prior to MultiMarkdown file creation, but I could be wrong. You are certain typographic quotes are turned off in the main Typography section of preferences? I guess another possibility is that if you pasted in quotations they might contain typographic quotation marks (general settings will not impact that, but the compile options I mentioned should).