ScrivQ | A template to control Quarto, export multiple files, manage bibliography and easily create cross-references

Yes, a simple shell script works wonders! If you wanted to utilise the Ruby script, you could still save it as a file and call it from your bash code.

But the most important thing the Ruby script does (at least my original one) is rewrite cross-referencing labels from a format that works well in Scrivener’s compiler and those that are required by Quarto’s crossref filter. So if you don’t need cross-referencing (remember Scrivener can do general cross-references too), then you may not need the ruby script at all. Bernardo’s script adds the ability to split one document into multiple files, which again you may or may not require…

Do you have a Scrivener project outfitted with this Ruby script and demonstrating your native Scrivener cross-referencing method that the script converts? I’d love to explore/play around with it.

Sorry for the late reply, @jpkell, @cavalierex, @lyndondrake and @ptram. I had been away from my home and workspace since June; and shortly after arriving a few days ago, I moved places, so I am still slowly catching up. The last version of ScrivQ has been ready since before I left, but I couldn’t finish documenting changes (which can be very obscure within a Scrivener project). I will be updating the GitHub project soon with it.

@lyndondrake, the error seems LaTeX-related, with regards to a caption and/or a margin note. You could try to locate it in the source file, comment it out, and try to compile the latex file again. If this is not something you could easily do, maybe you could just try the next version in which the error maybe will not show up. About the HTML styling, just add the YAML option as shown here: Quarto - HTML Theming

@jpkell and @cavalierex, lets us see if I can make this next version more friendly and easier to compile without R dependencies.

1 Like

No apology needed @bernardo_vasconcelos. I’m loving the template. What I might do is wait for the update on GitHub and try again with that.

On the point about HTML styling, the .qmd file produced has this:

      light: [Pulse]  
      dark: [Cyborg]  

but it doesn’t seem to be having much effect. Interestingly, this output happens even though the light option in the Scrivener metadata is set to default. I’ll re-test it when the new release is out on GitHub.

(Also I haven’t forgotten about the other conversation, of working on some filters and CSL styling via the Visual CSL Editor to get citations working the way I need them in pandoc-citeproc.)

Any ruby script is not required for any native cross-referencing; both mine and Bernardo’s templates utilise Quarto’s cross-referencing. If you want an example of native cross-referencing then that is demonstrated in my Scrivomatic template (scrivomatic has its own embedded ruby script [that was the basis of the Quarto one] used for setting up the script environment and doing some background work like running latexmk seperately but it doesn’t do any cross-references etc.).

So e.g.
Screenshot 2023-08-02 at 10.58.24_SMALL

Uses these compiler replacement rules to generate native cross referencing placeholders:
Screenshot 2023-08-02 at 10.59.03

That would mean that quarto got finalised references text and wouldn’t do any cross-referencing, it had been completed by Scrivener before any markdown output…


Thanks for your reply. (Congratulations with your move to your new place! No apologies needed.)

I have gotten a “bare bones” version of Scrivener > .qmd > Quarto > PDF working very well. Now I will see about adding the various Scrivener styles that can help with visual signaling of Markdown and Quarto code.

One thing that I am hopeful to be able to do is to permit the integration of LaTeX classes (document themes) – for example, the excellent kaobook. The two routes would be either (1) to re-create a “best match” simulation of kaobook in pure Quarto, versus (2) creating a general solution for any LaTeX theme by creating a Scrivener > .qmd > Quarto > LaTex > pandoc > PDF workflow (where the LaTeX step implements the kaobook theming and then pandoc creates the PDF).

@bernardo_vasconcelos and @nontroppo, Have you thought about such things (theming) for ScrivQ or Scrivomatic?

– Alexander.

Scrivomatic, being just plain Pandoc + recipes, is easy to tweak to use different “themes”; I have my own custom LaTeX template, but also use the excellent themes like Eisvogel, Elsevier’s template, a Letter and leaflet template etc. which only require one line of metadata to change, here are the example recipes (scroll down):

Each “recipe” is the .tex template and the collection of Pandoc settings that may be required. Pandocomatic makes it really easy to write these recipes.

Quarto also supports extensions that include custom formats:

To be honest, I like Quarto for its templates, and personally find it easier to stick with plain pandoc + recipes for customisation. But I think there is nothing stopping you from using Quarto extensions to build a custom format and that could be integrated into a Scrivener workflow.

Apropos of nothing, I gotta say that Typst looks very attractive and promising. I’m happy and locked in right now to to my Scrivener+pandoc+pandoc-crossref workflow. But that just means I can let the Typst team keep doing their thing and give it a try after it develops a bit further. The big downside from my perspective is that it doesn’t use LaTeX math. But I see from the pandoc forums that there’s a pandoc-friendly converter in the works.

EDIT: I think I’m seeing that Typst outputs to PDF only, which is not great if journals etc. require Word submissions. Still, I’m interested in the project and curious to see where it goes.

So, I finally have the new version ready or quasi-ready! It is incomparably better than the previous one, I think. And I love the way the bibliography now works within Scrivener. I highly encourage anyone interested in using a bibliography in association with Scrivener to check it out!

There are certainly holes in the documentation, which I would love if you could point them out.

Compiled sample:

Project download:


Thank you Bernardo and Ian, for all your efforts to make Scrivener a great front-end for a solid editorial system!

The new version of ScrivQ is something that even we humanists can handle without too much fear. Can’t wait to put it to test with a real project!



Thank you so much for this. It looks amazing. I look forward to exploring it after I finish the book I’m writing with Scrivener+Pandoc+Pandoc-crossref. I think I already said in a previous post that while I really like my current setup, I worry that pandoc-crossref’s compatibility with Pandoc depends on one (amazing!) guy. The fact that Quarto is being maintained by a team makes me really glad to have it as an alternative. And now that you’ve done the work to show how to use Scrivener as a front-end, well, that enables me to rest easy!

One thing I like about my setup is that the pandoc-crossref citation keys look like this ([@eq:EMC2]), where the name of the respective equation file in the binder is “eq:EMC2”. I like that because then I usually know which equation is being referenced. But when all the crossref keys are “scrivlink”, I might often need to click through to see which equation I had referenced.

I achieve my system by having all new equation documents named “eq:equation”, and then I change the ‘equation’ part to a unique identifier. Then I have a macro on my machine that changes “@eq” to “([@])”. Then I drag the equation document from the binder to the right of the “@” symbol. So I end up with "([@eq:EMC2]), and then pandoc-crossref does the rest upon compile. (This doesn’t work for chapters/sections tho, because those are handled in much the way you handle them in ScrivQ. For chapter/section cross-refs, I have a macro that changes “@se” to “[@sec:<$linkID>]”, and then I highlight “<$linkID>” and drag the respective section folder onto the highlighted part.)

Not sure if you could implement something like I have for equations in ScrivQ. Anyways, thanks again!

1 Like

Thanks, @ptram and @jpkell for the feedback!

@ptram, let us know how it goes.

@jpkell, you just reminded me that I forgot to place a note on the opaqueness, a downside, of using a single standard identifier; and presenting this, admittedly questionable, alternative to avoid it. That is, by creating a replacement rule in the Compile configurations that allows us to write, for example, scrivlink:that-table-about-that-thing and erase the :that-table-about-that-thing part and let nature run its course in ScrivQ.

About the longevity of the cross-reference system within Pandoc: I wouldn’t worry about it. Pandoc has been around for a while and Quarto is being supported by the folks from R Studio, which also is also nothing new.

1 Like

About the longevity of the cross-reference system within Pandoc: I wouldn’t worry about it. Pandoc has been around for a while and Quarto is being supported by the folks from R Studio, which also is also nothing new.

Thanks. What I meant was that I worry about pandoc-crossref failing to work at some point, given that it is created and maintained by just one person.

@bernardo_vasconcelos PS. I too am a philosopher. I don’t work in ancient, but I did study with Terry Irwin in grad school.

1 Like

@jpkell, in what area do you work?
I often check Irwin’s renderings of Aristotle’s Greek as they usually are very enlightening.
On cross-ref, what I mean is that there is clearly a group of people taking care of this now thanks to Quarto.

@ptram, that is music to my ears! Thanks.

@cavalierex, on your earlier point about Kaobook, yes, I have used and enjoyed it. However, I found that I could get a better result (with way fewer bugs to iron out) by simply using Quarto’s standard template. But it is beautiful nevertheless.

Be it as it may, it would be very easy to include these integrations into ScrivQ. In fact, I prepared a version in which all of Pandoc template and template-partials are in the project and being exported along with the other files during Compile. This means that you can edit any/all of the Pandoc templates that will be used in the TeX → PDF conversion from within Scrivener. Adding the Kaobook configurations, for example, would be very easy.

@lyndondrake, could you refresh my memory on our earlier discussion on CSL files? Was there something you were trying to achieve with it, but could not? CSL files are not easy to edit at all in the beginning, but once understand how it works, they are manageable.

@bernardo_vasconcelos I work in bioethics and phil of econ (with a focus on climate change).

On cross-ref: Ok yes, that’s exactly why I’m very glad to hear about Quarto and to know you’ve made it work with Scrivener. I’ll use my setup until I can’t, and then I can change to ScrivQ. THANKS!

1 Like

Question: How does one set docx as the output?

There you go.

There seems to be a small issue with some of the callouts in DOCX output, but, other than this, it works perfectly in PDF, HTML and DOCX.

1 Like

Thanks much. But how does one toggle between different outputs? There are so many metadata options. And I supposed to untick all of the ones associated with PDF and HTML, for example?

You could simply move PDF and HTML from the formats folder back to the Templates folder :wink:

Alternatively, you could duplicate the ScrivQ PDF compile format and change this:

1 Like