pandoc-latex-template icon indicating copy to clipboard operation
pandoc-latex-template copied to clipboard

[Bug] The bidi package is loaded too early

Open daamien opened this issue 3 years ago • 1 comments

Hi !

Thanks for this template, it is a very impressive piece of work.

I'm currently trying to use it for a document written in Persian with Right-to-Left (RTL) writing. The original document is located here:

https://github.com/OWASP/owasp-masvs/tree/master/Document-fa

I created a minimal example document.md containing this :

---
mainfont: 'Nazli'
---
<div dir="rtl" markdown="1">

انقلاب‌های فناورانه می

</div>

Note that I don't speak or read Persian myself so my knowledge on this topic is limited.

I am able to build successfully a pdf artefact using the default pandoc latex template like this:

$ pandoc --pdf-engine=xelatex examples/language-persian/document.md -o examples/language-persian/document.pdf

However with eisvogel I get the following error:

$ pandoc --template=eisvogel --pdf-engine=xelatex examples/language-persian/document.md -o examples/language-persian/document.pdf      
Error producing PDF.                                                                                                                                                           
! Package bidi Error: Oops! you have loaded package caption after bidi package.                                                                                                
 Please load package caption before bidi package, and then try to run xelatex o                                                                                                
n your document again.                                                                                                                                                         
                                                                                                                                                                               
See the bidi package documentation for explanation.                                                                                                                            
Type  H <return>  for immediate help.                                                                                                                                          
 ...                                                                                                                                                                           
                                                                                                                                                                               
l.251 \begin{document}  

After looking into the template I have found 3 problems:

  • The caption package is loaded after bidi (Line 601) https://github.com/Wandmalfarbe/pandoc-latex-template/blob/master/eisvogel.tex#L601

  • The mdframed package is loaded after bidi (Line 610) https://github.com/Wandmalfarbe/pandoc-latex-template/blob/master/eisvogel.tex#L610

  • The polyglossia package is loaded after bidi (Line 557 and it is also loaded before on line 434) https://github.com/Wandmalfarbe/pandoc-latex-template/blob/master/eisvogel.tex#L557 https://github.com/Wandmalfarbe/pandoc-latex-template/blob/master/eisvogel.tex#L434

The template seems to work with the following modifications:

  • Move the caption and mdframed section before bidi
  • Comment the second polyglossia load

Here's my working version of eisvogel:

https://github.com/daamien/pandoc-latex-template/blob/bug_bidi_persian/eisvogel.tex

Thanks again for your time, let me know how I can help fixing this...

EDIT: fixed links

daamien avatar Mar 02 '21 14:03 daamien

See PR #231 with my changes

daamien avatar Mar 02 '21 14:03 daamien