Scriv4, Pandoc, Latex and citations

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Mon Jan 08, 2018 6:30 am Post

Hi,
I am just getting started with Scrivener 3. I am an academic (technical) writer, so I really need to use citations extensively. I also use Latex a fair bit, certainly enough to get tired of its editing, compiling converting to pdf cycle.
From what I have read, the best way to use citations and compile a bibliography with Scrivener is by using it with Pandora. But I have a few questions about this that I wonder if someone on this list would be kind enough to answer:

1) My understanding is that Pandoc provides a way for me to produce many different document formats, including docx, latex, and others. But Scrivener seems to want to use MMD for latex, pdf, etc, and use Pandoc only for docx, xml and epub. Why not allow the use Pandoc for latex and other formats?

2) Does anyone have a simple example that shows how to insert citations and compile a bibliography? (I currently use Papers 3 but may switch to Bookends).

3) I have seen references to "Scrivomatic" (https://github.com/iandol/scrivomatic) and "Using Scrivener as a Pandoc editor/previewer" (https://orthostat.wordpress.com/2014/06 ... previewer/). These look like what I want to do - anyone have any experience with them, positive or negative?

But basically, any advice for getting started with citations/bibliography would be much appreciated.

Thanks.

Ki
Kinsey
Posts: 283
Joined: Mon Apr 09, 2012 6:06 pm
Platform: Mac

Mon Jan 08, 2018 9:38 am Post

Theses threads might be helpful.

There is a discussion on the use of Papers 3 with Scrivener 3 here: viewtopic.php?f=2&t=40699&hilit=citations

A more general discussion on Scrivener in an academic workflow: viewtopic.php?f=19&t=33880

User avatar
nontroppo
Posts: 1067
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Mon Jan 08, 2018 9:59 am Post

(1) You can use Pandoc using the MultiMarkDown format post-processing Panel in Scrivener; this output format is unfortunately named (it was debated during beta testing, but ended up staying the same despite allowing both MMD and Pandoc conversion)...

(2) I have info for Bookends, but there are Papers3 users (@lunk comes to mind) who maybe can help you better. You need to be able to use a [@BiBTeXKey] style temporary citation copied from Papers into Scrivener. Then you simply pass a --bibliography=mybib.bib file to Pandoc and a CSL style and it does the rest. I can make a test project to show the Scrivener side if you want.

(3) I wrote the scrivomatic workflow, but you do not need to use my workflow, I'm happy to answer questions to guide you in your own way to run. I do think if you are outputting to more than one format, and perhaps several different templates within a format (I use two main LaTeX output styles for example, same for HTML, sometimes want to run reference conversion, sometimes not for DOCX), then using pandocomatic really makes everything much easier once you've set up your settings. You change one line in your Scrivener metadata, and change the whole compile chain without further fussing...

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Mon Jan 08, 2018 1:09 pm Post

Thank you Kinsey and nontroppo (Ian?),
I will check those out. Regarding (2) above, would it be possible to please provide me with the small test project? I think once I see how the information is passed from Scrivener to Pandoc, I will be able to move forward from there.
Many thanks,

- Phil

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Mon Jan 08, 2018 8:41 pm Post

I've followed your advice by exporting to a text file and running Pandoc from the terminal with the --bibliography option. That works great. If I can figure out how to pass the Pandoc arguments from Scrivener I think I will be in business. It must have something to do with the compile options or settings?

User avatar
AmberV
Posts: 22433
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Mon Jan 08, 2018 11:22 pm Post

Yeah, setting up custom command-line parameters is documented in the user manual under §24.22, starting on page 645. The Processing pane it refers to is something you would modify about a compile format itself, as documented at the top of that chapter, pg. 579.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Tue Jan 09, 2018 2:01 am Post

Hi again,
Thanks, I tried using defining a new format after duplicating the MMD one. My compile format pane looks like the attached. However, when I compile it says "cannot produce pdf output from pdf". (same result if I add <$inputfile> to the Arguments). I had thought the input file for the MMD compile format would be an md file?
- Phil
Attachments
Screen Shot 2018-01-09 at 12.54.48 pm.png
Screen Shot 2018-01-09 at 12.54.48 pm.png (78.83 KiB) Viewed 5978 times

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Tue Jan 09, 2018 4:36 am Post

Hi again,

I found that if I covert to docx instead of pdf it works. I.e., "--bibliography my bib.bib -t docx -o <$outputname>.docx" does the citation and makes the bibliography entry. I'm a little puzzled about why it won't do a pdf, but this is enough to get my started. Thanks!

- Phil

User avatar
nontroppo
Posts: 1067
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Tue Jan 09, 2018 6:14 am Post

You can find a full Pandocomatic workflow project attached, it bundles all needed files into the Binder: a BiBTeX and CSL file for the bibliography, custom Word/CSS/LaTeX templates and the pandocomatic.yaml config file needed to specify the compile options. Read Resources Instructions in the Binder for details how to set this up (basically Export all resource files to the folder you will compile to, move pandocomatic.yaml to your pandoc data directory, change path for processing tool). The workflow includes examples of captioned figures, and compilation of custom inline styles like superscript and strong-emphasis...

Workflow.scriv.zip
(321.8 KiB) Downloaded 358 times

Oz
OzPhil
Posts: 6
Joined: Mon Jan 08, 2018 5:56 am
Platform: Mac

Wed Jan 10, 2018 11:38 am Post

Wow, that's fantastic, nontroppo! it will take me a little while to digest, but looks like just what I was looking for. Thanks heaps for making it available. Cheers,
- Phil

mn
mnott
Posts: 44
Joined: Fri Nov 18, 2016 1:12 pm
Platform: Mac + Linux

Thu Feb 08, 2018 6:55 pm Post

You may also want to look at TeXDown:

http://github.com/mnott/texdown

Here I've done a video about my larger workflow:

https://youtu.be/86rnBMz6XnU

zs
zsteir
Posts: 17
Joined: Thu Oct 25, 2012 2:25 am
Platform: Mac

Mon Feb 12, 2018 11:26 pm Post

Hi. I wonder if you can help me (particularly nontroppo) with a problem: I see to get different results when running scrivomatic from the command line and from Scrivener. [I imagine this has to do with environment variables, but I'm not sure which].

General info: my metadata instructs Pandocomatic to convert to LaTeX. Notice, I am running Scrivomatic with the "--build" option. So...

From the command line, I run:

Code: Select all

/Users/xxx/bin/scrivomatic.rb workflow_mmd -v -b 2>&1 >>scrivomatic.log

It works perfectly.
But the very same code only produces the .tex when run from within scrivener, like so:
[img]Untitlted.jpg[/img]

It seems that Scrivomatic is reading the "-b" properly. I see the following in the log:

Code: Select all

#<struct Scrivomatic::OPT input="'workflow_mmd'", output=nil, to=nil, command="pandocomatic", envpath="/Users/zvb1/.rvm/wrappers/default:/Library/TeX/texbin:/Users/zvb1/bin:/usr/local/bin", build=true, verbose=true, dry_run=false, open_log=false>


But, alas, it doesn't try to run latexmk after the pandoc conversion. This is the full log for the *failed* run is attached. Any ideas? Many thanks.

.
Attachments
scrivomatic.txt
(3.09 KiB) Downloaded 217 times
Untitled.jpeg
Untitled.jpeg (89.98 KiB) Viewed 5265 times

zs
zsteir
Posts: 17
Joined: Thu Oct 25, 2012 2:25 am
Platform: Mac

Tue Feb 13, 2018 3:19 am Post

I’ve determined that Scrivomatic can’t find the .tex file (although it’s there). Not sure why.

User avatar
devinganger
Posts: 1219
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272 (CN97au)
Contact:

Tue Feb 13, 2018 4:13 am Post

zsteir wrote:I’ve determined that Scrivomatic can’t find the .tex file (although it’s there). Not sure why.


same owner? read permissions? Does it get launched via globbing and need execute permissions?

What's the log from a successful command line run look like?
--
Devin L. Ganger, WA7DLG
Not a L&L employee; opinions are those of my cat
Winner "Best in Class", 2018 My First Supervillain Photo Shoot

User avatar
nontroppo
Posts: 1067
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Tue Feb 13, 2018 9:20 am Post

zsteir: yes you are right, when Scrivener runs a command, it runs under a very basic environment which doesn't contain any paths or other settings, and scrivomatic tries to find various tools and adds the paths, sets to the environment. I've updated scrivomatic to V1.0.13 to provide more extensive logging during the call to latexmk, and possibly fixed a problem where the default environment that scrivener uses may cause a text encoding issue.

https://github.com/iandol/scrivomatic/b ... crivomatic

See if it fixes the problem. I've tested it with a complex document and it works fine here. By the way, I currently force the use of xelatex with latexmk, but you use pdflatex, not sure if this will cause problems. I could leave this open, or provide a command line option if it would help.

You can also use pandocomatic to output to PDF directly and then Pandoc calls latexmk rather than use scrivomatic to do it.