Building a Book

Building a Book
Author

Logan Johnson

Published

February 9, 2023

Prompt:

The goal of this week’s blog is to document what you are doing when things do not go according to plan.

Similar to previous exercises, we have a specific use case in mind: we want to build a book from a github repository.

What happens in practice usually, is that we run into some problems. So your real task turns into that of a bug-hunter and fixer. Luckily, you have a community (the class discussion board) who might be able to help you.

What we want: build a book

Build the html version of the 2nd edition for Hadley Wickham’s book Advanced R Programming from a github repository.

Steps:

  1. Clone the repository https://github.com/hadley/adv-r.
  2. Open the R project in the repository in RStudio.
  3. Activate the Build tab (by default in the top right panel). Click on the Build Book button.
  4. The book will be available in html format as index.html

Deliverable (1): what is the last word in chapter 15? - You don’t have to answer this question, if things don’t work.

My Response

The last word in chapter 15 in both the PDF and HTML versions that I generated was “person.”

What to do when things don’t work?

Errors happen, they are frustrating, but if we learn something from them, we can turn them into valuable experiences.

  • check the Questions and Answers forum in Canvas whether there is a solution available for your problem.

  • if the above document does (not yet) include your question, document the error you encounter (be as concise and specific as you can at the same time)

  • if the Question and Answers forum does (not yet) include a solution, describe one approach on how you tried to solve the problem (and how this did not work).

  • submit the description of your problem in Canvas at Discussions > Questions and Answers. Write the paragraph in the mindset that you want to get help from somebody, and you try to describe the problem you are encountering.

  • Extra points (1 pt for the first suggested working solution): post a solution to one of the problems in the Questions and Answers forum (your own does not count!).

Deliverable (2): Write a paragraph on the biggest problem you encountered when you were building the book, (and how you managed to solve it.)

My Response

The whole process of downloading the repository was easy, despite the sheer number of files that are included with the process. Some challenges that I faced included many errors while trying to create the book. Some of the errors I faced included:

  • Error due to “___ package not found”
  • Error: C stack usage 7970272 is too close to the limit
  • Package fontspec Error: The font “Inconsolata” cannot be found
  • Bookdown: ! LaTeX Error: Command \href undefined

It was easy to solve those issues with packages not found. I simply downloaded the necessary package called out in the error messages. I had no issues with this issue.

The error with “C stack usage too close to the limit” was a confusing error for me. I wasn’t able to find a clear answer online anywhere. The issue seems to stem from computer memory issues and the issue of a recursive function that is large. Essentially to solve this, I restarted the RStudio session and then the issue seemed to resolve itself. I only faced it a time or two.

As simple as the missing “Inconsolata” font seemed to me, I spent a frustrating amount of time trying to figure out how to resolve this issue. I first tried to find a way to download the “fontspec” package with is in CTAN and not CRAN. My inexperience with LaTeX also didn’t help in this instance. I downloaded the package “tinytex.” This seemed to help some issues, but didn’t solve the specific font issue. I ultimately realized that I simply needed to download the font from Google Fonts. That was a simple, yet frustratingly long issue.

Lastly, the LaTeX Error: Command \href undefined lead me to the GitHub respostory of Yihui Xie for bookdown. The specific code and changes were made to a specific LaTeX file. I was able to find this same type of file in Hadley’s advr repository. I made a change locally by adding “

” before the issue of “LaTeX Error: Command \href undefined.” After this final change, the book was able to render with no issues.

Submit to your repo and you are done!