LaTeX footnotes into Scrivener footnotes

Is there a way to import LaTeX files with footnotes so that the footnote commands become Scrivener footnotes?
So what I have is something like this:

lorem ipsum dolor\footnote{This is my footnote text and probably some \cite[24]{greatauthor:greatbook} citations too in there.} ipsum lorem bla bla

And what I would like is to have that footnote become a Scrivener footnote with the text inside.

If there’s no import function, is there a way to accomplish this with find and replace? I can do a find for all my footnotes, of course (including odd ones like \footcite with regular expressions) but is there anything I could put in the replace box that would tell Scrivener to make them into Scrivener footnotes?
Thanks!

Yes, there is a way of doing so, though not in a typical GUI sense. There are some interesting implications of Scrivener’s inline footnote/annotation syntax that make this a possibility (it is in fact something I did myself many years ago when switching from another writing system to Scrivener, to convert its notation markings to inline annotations). Here’s the thing: wherever you see an inline footnote or annotation in Scrivener, it’s actually detecting a plain readable sequence of characters in the RTF file and transforming them in real time within the editor. I.e. if you take a Scrivener RTF file from inside the project format and open it in a normal word processor, you’d see raw codes. Since there is nothing special required other than having the syntax inserted correctly that means if you type them in by hand (or convert the strings from another kind of markup like LaTeX) and then reload the project to force the files to be processed, then the strings magically turn into inline footnotes.

To create an inline footnote in Scrivener, all you need to do is enclose the desired text in two codes. To use your provided example, here is what your target looks like:

lorem ipsum dolor{\Scrv_fn=This is my footnote text and probably some \cite[24]{greatauthor:greatbook} citations too in there.\end_Scrv_fn} ipsum lorem bla bla

It should be a trivial matter to build a ReGex that handles the whole conversion in one move. You could make use of the Edit ▸ Find ▸ Project Replace… function to convert an entire project at once (definitely back up before doing so!).

Lastly, if you don’t like inlines, use the Edit ▸ Transformations ▸ Convert Inline Footnotes to Inspector Footnotes menu command. There would be no sense in trying to automate directly to that format—it requires building XML content into a sidecar file and pairing hyperlinked UUIDs to it; might as well let Scrivener handle the heavy lifting for that task, if it’s your end goal.

Brilliant! Thanks so much!! Works perfectly. In case anyone else is trying this, just a note that I at least needed to relaunch Scrivener before the replaced text turned up as proper-looking inline annotations that could then be converted into inspector footnotes.

So my next question is, what about other formatting/notation codes? I’m assuming that comments similarly have markup tags? What about formatting (italics, etc.)? Is there a cheat sheet somewhere for various codes/tags? That would be incredibly useful in migrating marked-up text into Scrivener!

Thanks again, really appreciate it!

For comments you would want to take a similar route of going through the inline variant first, which is going to be far simpler to inject than messing with XML files, and then use the similar conversion tools in that same submenu.

Other formatting is going to be more difficult, because you’re leaving the realm of Scrivener’s special features, which are built on top of the RTF engine, and getting into RTF itself. At that point you would be doing far better to look into some form of LaTeX to RTF conversion, if the idea is to completely abandon the markup and switch to word processing.

But for other things, like annotations, I’d recommend experimentation. A simple way of doing so:

  1. Create a blank project in Scrivener, paste in some dummy text and add the markup you want to try and emulate.
  2. In the binder, ⇧⌘ Right-click on the item and select “Reveal in Finder”.
  3. Open the RTF file in TextEdit. If what you’re seeking to emulate is a Scrivener function you’ll see raw codes, and that’s all you need to inject. If it looks like formatting, then you’re in RTF land.

As for an RTF cheatsheet, you’ll just want to look up the public specifications for it. It’s not an easy syntax, mind. :slight_smile: Again, I’d recommend looking into a conversion utility. Pandoc may do well. Remember you only need to get the LaTeX into a format Scrivener can convert into RTF. So if you can’t find a good converter for that itself, try DOCX, ODT or HTML (the latter requires setting the Convert HTML files to: Text setting, in the Sharing: Import preference pane.

Thanks again, very illuminating! I had no idea that was how RTF worked, actually.

And, sorry to keep pestering you, but I can’t quite see how to get from the RTF version to the kinds of codes you listed for the footnote - I tested your suggestion of looking at the RTF for a model, but it looks to me like both comments and footnotes are coded in the same way in that, and it’s not the neat way you provided in the previous reply. Instead it’s linked to an XML and fn/comment are differentiated in that, while the RTF provides this:

{\field{\*\fldinst{HYPERLINK "scrivcmt://004D8849-D35F-45DE-AF2E-E610A9218840"}}{\fldrslt markup }}

I agree that it’s probably too nutty to try to do manual conversions to RTF; I’ll try pandoc for the basic italics and such. But if you have the code for doing the same with a comment as with the footnotes, which worked beautifully, I would really appreciate it!!

Right, that’s why I recommended using inline footnotes and annotation for the initial conversion, because it’s far easier to do so. Those are just text markup in the RTF file that requires nothing special to insert. Inspector comments and footnotes on the other hand are hyperlinks pointing to a paired UUID stored in a sidecar XML file. So to actually create your own from scratch you would have to generate XML, create a .comments file and insert hyperlinks at the RTF level (not the text level) pointing to them. Like I say—might as well let Scrivener handle the heavy lifting there, when converting from inline notation to inspector format.

Use the method I described to look up how inline annotations are marked up (the command is Insert ▸ Inline Annotation). That is about as straightforward as the inline footnote conversion described above. The only major difference is that inline annotations can store a colour.

Ah, sorry, was being slow there, forgot about the inline annotation step. Did manage to figure that out now. In case it’s of any use for anyone in the future, the code for annotations is

{\Scrv_annot \color={\R=0.499567\G=0.477401\B=0.378189} \text=Annotation text here \end_Scrv_annot} The color field seems to be required though of course the RGB values can be changed.

Thanks so much!