LaTeXiT for equations: automatic conversion possible?

Hi all,

I noticed very pleased that the latest version of Scrivener got an update in terms of MMD ==> LaTeX usability, as it is now fully included in the GUI. Great for technical science, thanks.

Right now I am configuring my workflow for a PhD thesis and LaTeXiT is a tremendous tool for editing equations and drag’n’drop them as a small PDF into Scrivener. When editing the formula, you can just drag’n’drop the PDF-snippet back to LaTeXiT and edit the file. Great stuff. Obviously the TeX code for the equation is stored in a comment file of the snippet and can be re-interpreted by LaTeXiT.

When compiling the draft with the snippets via MMD into LaTeX, all the equations are preserved, included as images named “PastedGraphic.pdf” and “PastedGraphic4.pdf” and so on. So a final manual task would be to replace them with the standard \begin{equation} \label{…} … \end{equation} to make them real formulas in LaTeX for the final manuscript.

But as the TeX-code is obviously already included in the PDF-snippet, is there no way to set up some clever replacement in order to do this automatically on the way compiling from a Scrivening to LaTeX? Basically look for PDF-snippets with the LaTeXiT-code filled and convert them to the standard equation syntax for LaTeX. This would be a great time-saver for large works with lots of equations.

Anyone with an idea? Hope I could make the idea clear, it is getting difficult to quickly describe workflows like that.

Best,
Chilichiller

OK, nobody seems to have an idea how to do this.

Now I modified my workflow a little, so that I am basically using 100% TeX code for equations, such as [ and ] and suitable replacements (I love them). It is not as visually appealing as the PDF images of LaTeXiT, but one step less to do as it produces instantly nice LaTeX code.

Cheers,
Chilichiller

I’m new to Scrivener and am looking at using LaTeXit with Scrivener to write my equations. I found this 10-year old post that is asking a similar thing. With the latest Srivener 3.2.3, it still seems quite the same as what this post says. I.e. use LaTeXit to construct an equation and drag the PDF image into Scrivener. To edit this equation, just drag it back to LaTeXit and edit the equation there. But if I double-click or right-click and select ‘Detect and typeset equations’, LaTeXit is fired up, but nothing is pasted into it. Do I need to do any settings on Scrivener or LaTeXit to make the equation editable by clicking on it? I.e. similar to editing Latex equations in Apple’s Pages?

JM.

Are you certain that you are using LaTeX, when you edit equations in Pages? I have read that for some years now the iWork suite has provided its own native equation editing and typesetting code. The only technology I am aware of that would make it possible for double-click editing to work is LinkBack, which was discussed years ago. As adoption rate has not really changed since then (you’ll note a number of the programs in that list don’t even exist anymore), I doubt there will be any change in opinion.

Basic Integration

At any rate, there are two ways of working with a equations in 99% of editors on the Mac:

  1. Use the LaTeXiT window itself to create it, and drag the result into the editor (vector PDF is usually best). This is probably the best way for starting a new one, as you can more easily fix typos and such. But like I say, you can use your own preferred tool here to get the notation itself.
  2. The second method is also what you would use to edit an equation you’ve already added to Scrivener. Right-click on the equation and select “Revert equations back to LaTeX code”, from the Services menu. It can be edited right there in the editor, or copy-pasted into LaTeXiT (or elsewhere) if one wishes. If edited inline, in the end you select the equation text in Scrivener, right-click and use the “Detect and typeset equations” service.

So obviously a couple of keyboard shortcuts on the Services pair is going to be very handy, but otherwise that’s about it. As I say to people when I suggest it, it’s not quite as seamless as LinkBack, but with the shortcuts it’s really not that bad.

Better Compile Output

Now as for compiling, one thing to consider is that we can use the LaTeXiT PDF as a thumbnail for our own utility and reference, rather than something that gets compiled. If we are creating a .tex file, there is no reason at all to be generating a PDF file of the equation and inserting that into the output. So here is how we could create a more effective document:

  1. Create a sample throw-away project to test with, using the “General Non-Fiction (LaTeX)” project template.
  2. Expand the Templates folder, in Research, and click on “Equation”. There is a little example text in here that is pre-selected. Place the cursor at the beginning of the line, and press ⇧⌘A (or Insert ▸ Inline Annotation), and type in " Insert LaTeXiT Equation " (with spaces around the sides, purely for cosmetic reasons), and press Return.
  3. At this point you can select the sample text in green again, so that it remains selected when creating new equations from this template. These steps could also be repeated for the Unnumbered Equation template, naturally.

On the left we have some sample text in Scrivenings view, showing the equation template in action. The rendered copy (including the carriage return after it, importantly) is within an inline annotation, indicated by the light red border. All that really compiles from this is the green text below it, which thanks to the way this project is set up, actually prints into the .tex file as:

\begin{equation} \label{scrivauto:7}
\int_0^\infty
\end{equation}

That’s just one idea of course. You could also use the main editor for the thumbnail entirely, and use a custom metadata field in the inspector to output the equation text itself. That way you don’t have to worry about the inline annotation part.

1 Like

Hi cjm,

If I could, I would upvote AmberV’s posting regarding the “General Non-Fiction (LaTeX)” project template, et al. A few thoughts:

  1. I have never used or worked with LaTeXiT, so I cannot comment.

  2. Starting with the “General Non-Fiction (LaTeX)” project template that AmberV referenced in their posting above, I’ve been working with Scrivener+LaTeX for the last two+ years.

  3. Scrivener+LaTeX offers an amazing array of functions for equations. Equations are the reason why I dove into the combined Scrivener+LaTeX code structure to provide me with a platform that is unequalled.

  4. That unequaled platform, however, comes at a cost. If you are looking for what Scrivener+LaTeX can offer for equations, that brings me to a few questions to consider if you are thinking of adopting the Scrivener+LaTeX construct:

  • What functionality and flexibility for equations, et al. are you ultimately looking for?
  • What personal time and coding resources are at your disposal?
  • What coding knowledge do you bring to your project? (and most important)
  • What time do you have to dedicate to learning how to meld Scrivener+ LaTeX together (mostly to learn about LaTeX)?

A sampling of the more than 100 equations I currently have includes:

If you are not looking for type of flexibility in your equations as I’ve shown above, then you may not need to subscribe and commit to the full blown Scrivener+LaTeX model that I have adopted, and LaTeXit may be enough to give you the flexibility you need.

FYI, StackExchange is an excellent, indispensable resource for LaTeX that I use almost every day. There are also many postings for LaTeXit there as well, but I have never used SE for LaTeXit.

HTH,
scrive
:thinking:

1 Like