Skip to content
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

Equation labels not properly handled when pandoc 2.0 is used with gitbook output #504

Closed
dataopt opened this issue Dec 26, 2017 · 9 comments
Milestone

Comments

@dataopt
Copy link
Contributor

dataopt commented Dec 26, 2017

Here is a minimal example for a minimal book with the following index.Rmd

---
title: "A Book"
author: "Frida Gomam"
site: bookdown::bookdown_site
documentclass: book
output:
  bookdown::gitbook:
    split_by: section
  bookdown::pdf_book: default
---

# Test labels {-}

Second equation label is not replaced with proper tag when using pandoc 2.0

\begin{equation}
x \in \mathbb{R} (\#eq:real)
\end{equation}
Hello
\begin{equation}
y \in \mathbb{Z} (\#eq:integer)
\end{equation}

Screenshot of the generated gitbook:
screen shot 2017-12-26 at 4 55 46 am

@yihui yihui added this to the v0.6 milestone Dec 28, 2017
@yihui
Copy link
Member

yihui commented Dec 28, 2017

Could you add empty lines before and after Hello so that the equation can be in its own paragraph?

@dataopt
Copy link
Contributor Author

dataopt commented Dec 28, 2017

Unfortunately, making the equation a paragraph results in too much space in the latex output. Below are screenshots of before and after putting empty lines around Hello.
screen shot 2017-12-28 at 6 44 47 pm
screen shot 2017-12-28 at 6 45 23 pm

@yihui
Copy link
Member

yihui commented Dec 29, 2017

The spacing issue is easier to solve. A quick google search: https://tex.stackexchange.com/q/224987/9128

@dataopt
Copy link
Contributor Author

dataopt commented Dec 29, 2017

Thanks for the suggestion. Unfortunately, using setlength is more a hack than a solution to the problem since to get the desired spacing, I have to specify a negative value for abovedisplayskip. As the Rmd file contains perfectly valid syntax, the problem is probably a bug in bookdown.

@yihui
Copy link
Member

yihui commented Dec 29, 2017

I know exactly what the problem is in this case, and I also know to fix it. I just hope I don't have to touch it, for three reasons: (1) I often have too many other things to do; (2) there is a workaround (i.e. this issue does not really block you); (3) fixing bugs can introduce new problems.

@dataopt
Copy link
Contributor Author

dataopt commented Dec 29, 2017

I now also know exactly what the problem is. I'm making a pull request to pandoc to add newlines around inlined display math. This should solve the problem. I hope the PR gets accepted.

EDIT: I discovered a simpler solution that requires no changes in bookdown and pandoc. It is to add the following option:
pandoc_args: "--wrap=preserve"

Should this option become a default?

@yihui
Copy link
Member

yihui commented Dec 29, 2017

It is great to know --wrap=preserve fixed the issue. It is probably a reasonable default.

@yihui yihui closed this as completed in 6d52f55 Dec 29, 2017
@yihui
Copy link
Member

yihui commented Dec 29, 2017

I just made --wrap=preserve the default for Pandoc 2.0. Thanks a lot!

yihui added a commit that referenced this issue Dec 29, 2017
@github-actions
Copy link

github-actions bot commented Nov 6, 2020

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 Nov 6, 2020
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

2 participants