Scrivener with LaTex Equations > Markdown > pandoc workflow: how to?

Hi,

I’m writing a scientific book with many citations (managed by Zotero) and equations. My publisher expects a docx file.

My present workflow is the following:

  1. I write everything in Scrivener using custom styles (imported from docx template)
  2. Within the text I include BibTex cite-keys (from Zotero)
  3. Then compile to Multimarkdown (Compile for > Multimarkdown) with my custom format, where I’ve
  • updated styles by adding "# " as prefix to Headings 1, 2, 3, etc, "** " for Strong style, etc.
  • call my custom bash script (in Processing), where I put all my pandoc parameters, which looks like that:
pandoc --filter pandoc-citeproc --bibliography /Users/wodecki/Zotero/my_library/mylibrary.bib my_file.md -f markdown-auto_identifiers -o my_file.docx

And it works: I get my docx perfectly formatted :slight_smile: But without equations…

My question: how to improve this workflow to include LaTex equations?

As I understand, my workflow at the moment has the following logic:

  • write sth in scrivener > export to pure markdown > send this markdown to bash script, which generates (via pandoc) docx file.

I spent hours on trying different options to include latex equations, and failed.
Especially, I’ve played with Pandoc Multimarkdown outside the scrivener: created a sample file with equations in the form of:

$$ x^2 = 15 $$

which has been correctly converted from markdown to docx by pandoc. Unfortunately, when I put this into Scrivener doc, it doesn’t show up as equation. So, I’m stuck…

I would appreciate Your help on this workflow. Especially some tips on eg.:

  1. should I move from Multimorkdown export to eg. Pandoc > docx offered by Scrivener? If yes: how can I implement elements of my bash script (eg. calling my library, citation styles or MS Word template)?
  2. or should I write my equations in some other format in Scrivener?
  3. or tweak my current export settings?

I’m aware that the solution may be somewhere in this discussion forum (apologies than…), but after so many hours I simply give up.

Many thanks in advance :slight_smile:

Andy

Hi,

after next few hours spent with Scrivomatic (github.com/iandol/scrivomatic - a great work BTW, congrats, Ian :slight_smile: )
I decided to simplify my question.

How to create a Scrivener document and configure exports in order to combine:

  1. Latex numberMath Equations like:
    x^{\alpha} e^{\beta x^{\gamma} e^{\delta x^{\epsilon}}}
  2. BibTex citations from zotero in the form eg. [@myname2016]
  3. with export to docx file or, preferably, to markdown processed by pandoc script?

IMHO this is a very basic need for a scientific manuscript, and should be possible without quite complicated setup like Scrivomatic.

I would appreciate Your help :slight_smile:

Many thanks,

Andy

Scrivener allows you to tell the Compile command to treat designated styles as raw LaTeX markup. See Section 24.5.3 in the Scrivener manual. That will pass your equation (or other) markup straight through to whatever post-processing tool you prefer.

I would say that the challenge here is not getting your equations out of Scrivener, but getting them in to Word, which uses its own proprietary equation tool.

Scrivener also supports MathType equations, but in my experience the results of importing those into Word can be mixed.

Katherine

Hi Andy, thanks.

For Pandoc, you want to make sure that Pandoc is properly parsing the maths for you (don’t specify it as raw LaTeX). It should do this by default as long as you markup correctly, you can see in my example workflow using styles:


Screenshot 2019-12-16 at 08.48.11_SMALL.png

This should create simple inline/block syntax that Pandoc will convert to Microsoft’s proprietary maths in Word, while still remaining compatible with HTML/LaTeX outputs too…

Screenshot 2019-12-16 at 09.26.38.png
github.com/iandol/scrivomatic/r … kflow.docx

By the way, Pandoc V2.8+ now has a neat option to specify groups of settings (a simplified version of pandocomatic), and this means you can use Scrivener’s compile formats to drive different outputs, see some examples here:

github.com/iandol/dotpandoc/tre … r/defaults

This will enable a simpler workflow while still providing a lot of customisability for Scrivener users…

Hi,

many thanks for Your suggestions :slight_smile:
Finally, I overcome the problem in a way a bit simpler than Scrivomatic.
You can find my final set-up described here: https://medium.com/@andrzej.wodecki/scrivener-for-scientific-writing-setup-af5edf4482b8, and a github project with all the files here:
github.com/wodecki/writing

Many thanks once again :slight_smile:

Andy

Glad you got it working, and thanks for detailing your workflow 8)