Skip to content

Building gitbook with local mathjax gives Invalid argument error #668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mterente opened this issue Jan 8, 2019 · 5 comments
Closed

Building gitbook with local mathjax gives Invalid argument error #668

mterente opened this issue Jan 8, 2019 · 5 comments

Comments

@mterente
Copy link
Contributor

mterente commented Jan 8, 2019

Hi all,

I'm trying to build a book in gitbook format with local mathjax, via the YAML header options:

output:
  bookdown::gitbook: 
    mathjax: local
    self_contained: false

However, I'm getting the following error:

pandoc.exe: libs/mathjax-local/MathJax.js?config=TeX-AMS-MML_HTMLorMML: openBinaryFile: invalid argument (Invalid argument)
Error: pandoc document conversion failed with error 1

Many thanks for this beautiful package!

Mihai

local-mathjax-error-MWE.zip

> devtools::session_info('bookdown')
- Session info ----------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.4.3 (2017-11-30)
 os       Windows 7 x64 SP 1          
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  English_United States.1252  
 ctype    English_United States.1252  
 tz       Europe/Istanbul             
 date     2019-01-08                  

- Packages ----------------------------------------------------------------------------------------------------
 package   * version date       lib source                            
 base64enc   0.1-3   2015-07-28 [1] CRAN (R 3.4.0)                    
 bookdown    0.9.1   2019-01-08 [1] Github (rstudio/bookdown@dc33d2f) 
 digest      0.6.18  2018-10-10 [1] CRAN (R 3.4.4)                    
 evaluate    0.12    2018-10-09 [1] CRAN (R 3.4.4)                    
 glue        1.3.0   2018-07-17 [1] CRAN (R 3.4.4)                    
 highr       0.7     2018-06-09 [1] CRAN (R 3.4.4)                    
 htmltools   0.3.6   2017-04-28 [1] CRAN (R 3.4.0)                    
 jsonlite    1.6     2018-12-07 [1] CRAN (R 3.4.4)                    
 knitr       1.21    2018-12-10 [1] CRAN (R 3.4.4)                    
 magrittr    1.5     2014-11-22 [1] CRAN (R 3.4.0)                    
 markdown    0.9     2018-12-07 [1] CRAN (R 3.4.4)                    
 mime        0.6     2018-10-05 [1] CRAN (R 3.4.4)                    
 Rcpp        1.0.0   2018-11-07 [1] CRAN (R 3.4.4)                    
 rmarkdown   1.11.3  2019-01-08 [1] Github (rstudio/rmarkdown@b209cdc)
 stringi     1.2.4   2018-07-20 [1] CRAN (R 3.4.4)                    
 stringr     1.3.1   2018-05-10 [1] CRAN (R 3.4.4)                    
 tinytex     0.9.4   2019-01-08 [1] Github (yihui/tinytex@7a889fb)    
 xfun        0.4     2018-10-23 [1] CRAN (R 3.4.4)                    
 yaml        2.2.0   2018-07-25 [1] CRAN (R 3.4.4) 

> rmarkdown::pandoc_version()
[1] ‘2.3.1’

> system('pdflatex --version')
pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018/W32TeX)
kpathsea version 6.3.0
Copyright 2018 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.34; using libpng 1.6.34
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.00

@ashgreat
Copy link

Were you able to resolve this? I am getting the same error.

@mterente
Copy link
Contributor Author

Unfortunately, not...

@cderv
Copy link
Collaborator

cderv commented Aug 27, 2020

Sorry all, it has been a while. Thanks for your patience.

As of today, I can't reproduce this issue with last version of packages and last pandoc 2.7. shipped with RStudio

# work in temp folder
dir.create(tmp_dir <- tempfile())
old <- setwd(tmp_dir)
# download the example
url <- "https://github.com/rstudio/bookdown/files/2737261/local-mathjax-error-MWE.zip"
xfun::download_file(url)
#> [1] 0
list.files()
#> [1] "local-mathjax-error-MWE.zip"
unzip(basename(url))
list.files()
#> [1] "local-mathjax-error-MWE"     "local-mathjax-error-MWE.zip"

# set wd to the downloaded folder
setwd(xfun::sans_ext(basename(url)))
list.files()
#> [1] "bookdown-minimal.Rproj" "index.Rmd"
# to see the file: 
xfun::file_string("index.Rmd")
#> ---
#> title: "A Book"
#> author: "Frida Gomam"
#> site: bookdown::bookdown_site
#> documentclass: book
#> output:
#>   bookdown::gitbook: 
#>   # default
#>     mathjax: local
#>     self_contained: false
#>   #bookdown::pdf_book: default
#> ---
#> 
#> # Hello World
#> 
#> Hi.
#> 
#> Bye.
#> 
#> <!-- If you need PDF output, uncomment bookdown::pdf_book above in YAML. You will need a LaTeX installation, e.g., https://yihui.name/tinytex/ -->
#> 
#> Sample formula: 
#> 
#> \begin{equation}
#> E = mc^2
#> (\#eq:mass-energy)
#> \end{equation}

# tested with pandoc 2.7.3
rmarkdown::find_pandoc(version = "2.7.3")
#> $version
#> [1] '2.7.3'
#> 
#> $dir
#> [1] "C:/Program Files/RStudio/bin/pandoc"

# render the book with no error.
bookdown::render_book("index.Rmd")
#> processing file: _main.Rmd
#> output file: _main.knit.md
#> "C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS _main.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output _main.html --email-obfuscation none --wrap preserve --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\Users\chris\Documents\R\win-library\4.0\bookdown\templates\gitbook.html" --highlight-style pygments --number-sections --include-in-header "C:\Users\chris\AppData\Local\Temp\RtmpiaQHoi\rmarkdown-str4fc84c462a0b.html" "--mathjax=libs/mathjax-local/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "C:/Users/chris/Documents/R/win-library/4.0/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/4.0/rmarkdown/rmd/lua/latex-div.lua"
#> 
#> Output created: _book/index.html
#> [1] "C:/Users/chris/AppData/Local/Temp/RtmpiaQHoi/file4fc81b2e2abb/local-mathjax-error-MWE/_book/index.html"

# clean
setwd(old)
unlink(tmp_dir, recursive = TRUE)

@mterente, @ashgreat, If any of you two still encounter this issue can you provide more information please ?
I am currently look at mathjax handling with gitbook

this issue you encountered should not be but let's also note that there is an issue with mathjax = "local" anyway because it is not correctly supported : An online mathjax will be used. See #915 (comment)

@cderv cderv self-assigned this Aug 27, 2020
@cderv
Copy link
Collaborator

cderv commented Mar 24, 2021

I still can't reproduce this and there was no answer since my last reply.

I'll close this. Please open a new issue linking this one if you still have issues not covered by one of the other mathjax related ones.

@cderv cderv closed this as completed Mar 24, 2021
@cderv cderv removed their assignment Mar 24, 2021
@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants