Giter Site home page Giter Site logo

Comments (4)

cpsievert avatar cpsievert commented on May 27, 2024

Oh, another thing, the markdown is always parsed for HTML output, but this problem happens when you do:

bookdown::render_book("index.Rmd", "bookdown::pdf_book")

from bookdown-crc.

yihui avatar yihui commented on May 27, 2024

You have to use text references: https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references

from bookdown-crc.

cpsievert avatar cpsievert commented on May 27, 2024

Great, this seems to fix a lot of the issues I was seeing, thanks!

Could you provide some intuition as why this is necessary? Even if it's just a useful workaround? Having a comment about this somewhere (either in the publishing section of the bookdown book or in this repo) would have saved me lots of time.

from bookdown-crc.

yihui avatar yihui commented on May 27, 2024

From the book:

[...] It is also useful when these captions contain special HTML or LaTeX characters, e.g., if the figure caption contains an underscore, it works in the HTML output but may not work in LaTeX output because the underscore must be escaped in LaTeX.

The text can contain anything that Markdown supports [...]

It is necessary to use a text reference in your case because your caption is not "plain-text": it contains formatting (with Markdown syntax). When out.width is used, knitr switches to hook_plot_tex to generate LaTeX code for graphics (i.e. the \begin{figure} \includegraphics{} \caption{} stuff), and Pandoc doesn't recognize Markdown in \caption{}. Without out.width, it generates Markdown ![](), and Pandoc can recognize Markdown in the caption [].

In short, you can only put the caption in fig.cap if the caption is not plain plain-text without any special characters in any languages. In other cases, it is only safe to use text references.

from bookdown-crc.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.