0

Following the recommendation of the kind user in this post: PDFLaTeX and Arabic, Farsi and other scripts

I switched compilers, from Pdftex to Luatex in order to be able to print non-Latin alphabets, which works.

What doesn't work is my shell script to automatically convert from markdown, via pandoc, to a .tex file, to a PDF via Latexmk. I had this working perfectly, but I don't know how to do it for Luatex.

This was the script:

mkdir -p /home/Docs/Notes/{{title}} 
pandoc -r markdown-auto_identifiers -w latex {{file_path:absolute}} -o /home/Docs/Notes/{{title}}/{{title}}.tex --template="/home/Docs/LaTeX/My Templates/Notes/Notes.tex" --lua-filter=/home/Docs/LaTeX/Filters/highlight.lua --lua-filter=/home/Docs/LaTeX/Filters/highlight-period.lua --lua-filter=/home/Docs/LaTeX/Filters/Span.lua --lua-filter=/home/Docs/LaTeX/Filters/Span-period.lua
gnome-terminal -- bash -c "cd /home/Docs/Notes/{{title}} && latexmk -pvc -pdf < /dev/null && latexmk -c && cp {{title}}.pdf /home/Docs/Notes/ && exit; exec bash"

I run this from a plugin in Obsidian.md (a markdown editor) that can replace the {{title}} variables with the current note, i.e. file, name.

With the above script, I get told:

! Package babel Error: The bidi method 'basic' is available only in
(babel)                luatex. I'll continue with 'bidi=default', so
(babel)                expect wrong results.

I believe only the part after gnome-terminal is relevant, and I tried switching the latexmk command to this: latexmk -pdflatex=lualatex -pdf {{title}}.tex

With this it compiles a little further, but still get an error, and no PDF is produced.

=== TeX engine is 'pdfTeX'
Latexmk: Found input bbl file '2023-07-24.bbl'
Latexmk: Log file says output to '2023-07-24.pdf'
Biber warning: [177] Biber.pm:130> WARN - The file '2023-07-24.bcf' does not contain any citations!
Latexmk: Found biber source file(s) [2023-07-24.bcf]
Latexmk: All targets (2023-07-24.pdf) are up-to-date
Rc files read:
  /etc/LatexMk
Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76.
cp: cannot create regular file '/home/Docs/Notes/': Not a directory

My MWE LaTeX Document from the other thread:

\documentclass[a4paper, 12pt, oneside]{article}

\usepackage[bidi=basic]{babel}

\babelprovide[main, import]{english} \babelprovide[onchar = ids fonts]{arabic} \babelfont[arabic]{rm}[Renderer = HarfBuzz, Scale = MatchLowercase]{Amiri}

\begin{document} Giaurs - From Persian فروشگاه‎ (gâvor) \end{document}

How can I adapt this script to automate the process once again.

Thanks!

1 Answers1

2

latexmk will use pdflatex by default (or explicitly via the -pdf option on the commandline). You can replace that by -pdflua or equivalently -lualatex

David Carlisle
  • 757,742
  • Now it seemingly mostly works, as in it's opening a compiled PDF in chromium which is weird because that's not my default PDF viewer at all. Also it's still not copying the new PDF to the desired directory, telling me Latexmk: This is Latexmk, John Collins, 20 November 2021, version: 4.76. cp: cannot create regular file '/home/Docs/Notes/': Not a directory which is strange since it is a directory. – ReaderGuy42 Aug 23 '23 at 15:04
  • In the output listings, latexmk says it had success. The error message appears to be from the command cp {{title}}.pdf /home/Docs/Notes/ (with presumably a correct substitution for {{title}}). Do you get the same error if you run the commands from the command line instead of a script? What are the contents of /home/Docs/Notes/? – John Collins Aug 23 '23 at 23:33
  • has title got a space in its name? – David Carlisle Aug 23 '23 at 23:56
  • sometimes, not always. The one I just tested did not. – ReaderGuy42 Aug 24 '23 at 11:41
  • @ReaderGuy42 your cp will fail if cp {{title}}.pdf /home/Docs/Notes/ expands to cp foo bar.pdf /home/Docs/Notes/ it needs quotes around the file name – David Carlisle Aug 24 '23 at 11:45
  • @DavidCarlisle OK; I've added single quotes because the whole script here is already surrounded by quotes. This works now, and correctly compiles it to PDF. However, it's still not copying the resulting PDF to the desired directory and it's opening the PDF in chromium and the terminal isn't exiting. How do I fix all of this? Thanks! – ReaderGuy42 Aug 24 '23 at 11:53
  • I think the problem is that the file is opened and then the commands to copy the file and exit are never processed. I don't want the PDF to automatically open. How can I do this? – ReaderGuy42 Aug 24 '23 at 12:05
  • Figured it out! I need the -pv- option as that suppresses the opening of the preview. And then it can copy the file to the directory I want. Also in this case the variable {{title}} appears to take care of possible spaces, because if I add in single or double quotes it doesn't work and can't find the file. Without them it works. So the script now reads: gnome-terminal -- bash -c "cd /home/Docs/Notes/{{title}} && latexmk -pv- -pdflua < /dev/null && latexmk -c && cp {{title}}.pdf /home/Docs/PDFs/ && exit; exec bash" – ReaderGuy42 Aug 24 '23 at 12:30