Giter Site home page Giter Site logo

yihui / bookdown-crc Goto Github PK

View Code? Open in Web Editor NEW
69.0 7.0 63.0 45 KB

A minimal example of using bookdown to write a book for Chapman & Hall/CRC

Home Page: https://yihui.name/en/2018/08/bookdown-crc/

License: MIT License

TeX 99.50% CSS 0.50%
bookdown book rmarkdown

bookdown-crc's Introduction

This is a repo to host the (Markdown) source files of my personal website, including my Chinese and English blogs, as well as several project websites (such as knitr.) The content of all pages is licensed under CC BY-NC-SA 4.0.

You are welcome to post comments on my site. To do so, you need to log in using your GitHub account at the bottom of a page. If you have any other feedback, comments, or questions, please post them to my GitHub discussion board.

A technical note

To build the website locally, you must clone this repo with its submodule (use the --recursive argument), e.g.,

git clone --recursive [email protected]:yihui/yihui.org.git

The website is built via the R package blogdown. Please read its documentation for how to use it.

I don't recommend you to study how my website is built, because it is complicated. In particular, the way I manage images is fairly complicated.

bookdown-crc's People

Contributors

szimmer avatar yihui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bookdown-crc's Issues

Using listings package to break lines in R output

I'm trying to incorporate recommendations here to break the lines of R output in a PDF but I can't get it to work.

See example of what I changed here

Overview:

  • Added listings package to preamble.tex \usepackage{listings}
  • Set option to break lines in before_body.tex \lstset{breaklines=true}
  • Added a chunk of wide output using
options(width=200)
1:100

When I made the PDF, it doesn't break the lines as expected.

image

Any ideas?

Rendering of unicode characters fails

I'm just starting to experiment with this template, but I keep running into the same issues regarding unicode characters.

With a fresh clone of this repo and the addtition of

library(lobstr)
ast(1 + 1)

which should render

█─+
├─1
└─1

I start running into encoding problems.

#> ! Package inputenc Error: Unicode char █ (U+2588)
#> (inputenc) not set up for use with LaTeX.

#> Error: Failed to compile bookdown.tex. See bookdown.log for more info.

I have seen Hadley adress this issue in the preamble of Advanced R: https://github.com/hadley/adv-r/blob/master/latex/preamble.tex#L24 and I've experimented with using that preamble or including the code-block in the preamble of this project.

I also tried both pdflatex and xelatex as a pdf-engine and am not entirely sure how to best proceed from here.

LaTeX Error: Environment rmdtip undefined.

First off, thanks so much for this template! It's going to save me so much time and agony 🍻.

Have you given any thought to supporting custom blocks in the pdf version? Currently if I try to add something like this to an Rmd:

```{block, type = "rmdtip"}
Bookdown rocks
```

I get

LaTeX Error: Environment rmdtip undefined.

The short vertical and horizontal lines at corners

Hi Yihui, thank you for the wonderful package! I am wondering if there is a way to avoid the lines (I suppose were for the purpose of alignment) at all four corners of the odd-numbered pages. I went through css, preamble.tex, and index.rmd, but failed to solve this issue. Could you give some hints? Thank you!

Where is the PDF?

Hi there,

When knitting, where is the PDF file?

Thank you,
Matthew

\href{} applied to \includegraphics{} doesn't appear to work for pdf

To reproduce, try adding a fig.link="https://google.com" to this code chunk (or any chunk that produces an image):

```{r hello, fig.cap='Hello World!', out.width='90%'}

Interestingly, the appropriate \href{} is generated in the resulting tex file (so knitr/bookdown isn't the problem here), but clicking on the image in the pdf does nothing. Any idea why that might be? Perhaps a problem with the krantz.cls file?

LaTeX Error: Command \href undefined when building pdf book in CRC style

Hi,

I received this error LaTeX Error: Command \href undefined when building my book using bookdown::pdf_book today.

image

Previously, it was not a problem - and I managed to generate pdf book (CRC style) from the same source many times. The latex error could be due to the CRC style or the css, but I was unable to confirm this. I also tried to build the pdf books using the sources

  1. from bookdown-demo. Outcome: there is no error and the pdf book is generated
  2. from bookdown-crc. Outcome: I got the same error and no pdf book generated

I have reinstalled tinytex, but still did not work. And even after I have installed Tex Live 2022, I still receive the error.

Update:

Today, I successfully built the book using my other computer. This computer however uses Miktex. Perhaps, the error is related to TinyTex or Tex Live?

Appreciate any help and guidance.

Use of "caption" breaks "krantz"

Using documentclass krantz removes the colon (:) in table captions ("Table 1:" becomes "TABLE 1"), but the line

\usepackage[bf,singlelinecheck=off]{caption}

in "latex/preamble.tex" adds it back. Chapman & Hall doesn't like that, I get complaints in the proofreading phase. However, a workaround seems to be to just remove the line (and not use the 'caption' package).

If it doesn't break anything, I suggest removing it.

Göran Broström

Index entry page numbering is incorrect when TOC is long

When the table of contents exceeds two pages (and therefore goes from 2 to 4 pages total), the page numbers and hyperlinks for index entries are off by two pages.

To reproduce this, clone this repo and then add enough section headings to grow the TOC. I put about 60 level-two headings into chapter 2 to accomplish this.

Then observe that the index entries for "bookdown" and "knitr" are incorrect by two pages - the same two pages that the TOC gained. The index entry for "FOO" is correct because the \mainmatter command restarts the page numbering. However, for a book without a frontmatter mainmatter split, the index page numbers are wrong for the entire book.

I can't tell if this is a problem with krantz.cls or with bookdown.

Failed to render

Hi there,

I have downloaded the minimal example, set up an Rstudio session, and without making any changes I have attemped to Build the book. However, I received the following error messages:

Quitting from lines 20-28 (bookdown.Rmd)
Error in dev.control(displaylist = if (record) "enable" else "inhibit") :
dev.control() called without an open graphics device
Calls: local ... call_block -> block_exec -> chunk_device -> dev.control
In addition: Warning messages:
1: In grSoftVersion() :
unable to load shared object '/Library/Frameworks/R.framework/Resources/modules//R_X11.so':
dlopen(/Library/Frameworks/R.framework/Resources/modules//R_X11.so, 6): Library not loaded: /opt/X11/lib/libSM.6.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/modules/R_X11.so
Reason: image not found
2: In cairoVersion() :
unable to load shared object '/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so':
dlopen(/Library/Frameworks/R.framework/Resources/library/grDevices/libs//cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/grDevices/libs/cairo.so
Reason: image not found
3: In (function (filename = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", :
failed to load cairo DLL
Execution halted
Error: Failed to run 'render_book' in a new R session.
Execution halted

Exited with status 1.

Any clues as to why it is failing?

Unnumbered chapters appear twice in TOC

This is an issue with the krantz.cls file, but since this repo is the best source for making a CRC krantz.cls book, I thought I should raise it here.

Unlike a latex book, krantz.cls by default includes unnumbered chapters in the TOC. As far as I can tell, this is unaffected by being part of \frontmatter or \mainmatter.

The problem does not appear in this demonstration book because the _output.yml file has the code toc_unnumbered: false to suppress the duplicate headings. You'll notice that in this demo book, the Preface does appear in the TOC.
However, there are other reasons one might want toc_unnumbered: true (say, for unnumbered sections to appear).

My suggested solution is to comment out, or remove, line 717 of krantz.cls which has
\addcontentsline{toc}{fm}{#1} in the definition of \@schapter. That will make krantz.cls behave more like the normal latex book class and requires unnumbered chapters to be explicitly included in the TOC. Since bookdown handles the TOC for unnumbered chapters and sections, this makes krantz.cls behave better with bookdown.

If there's a better approach I'd love to hear it, or if this seems like the right fix then it would be helpful to change it in this repo.

Soft wrap long code output in pdf_output

Hey,

First of all, thanks for this template, it saved us a lot of time :)

I'm facing a little issue I can't figure out (and thanks @cderv from trying to solve it with me 💪):

When printing the book to pdf, some of the code outputs overflow the width of the pdf.

This happens with the default template from here, and can be reproduced as such:

cd /tmp 
git clone https://github.com/yihui/bookdown-crc
cd bookdown-crc/
R -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book");browseURL(.Last.value)'

Here is the output of page 9:

Screenshot 2020-11-19 at 09 39 02

What I've tried:

\usepackage{listings}
\lstset{
  breaklines=true
}

None of these seemed to solve the issue completely: changing the font size works to a certain extent, but for very long line the code still overflow.

Are there any solution to correct this?

Thanks for your help,
Colin

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.