LaTeX code and control in MMD

Hi I’m trying to use Scrivener to write a scientific essay and the use mmd>Latex to make a pdf. As happy I am with the “technical” stuff in latex as unhappy am I with the/my workflow in it.

So I was wondering if there is a way to make mmd disregard parts of what I’m writing and just send it directly to the tex file, so that i can write, eg math, in latex code directly in scrivener?
Eg.
<disregard_tag>$$\int_{a}^{b}sin(x)dx$$<\disregard>
and this will then produce the “$$\int_{a}^{b}sin(x)dx$$” part in my tex document?

Also is it possible to specify “how” mmd should translate to latex? as it uses some packages that i don’t have (I’m running a small/basic compilation of latex). I know this is somewhat against the whole philosophy of MD and MMD that it should be readable just as it is, and I partially agree (it a hell in Latex to have to edit stuff, as it could be written in one line), but it would be nice to be able to insert some code here and there.

Also how does any of you use srcivener and mmd>>latex in a math/physics scenario? Do you use it at all for this kind of work?

Mesalas

I am working on a trial feature that allows XHTML comments to be passed unaltered into the raw latex source, e.g.:

would work as expected.

To enable this feature, simply insert the following into the XSLT file of your choice:

[code]<!-- Process Comments without processing -->
<xsl:template match="comment()">
	<xsl:value-of select="."/>
</xsl:template>

[/code]

One caveat (for now, anyway): the comment has to be a “child” of something, e.g. a

. So if you want raw LaTeX to be in a separate paragraph, do this:

<p><!-- Raw \LaTeX --></p>

I am awaiting more feedback on this before I add it to the next public release.

As for the second part of your question, you can edit/create your own XSLT files to use as many or as few LaTeX packages as you like. MMD is totally customizable.

Yes, the output process looks like this:1. Scrivener compiles all the bits of the draft; creates titles with the appropriate header depth, if the user has specified that option; inserts MMD meta-data information specified in File menu / MultiMarkdown settings, and then creates a temporary plain text file. Exporter stops here if plain MMD export was used.

  1. This is fed to the standard MMD Perl scripts, depending on the output option selected in the export pane. These produce a valid XHTML file. Export stops here if XHTML export was used.
  2. The scripts then take that file and using the XSLT language, transform the XHTML into the intended output format (generally LaTeX, but it can be anything at that point, even variations of XHTML or other XML formats, such as OpenDoc).

The step where you want to inject customisations is the final one. The first thing I would recommend doing is downloading MultiMarkdown and placing the MMD directory in [pre]~/Library/Application Support/MultiMarkdown[/pre]. Scrivener by default uses a version that is built into Scrivener, but if you have a copy installed there, or at the computer’s Library level, it will defer to that instead. This makes it much easier to customise your MMD installation.

The rest is up to you. There is a folder in there called XSLT, which contains all of the transformation scripts. You’ll notice there are quite a few options out of the box. Most of the final stage transformers rely upon a cascading of generalised ones, so making changes to the general ‘xhtml2latex.xslt’ will impact ‘memoir.xslt’, ‘article.xslt’, and so forth. Further, many are variations on ‘memoir.xslt’, so changes there will impact them. The reason for knowing this is that the parts of the LaTeX file you wish to change may not actually be in the final XSLT specified in your MMD meta-data header (or the default memoir.xslt).

Recommended practice is to duplicate the XSLT you wish to modify, preferring to modify the final XSLT (such as ‘science,xslt’, rather than the generalised ones, such as ‘xhtml2latex.xslt’), if possible, and then specifying the name of this new customised XSLT in the MMD meta-data settings. If you do want to modify one of the base transformers, I suggest duplicating it, and saving the original copy for back-up purposes.

If you make a lot of revisions, take care to preserve them somewhere safe so the next time you upgrade MMD you do not accidentally delete your XSLT folder.

Further customisation is possible. Since the entire export process is Perl and XSLT, the whole engine is rather easily modified to the very core. The only limit is how good you are with these languages, or how willing you are to learn them. For example, I have coded a customised version of MMD that allows me to add CSS classes to elements, and I use this to create variations in the final product.

Thanks for the replies, I’ll look in to it first thing in the morning :smiley:

it works like a charm, thanks :smiley: