Page 3 of 3

### Re: How to compile a Scrivener document to Latex?

Posted: Mon Jun 10, 2019 9:12 pm
Make sure you are implementing the workaround as suggested, to the Markup pane.

Aha! I didn't realize that was the suggested way to implement the workaround. I just did as you commanded, and it worked beautifully! After two weeks of despair and struggle to figure out how to proceed, I think this is all I need to get back to writing. Thank you!

Last question (for now, I think): Using the workaround via Markup, the name of the equation is suppressed, and instead I get "Equation 1.1". Is there a way to have the "E" in "Equation" be lowercase, instead of upper?

### Re: How to compile a Scrivener document to Latex?

Posted: Mon Jun 10, 2019 9:46 pm
Ah, and now you begin your descent into the wonderful and mad world of LaTeX customisation.

The first thing you need to learn is how to figure out when it is Scrivener and when it isn’t. The best way to do that is to open the .tex file, scroll to the spot, and see what you have there. Does the word “Equation” prefix any numerals in the file? Nope… so that must be coming during the typesetting process—much like the numbers beside the equation exist nowhere in the .tex file.

It is producing that label automatically, and “Equation” is its default way of referring to equations. That is flexible, if you want it to refer to them as bananas, you could do so. Copy and paste the following line into a convenient place, like the Equation Packages module in front matter:

Code: Select all

\renewcommand{\equationautorefname}{equation}

The quick summary of what this does:

• \renewcommand is how we change macros that already have been defined.
• In this case the \equationautorefname macro is very simple, it prints the word “Equation” wherever you use it.
• So the first part of the renewcommand stipulates which command to renew, the second part in brackets stipulates the value. If you’ve ever done programming this is a bit like variable=value. Where it gets trickier is when the right hand side is comprised of more macros. Fortunately in this case it’s very straightforward.
• Thus this line says we want the system to print “equation” wherever this macro is called.

You can make it “eq.” if you want, as well.

To come back to something I said earlier, this might be the kind of thing your publisher is all set up to do with a house style. The nice thing about LaTeX is this in fact: in your text you have \autoref{someequation}, and that’s it. How that prints is up to the “preamble”, which is the configuration for the document. What that means is that if you hand your publisher a file with the autoref stuff in place, and they have a comprehensive configuration for how equation cross-refs should be printed, you needn’t worry about the particulars yourself.

Just squint around the defaults in the meanwhile—but if they really bother you, you’ll usually have to do a little digging. For that I recommend the TeX StackExchange site. Every newbie to extremely advanced level question has been asked there, I’d bet.

Learning how to find the answer is as much a learning curve as anything else about this system. I also suggest the WikiBook, which will help you find the right words to communicate with search engines, as well as provide you with some basics of the system.

LaTeX is pretty simple on some levels, especially at the level a writer is meant to use it at. Once you get into the design or even minor customisation though, expect the learning curve to very promptly and abruptly go vertical. It’s a very old system that has had many decades and many thousands of users contributing to it over that span of time. There are layers upon layers of macros doing the stuff we take for granted, like \autoref.

My advice, stick to using the defaults unless you really, really need to change something and your publisher says its definitely up to you to do so (like maybe they don’t use hyperref, which includes the autoref command, and then you would need to adjust the Markup pane to use a different macro).

Another piece of advice: go slow. Import one chapter, convert it, clean it, test it both separately and then integrated with the whole thus far. Then move on to the next chapter.

### Re: How to compile a Scrivener document to Latex?

Posted: Mon Jun 10, 2019 9:52 pm
AmberV wrote:Ah, and now you begin your descent into the wonderful and mad world of LaTeX customisation. :lol

The first thing you need to learn is how to figure out when it is Scrivener and when it isn’t.
Got it. Thanks, the explanation that followed this helps.

To come back to something I said earlier, this might be the kind of thing your publisher is all set up to do with a house style.
I'm actually sure you're absolutely right. I will, as you say, squint in the meantime.

Another piece of advice: go slow. Import one chapter, convert it, clean it, test it both separately and then integrated with the whole thus far. Then move on to the next chapter.
Will do! Thanks again!!!

### Re: How to compile a Scrivener document to Latex?

Posted: Tue Jun 11, 2019 12:26 pm
Two pieces of news for you:

1. The bug with linking placeholders has been fixed and will be available in the next minor update (which will be soon). Consequently you should be safe in using that approach—though as noted it shouldn’t typically be necessary unless you want to create a cross-reference in a style that doesn’t match how the Markup pane is set to work.
2. The next update will also include an improved version of the LaTeX project template. I’ve added documentation for equations to the help file, and have also added an “Equation” style, which can be used to create equations in the main text rather than having them in separate binder items. On the one hand it should make sections with a lot of display equations easier to work with (not broken up so much in the binder), but on the other hand the automation with cross-references and label creation depend upon section layouts. So you’ll have to supply your own label to them in the manner documented, and refer to them with typed in \autoref{…} calls (though I suppose you could make a style to handle the syntax for you, if you wanted to).

I’ve attached the template for now (the updated template is now available in the official version of Scrivener). To “upgrade” your project (I would recommend File ▸ Back Up ▸ Back Up To... first, just in case something goes wrong!):

1. First import the template with the Options button along the bottom of the New Project window. You’ll get two entries, you can check which is which by right-clicking on their tiles and seeing which one allows you to rename/delete.
2. Create a throw-away project with the new template and open your WIP.
3. From the WIP, use the Format ▸ Style ▸ Import Styles... menu command, and target the throw-away project. Replace any style collisions when asked.
4. Next you’ll need to update the compile format. Open File ▸ Compile... in both projects.
5. In your WIP, either rename or delete the “LaTeX (Memoir Book)” Format. I’d delete, but if you’ve already done some customisation to it, you might want to set it aside and merge those changes into the updated format.
6. From the throw-away project, drag and drop its copy of “LaTeX (Memoir Book)” into the Format sidebar of your WIP to import it.

That should be it! There are a few other very minor adjustments I made (like fixing that natbib typo), but nothing worth bothering over.

I considered adding some sample material, but I’ll have to save that for a future iteration.

### Re: How to compile a Scrivener document to Latex?

Posted: Tue Jun 11, 2019 8:10 pm
AmberV wrote:Two pieces of news for you

Wow, this is great. Thanks!

The bug with linking placeholders has been fixed and will be available in the next minor update (which will be soon). Consequently you should be safe in using that approach—though as noted it shouldn’t typically be necessary unless you want to create a cross-reference in a style that doesn’t match how the Markup pane is set to work.

I'm not sure I ever followed what the bug is...

The next update will also include an improved version of the LaTeX project template. I’ve...also added an “Equation” style, which can be used to create equations in the main text rather than having them in separate binder items. On the one hand it should make sections with a lot of display equations easier to work with (not broken up so much in the binder), but on the other hand the automation with cross-references and label creation depend upon section layouts. So you’ll have to supply your own label to them in the manner documented, and refer to them with typed in \autoref{…} calls (though I suppose you could make a style to handle the syntax for you, if you wanted to).[/list]

This is great. I think I personally will stick to having my non-inline equations being separate binder items, as the automated cross-referencing via "Link to Document" is really handy and quick (especially now that I can suppress the equation name--via the changes in the Markup pane--to yield just "Equation (1.1)".

One other small item that I'm not sure can be addressed in an ideal way for me: When I copy an equation in MathType, the copied LaTex code is flanked by "$" on the left and "$" on the right, a la:

Code: Select all

$2 + 2 = 5$

But your Equation binder template wants only "2+2=5". Is there any way to allow me to just paste in

Code: Select all

$2 + 2 = 5$
and have the flanking slashes and brackets stripped away in compile? I just ask because it would be great to not have to remove the slashes and brackets each time I copy an equation from from MathType and paste into your Equation binder item. That said, it's also not the end of the world.

### Re: How to compile a Scrivener document to Latex?

Posted: Tue Jun 11, 2019 8:53 pm
Is there no setting in MathType to remove that? It seems rather presumptuous to me that assume that is the type of environment you want whenever you copy an equation out of it. But what do I know, I've never written anything that requires extensive formulae.

Well I'd get them all pasted in incorrectly and then fix them all at once. One nice thing about keeping your equations in separate binder items is that you can run a project search for them. Search for "Equation" by Section Type, click the hook arrow button in the search results header bar, and switch to Scrivenings mode. Now you can use simple search and replace to nuke them all at once (probably make a backup before doing that, just in case!)

### Re: How to compile a Scrivener document to Latex?

Posted: Wed Jun 12, 2019 5:13 pm
AmberV wrote:One nice thing about keeping your equations in separate binder items is that you can run a project search for them. Search for "Equation" by Section Type, click the hook arrow button in the search results header bar, and switch to Scrivenings mode. Now you can use simple search and replace to nuke them all at once (probably make a backup before doing that, just in case!)

Amazing, I am continually amazed by how flexible Scrivener is.

### Re: How to compile a Scrivener document to Latex?

Posted: Tue Jul 30, 2019 10:07 pm
AmberV wrote:One nice thing about keeping your equations in separate binder items is...

Hi AmberV, I'm baaaack Today question: Is there a way to tweak the LaTex template so that references to Equation binder items use "\eqref" instead of "\autoref"? Or would a change to implement that also change all other references (e.g. refs to chapters, etc.)?
Thanks!

### Re: How to compile a Scrivener document to Latex?

Posted: Wed Jul 31, 2019 8:35 am
Given autoref’s goal of providing adaptive cross-reference styles depending upon the type of element you are referring to, my first question would be: what qualities of eqref are you looking for, that you wish autoref did? Chances are you can make autoref work the way you want for equations, without changing how it works for other things.

Here’s something to get you started: Combining \autoref and \eqref.

To answer your literal question: you can see the full range of options in the Markup compile format pane. The two types of links it distinguishes between are external and internal links. It would need a much more complicated UI and implementation to change the prefix/suffix based on the Section Type of the thing the link points to.

There may be a solution that involves the Document Title Links compile format pane being enabled, so as to get prefix/suffix link adornment, then a whole wad of regular expression based replacements to basically undo the effects of that setting for most of those (so you don’t get “\chapter{Something} (\autoref{scrivauto:38})”, and more replacements to convert how some links like the above are cleaned up to eqref—but I think we’d really be pressing the definition of utility and clean output design by going down that path.

Again, I think this problem can (and should) be delegated to LaTeX, and to the hyperref package specifically.

### Re: How to compile a Scrivener document to Latex?

Posted: Mon Aug 05, 2019 8:37 pm
AmberV wrote:...my first question would be: what qualities of eqref are you looking for, that you wish autoref did?

Thanks very much. I wanted eqref because it adds the parentheses around the equation name. The trick given in the link you provided didn't work for me, although I suspect I just implemented it poorly (due to my poor understanding of what it does).

I found a solution that works fine for me: After compiling to LaTex from Scrivener, I open the .tex document with a lightweight Tex editor named Geany. That has the ability to find/replace strings with a carriage return, so that I can find all instances of

Code: Select all

%Equation \n\\autoref

and replace them with

Code: Select all

%Equation \n\\eqref
. (That's the search string because I have suppressed "Equation" by using your internal link prefix trick in Compile > Markup.)

This search/replace trick works only if all my equations are titled Equation (i.e. the stock Template name) in the sidebar. Some people might find that limiting/annoying, but I'm living with it just fine. With this workflow, I am able to refer to any equation using its "parenthesized" name, adding an word before that name that I want. And that gives me all the flexibility I want.