General Non-Fiction LaTeX output on mac

Hi, I am writing a smallish thesis using the General Non-Fiction LaTeX template on a Mac (Scrivener 3.5.2, macOS Tahoe 26.4.1, macbook pro M1). I am trying to get the Compile workflow going early so I don’t end up with a Scrivener file with no way of getting it out to LaTeX - the MMD approach failed for me for unknown reasons, but I like the direct LaTeX approach better anyway. I’m not that fluent yet in LaTeX but Word has messed up so many important documents that I avoid it whenever I can.

Compiling the general non-fiction template works really well in general. Since Scrivener outputs a folder with the tex file and all images inside, I need to point the bibliography to outside the folder so the bibliography is available immediately on compile (ie. \addbibresource{../thesis.bib} instead of \addbibresource{thesis.bib} in the preamble modules of the front matter in the template - this took me a while to figure out). My bibliography is an auto-updated biblatex file (with biblatex-apa checked) from Zotero 8 that is pointed to the Texifier folder on iCloud Drive and set to Keep Downloaded, works well too.

However, Compile never outputs a normal folder with a .tex file inside:

If I choose to compile without the .tex extension, I get a normal folder that contains a file called thesis without extension, thesis.pdf, and the images. When adding the .tex extension to the thesis file, it opens normally in Texifier or Texshop, so all seems to be fine.

If I choose to add the .tex extension in the compile menu, I get no folder but a single file called thesis.tex that is actually a folder-like thing. I can option-click-open-package it and find the same files as before, only the thesis.tex extension is already there. I need to copy everything elsewhere to work with it in the LateX editor. The same happens if I compile locally, so it is not iCloud Drive doing strange things.

I don’t mind much adding an extension, but I wonder whether this is a bug or some unavoidable behaviour of the compiler in macos.

thanks

Well done for getting the workflow going early. This will also afford you the opportunity to “tweak” the LaTeX settings beyond that provided by the Scrivener Template.

I don’t see the same issue you see.

I always compile to a folder in ~/Desktop getting there by navigating the folder structure in the dialog box. The Save As at top is “Project_Name.tex”, I check “on” the Append “.tex” extension, and I have the open with set for Texmaker. I don’t compile to any cloud-synced folder.

These settings the same?

1 Like

My guess is that you have some program installed that presumes a folder ending in “.tex” should be a package. That isn’t something that can be done any other way, the only thing that defines what a package is, is some software declaring that to the system. You can see this in effect by uninstalling Scrivener, and you’ll find all of your “.scriv” folders become shown as such, instead of treated as packages. The presence of Scrivener is the only thing that makes that happen.

Likewise, if you rename a Scrivener project folder to remove the .scriv, it would stop acting like a package (and go right back to acting like one once you rename it back). So you could also fix this problem by renaming the “output.tex” folder to “output”, but that’s no less work than you’re already doing.

The cleanest solution would be to find which program is doing this, and look for options to disable this behaviour. If it doesn’t allow doing so, maybe just uninstall it and find something similar.

You could work around it though, by automating the part you’re doing manually, using the Processing pane’s script (what is being used to generate the PDF automatically upon compiling). If you click the Edit Script button, you could add something like this at the very top:

mv "$2" "$2.tex"

In the Arguments field, you will see that <$outputname> is given as the second argument ($2), which is how that would work. This placeholder prints the base name you supply in the compile Save window. Thus without the extension setting enabled, you can compile to “test”, and the script will interpolate that command to:

mv "test" "test.tex"

Now you should have a folder called “test”, with “test.tex” inside of it, along with everything else the compiler produced.

3 Likes

I’ve posted my main reasons why before (you can search my posting history) but I strongly encourage you to consider implementing an pandoc-based workflow instead. That workflow can easily output LaTeX but also docx. It’s desirable if there is any chance you’d want your drafts or final product as a docx —for example, if your advisor asks for a docx because they prefer to use Word’s track changes and comments to give you feedback, or if you might want to submit the paper to a journal, many of which ask for docx submission.

You can still use Scrivener as your editor for this — I wrote a technical academic book in precisely that way. Or you can use Quarto. Or you can just use a markdown editor and use pandoc natively.

1 Like

that’s what I’d like. that would be great

I tried to compile again to a folder on the desktop, and now it generates a normal thesis.tex folder. it must be iCloud. Maybe I should stop the idea of ever editing this tex output on an ipad, I won’t do it anyway.

thanks a lot!

true. I tried it again, and now I get thesis.tex folders except on iCloud. I think I tested to compile locally before, not sure what happened.

I tried your suggestion as well - with this modified script and add .tex extension unchecked I can even compile to an iCloud folder.

# Compile to folder without .tex extension
mv "$2" "$2.tex"

# Produce the PDF file and clean up
latexmk -silent -interaction=nonstopmode -xelatex -jobname="$2" "$1"
latexmk -c "$2.pdf"

# With all of the above dancing around, Scrivener won't know
# this is what we really want to open...
open "$2.pdf"

great, thanks! Maybe I’ll drop the sync idea however. It can mess up many things.

1 Like

I edit my documents (sometimes) on iPad and they are synced back to the Mac. I use Dropbox for syncing the Scrivener project. Nothing really to do with LaTeX tex files, the way I work.

I don’t think iPad is the issue, nor the sync mechanism.

I only do the compile step on the Mac. I never edit the tex output unless I’m experimenting with LaTeX commands that will eventually go back into the Scrivener settings for LaTex. I have a separate Scrivener file in “Front Matter” with my settings.

I always send the output to a local folder. Don’t see the need to send to a folder synched with anything.

~/Desktop/[Project Name].tex

Strange! I don’t know anything about iCloud really, I wonder how it is seemingly following its own file system rules? But no matter the service, I’d probably avoid syncing compile folders anyway, until I’m largely done with them. That’s a lot of unnecessary bandwidth usage, deleting and recreating all the PNG/JPG files, etc.

1 Like

I have to read into this again. One reason I dropped it is that I use eg. \parencite{miller2018something} in the document and that’s difficult to get through pandoc. The other reason is that it got complex, I ended up installing ruby for pandocomatic for scrivomatic and it all got too much. Also MMD was not trivial, the macos has a version that doesn’t work and such. I also heard that homebrew makes problems on macs in the long run and don’t know enough to be able to judge what installation is good.

Quarto would interest me. I have some (very low-key) stats analyses and I would really like to do these in R if I manage. (I took biochemistry before there was decent stats training in these fields.)

But I’d have to drop Scrivener for Quarto, which would be difficult. I really like the possibilities to rearrange lines, text pieces, possibilities to note and comment and outline in Scrivener. The arrow key line swap and document swap is so helpful, it’s worth having a bit of work for the compile.

True, I am rearranging to sync much less. I think it contributed to the breakdown of my mac, I just had an I/O board replacement, they changed the battery and couldn’t get it back to work so everything is new, and I am careful. I even quit Dropbox often and sync it once a day.

I have that too, that’s enough. I even put notes into a separate plain text app and transfer them to Scrivener on the mac, so I don’t ever forget to close and sync the .scriv project and get into sync conflicts.

I won’t edit the output of this on a phone or anything. Having the Texifier file on the phone was useful for a much smaller thing I did only in Texifier, but I don’t need that any more.

Yea, don’t mess with the TEX file, unless just experimenting. Let Scrivener do that heaving lifting for you.

FYI, I compile with the app TeXmaker most the time but also have TeXshop used occasionally, but don’t like the interface.

I particularly like my setup can easily create TOC (with Table and Figure TOC) and Index. I’m working on a small Python program to process automatically as a last step in Scrivener to build an index based on a list of words in a separate text file rather than manual marking words to be in the index. Doing this mainly for fun and the challenge. Works in progress.

1 Like

My Scrivener+pandoc workflow doesn’t use pandocomatic/scrivomatic/ruby. Scrivener simply creates a markdown file and hands that over to native pandoc. Pandoc then processes citations and latex math and hands cross-referencing over to pandoc-crossref.

I don’t think it would be very hard to have an LLM write a lua script that would crawl the md file that Scrivener creates and switch all “\parencite{miller2018something}” to “[@miller2018somethingmiller2018something]. Or you could do this once on your source material and then from now on use the Zotero Better BibTex plugin for producing pandoc citations from your source library.

I haven’t made my Scrivener project publicly available but if this is a route you want to go, I’d be happy to share it via DMs and explain some of the bespoke elements (such as my Scrivener-based method for controlling when the first line after a blockquote or an equation is or is not indented). I have even written up a guide for my coauthors on installing and using Better BibTeX for managing/producing pandoc citations.

ADDING…: I too use a Mac.

2 Likes

I did make the LaTeX project template for a reason. :slight_smile:

As much of a Markdown nut as I am, I recognise that it doesn’t address all cases equally well, that sometimes an abstraction markup gets more in the way than helps—or maybe sometimes we just prefer something else.

I would also say, for someone looking to learn LaTeX, doing so without an abstraction tool getting in the way will benefit you in the long run. I started out writing directly in LaTeX, and while I don’t do it much any more, I’m glad that I did.

As for Quarto though, you needn’t abandon Scrivener for that! Run a search for it in this category, and you’ll find a lot of discussion on getting the two working together, including some project templates to help with that.

4 Likes

And it is really good. Really good. The succinct and complete documentation for how to use all the features is superb. It has stood the test of time for me, including my own learned-customisations of LaTeX and indexing features. Thanks for doing it.

2 Likes

neat! and much more efficient.

Thanks a lot, this project might be great at a later stage. I think right now I should not change anything that works, better do the conversions once I know more exactly what I need. I’m happy to get back to you once I’m a little more along. I tend to get lost in tools but really have to push ideas : ) great to have such support here

Possibly also relevant: the first draft of the book was written with AmberV’s LaTeX template. When the publisher made it clear they would require the final submission in docx, I pivoted. I’m glad I did, because I’ll never again need to worry about producing a docx from my Scrivener source file, even as I typically output to (LaTeX-typeset) pdfs from the same source.

I agree also with @rms it is a great template! The small errors that I wrote about initially are not hidden icebergs which is comforting to know, and I’ll continue like this until I have some content. Unless I go down the pandoc route once more with @jpkell , or even Quarto, it needs very little adapting.

Thanks everyone!

1 Like