working with exisiting LaTeX files

Hi all,

I am currently trying out Scrivener and I really enjoy using it. However, most of my writing is done in LaTeX, in collaboration with co-authors, and often reusing text from previous LaTeX files. As a consequence, I am reluctant to turn to MMD.

Is there a way to

  1. import/open LaTeX source documents in Scrivener such that they get sliced up in sections and subsections the Scrivener way.
  2. edit pure LaTeX inside Scrivener (I don’t want to learn the MMD syntax when I already know LaTeX) / also using bibtex.
  3. export again to a LaTeX source file for distribution
  4. do all of this in such a way that the exported LaTeX source file gets only the modifications that I made, such that the subversion or git version control will still work for us ?

I am sorry to ask this question here, but I could not find this exact answer. I only found links to write in MMD and export to LaTeX …

Thanks !


In the absence of any expert replies, I’m going to offer a tentative ‘yes’ on the first three (your 1, 2, and 2). For 3, frankly I have no idea (and here in England a git is still primarily an unpleasant person rather than anything software related - there’s a joke about a cyclops, but that’s for another time).

For importing, the standard command K will split the document up into pieces, so you can then tweak and re-arrange as you like.

You can then use Scrivener as a plain text editor, adding all the standard Latex codes, then compile the text to a tex file. I think the key here is specifying the right XSLT in the metadata: there’s a clean-latex.XSLT (or thereabouts). That lets me stick all manner of raw Latex in the text, and it all comes through fine.

Actually if you intend to work in LaTeX, I would recommend steering clear of MMD altogether and just using the Plain Text compile format. You might wish to check in the MultiMarkdown section of the forum, as there have been a few posts providing helpful tips and tricks for using some of 2.0’s new features to generate nice LaTeX structure without any extra work from you, such as chapter names and simple code expansions using replacements. All of that is optional, of course. At its most basic, Scrivener will just assemble a text file based on the contents of the Draft. That could be anything from a LaTeX document to a C++ header file.

One thing you might find a little tedious is constantly importing, splitting, compile, and uploading. Scrivener is really designed with the idea of it being the central repository from which a single person works on a thing, and they work on that thing in Scrivener until it is ready to graduate to final aesthetics or back-and-forth with editors. Any other use of it is very likely going to be a compromise. That’s not necessarily always true—there are many fringe uses of it that are quite efficient, clever, and useful—but this type of in-and-out workflow will basically negate much of what makes the program so powerful: a persistent, heavily annotated master outline that is all at once that and your actual material. Or in other words, it would take so much work to re-split the document every time you bring it in, and for so little gain: you won’t be able to “keep” the fruits of this labour once you compile.

That’s the only negative I can see with external versioning of a draft compile. Most people just dump the whole Scrivener project on Git or what have you.

Dear AmberV and MrGruff,

thank you for your encouraging replies. Based on AmberV’s comments, my conclusion is that the process of repeatedly getting things in and out of Scrivener, to share with non-users, only makes sense if I want to seriously restructure an article in a latex file that is handed over to me by someone else.

Concerning the editing in LaTeX, I have tried a number of things, which I thought I might share, that do not work as I had anticipated.

  1. Importing an existing latex file. Importing and splitting appears to be a Scrivener command. I have set the “split at” to \section and it nicely splits my document into sections. I would, however, like to keep the word “\section” instead of seeing it disappear during import. Can this be automated ?

  2. When using MMD-> LaTeX, I have found that I need to add a meta-data field “LaTeX XSLT”, otherwise it will default to “memoir”. The location has changed wrt pre-2.0 forum discussions. It is now in the Meta-Data panel of the compile window.

  3. I have tried a number of options for this LaTeX XSLT file :

a) “clean-text-allow-latex.xslt”, as indicated approximately by MrGruff. This does not do any mark-up; it simply keeps my text. It, however, adds a few lines at the top of the file that I need to take care of, and it does not automatically add the .tex extension. What is the advantage over exporting to txt and not using MMD at all in this case ? This is what AmberV probably pointed out as well. I am, however, puzzled at why this option exists ? Does it have an advantage ?

b) “article.xslt” : this would probably work nicely if I use MMD->LaTeX the intended way, and just copy-paste snippets of LaTeX code into a new file. What I tried now is simply commenting out all text in all sections with the html comment tags . This makes Scrivener hang during compilation.

  1. Concerning syntax highlighting, I have tried adding the “Edit with TextMate” button, and this works nicely. However, it kind of kills the idea of having everything together in one application instead of one thing on top of the other.

  2. When using the clean-text options, svn treats the file as expected : no problems with detecting the right changes and leaving the rest unaltered.

  1. Automation: yes, just do a search and replace in TextMate for [b]\section[/b] => [b]% ***\n\section[/b] (changing the \n to an actual Opt-Enter return when typing it into the replace box, of course). Then have Scrivener look for [b]% ***[/b] as the split point. This assumes [b]\section[/b] always falls at the beginning of a new line; if not the replace string will need to be altered.
  2. Yes.
  3. (a & b) I’m still at a loss here. It sounds like you are trying to turn the MMD compile format into a plain-text compile format—something that just passes your code right through—when you have that option already available right above. To reiterate, there is no reason at all to use MMD if all you work in is LaTeX, and it is more comfortable for you to write and think in that than learn a proxy. I’m not sure what caused the hang—HTML comments by themselves work just fine, I use them extensively for inserting little LaTeX macros that are otherwise not addressed by MMD. Whatever is hanging (probably not Scrivener but the MMD Perl scripts it calls (you can tell by the progress bar type: candy-stripe means Scrivener’s done and it’s waiting for Perl to get back with results)) is probably some oddity in the comment or scale of them.
  4. Yeah, I never much cared for that workflow either. It’s not so much the external editor that bothered me (I do that constantly with other programs because most programs are nowhere near what TM can accomplish for me, so I copy and paste a lot; in fact I’m doing that right now using an MMD->BBCode converter :slight_smile: ), but rather because I make heavy usage of Scrivener’s rich text features, such as footnotes, annotations, highlights, cross-references, revision markings, and so on. Piping to a plain-text editor wipes all of that out.

Thanks again for the nice replies.
Indeed, the hang when going through MMD compiling is probably in the Perl script.

I have no technical questions left at this point; now it comes down to finding an ideal workflow to make use of Scrivener’s features while making extensive use of pasted-in LaTeX text from older files.