rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.78k stars 1.27k forks source link

Equations not labeled in PDF output? #217

Closed zkamvar closed 8 years ago

zkamvar commented 8 years ago

I notice that, while reference equations display properly in HTML, they do not display their equation number in PDF. I generated an example that works on my machine using the bookdown demo (https://github.com/zkamvar/bookdown-demo/blob/master/01-intro.Rmd):

image

Here's my sessionInfo:

Session Info ``` Session info --------------------------------------------------------------------------- setting value version R version 3.3.1 (2016-06-21) system x86_64, darwin13.4.0 ui RStudio (1.0.25) language (EN) collate en_US.UTF-8 tz America/Los_Angeles date 2016-10-04 Packages ------------------------------------------------------------------------------- package * version date source assertthat 0.1 2013-12-06 CRAN (R 3.2.0) bookdown 0.1.15 2016-10-04 Github (rstudio/bookdown@c0b02d4) devtools 1.12.0 2016-06-24 CRAN (R 3.3.0) digest 0.6.10 2016-08-02 CRAN (R 3.3.0) evaluate 0.9 2016-04-29 CRAN (R 3.2.5) htmltools 0.3.5 2016-03-21 CRAN (R 3.2.4) httpuv 1.3.3 2015-08-04 CRAN (R 3.2.0) knitr 1.14.9 2016-10-04 Github (yihui/knitr@63407ab) magrittr 1.5 2014-11-22 CRAN (R 3.2.0) memoise 1.0.0 2016-01-29 CRAN (R 3.2.3) mime 0.5 2016-07-07 cran (@0.5) miniUI 0.1.1 2016-01-15 CRAN (R 3.2.4) R6 2.1.3 2016-08-19 cran (@2.1.3) Rcpp 0.12.7 2016-09-05 cran (@0.12.7) rmarkdown 1.0.9014 2016-09-21 Github (rstudio/rmarkdown@81c2092) rsconnect 0.4.3 2016-05-02 CRAN (R 3.3.0) shiny 0.13.2.9005 2016-09-02 Github (rstudio/shiny@1ff52c5) stringi 1.1.1 2016-05-27 CRAN (R 3.3.0) stringr 1.1.0 2016-08-19 cran (@1.1.0) tibble 1.2 2016-08-26 cran (@1.2) withr 1.0.2 2016-06-20 cran (@1.0.2) xtable 1.8-2 2016-02-05 CRAN (R 3.2.3) yaml 2.1.13 2014-06-12 CRAN (R 3.2.0) ```

Here's my pandoc version:

pandoc version 1.16.02 ``` pandoc 1.16.0.2 Compiled with texmath 0.8.4.1, highlighting-kate 0.6.1. Syntax highlighting is supported for the following languages: abc, actionscript, ada, agda, apache, asn1, asp, awk, bash, bibtex, boo, c, changelog, clojure, cmake, coffee, coldfusion, commonlisp, cpp, cs, css, curry, d, diff, djangotemplate, dockerfile, dot, doxygen, doxygenlua, dtd, eiffel, email, erlang, fasm, fortran, fsharp, gcc, glsl, gnuassembler, go, haskell, haxe, html, idris, ini, isocpp, java, javadoc, javascript, json, jsp, julia, kotlin, latex, lex, lilypond, literatecurry, literatehaskell, llvm, lua, m4, makefile, mandoc, markdown, mathematica, matlab, maxima, mediawiki, metafont, mips, modelines, modula2, modula3, monobasic, nasm, noweb, objectivec, objectivecpp, ocaml, octave, opencl, pascal, perl, php, pike, postscript, prolog, pure, python, r, relaxng, relaxngcompact, rest, rhtml, roff, ruby, rust, scala, scheme, sci, sed, sgml, sql, sqlmysql, sqlpostgresql, tcl, tcsh, texinfo, verilog, vhdl, xml, xorg, xslt, xul, yacc, yaml, zsh Default user data directory: /Users/zhian/.pandoc Copyright (C) 2006-2015 John MacFarlane Web: http://pandoc.org This is free software; see the source for copying conditions. There is no warranty, not even for merchantability or fitness for a particular purpose. ```
yihui commented 8 years ago

I think you need to use the equation environment instead of just the display style $$ $$: https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html It is funny, though, that LaTeX actually generated the equation number when it rendered the reference.

zkamvar commented 8 years ago

LaTeX actually generated the equation number when it rendered the reference

Actually, it didn't. When you click on that link, it goes to Chapter 3 ¯_(ツ)_/¯

Switching to equation environment works, and it also works in html for the demo. I've got a bit more complicated case over at https://github.com/zkamvar/beaverdown (html only renders with $$ and latex only renders with equation), but I'll save that for when I can get a MWE, by which time I'll probably have figured it out ᕕ( ᐛ )ᕗ

yihui commented 8 years ago

Your Pandoc version is probably too low. If you use RStudio, please install the preview version as documented: https://bookdown.org/yihui/bookdown/get-started.html The preview version ships Pandoc 1.17.2.

zkamvar commented 8 years ago

This worked. I actually had the preview version, but was rendering from the command line, so my own version of pandoc (1.16.2) was being used. Thanks!

yihui commented 8 years ago

FYI I have this in my .bash_profile to make sure pandoc in RStudio is used:

$ tail -n1 ~/.bash_profile 
export PATH="$PATH:/Applications/RStudio.app/Contents/MacOS/pandoc"

You can also add a symlink to, e.g., /usr/local/bin, but sometimes I need to test different versions of Pandoc by brew install pandoc, so I'd rather leave /usr/local/bin clean.

github-actions[bot] commented 4 years ago

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.