11 Weird Pressbooks Tips
This section is just here for me to make notes as I go along. You can ignore it unless you are trying to create your own PressBook.
Don’t miss the next/previous/top browsing buttons in the bottom border of the browser page. The small text on a dark border can make them less than obvious. Also be sure to check out the revision history that makes it easy to review and/or roll back changes.
Formatting Glitches
Copying from the visual editor and pasting changes some of the underlying code. Backslashes will disappear, which will break the latex commands in your equations, and any escape sequences you put in, for example to include dollar signs. It will also change simple https: addresses for youTube videos (what you get when you paste from the browser window) into html links with anchors.
Bolding type doesn’t work in lists
- Bolding type doesn’t work in lists
You can’t include images from another site
unless maybe it is another pressbooks site…
and then you will need to edit attributes in the HTML directly if you want to change the size. You can’t include an image from a github repo https://github.com/sellensr/Tiny-House/blob/master/Mar29%20ON%20Elec.jpg except as a link.
Media files don’t auto update
Changing the caption in the media library doesn’t seem to have any effect on the caption where you already inserted the media into the book. You need to re-insert after updating.
Formatting Computer Code in your book
Select multiple lines and use the preformatted format instead of heading or paragraph to manage multiple lines of code. If you select all the way to the end of the last line, preformatted will extend to the next paragraph, so select carefully.
Use the open single quote character
(reverse of an apostrophe, lower case of ~ in the top left of most keyboards) or this is code
pressbooks code, /code shortcode tags with square brackets to enclose text and get the same effect inside a paragraph. The code tag doesn’t behave gracefully across line breaks.
Units and Spacing
Enclosing something like C_p = 4180\;\rm J/kgK in $ signs on a latexpage will produce and avoid breaking across the end of a line, however it won’t include other text styling like bold in the latex portion.
In lines like this you can introduce a non breaking space by switching to text mode editing and adding at the appropriate location. There’s one of those between the number and the J. The weird part is it will disappear by next time you switch from visual to text mode, but the effect will remain.
Burning a coffee cup full of propane will produce heat release of about 8000000 J.
Building in your own LaTeX commands
Under Settings/QuickLaTeX/Advanced you can include new components to the LaTeX preamble, like this one
\newcommand{\kelvin}{\ensuremath{^\circ\,\textrm{K}}}
that makes a degrees Kelvin unit after a number in math mode. Like this . Or this one to do units
\newcommand{\units}[1]{{\rule{0.01pt}{0.01pt}\rm\,{#1}}}
This is an example and here’s another 37 37 37 3787 37 , although the numbers outside the math mode segment will allow a line break.
Equation Tips
Using “align” instead of “equation” will help a lot with formatting longer equations in the narrower space of a pressbook.
(1)
(2)
Use the \label and \ref commands from \LaTeX just like normal for the align (1) and equation (2) environments. (Don’t use the words align or equation as part of your label names.)
Files you can’t include in Pressbooks
Pressbooks wants to protect people from malicious files that could cause them grief. As a result, it won’t allow you to include many types of files (e.g. .zip, .ipynb, .csv) as media for the book. One solution is using Google Drive to house the files. Once you have uploaded them to Google drive right click and choose get shareable link, then right click and choose share to copy the link and be sure permissions are set to allow anybody to view the document.
A more open alternative, with less opaque links, is to store the files in a GitHub repository like this one. You can also point to specific files or to folders in the repository, but keep in mind those links will break if you change the organization or rename the files.
When adding Jupyter Notebooks to a GitHub repo, be sure to select Kernel / Restart and Clear Output before saving the notebook. This has two advantages, firstly it removes the graphics content from the notebook, making it smaller. This content is usually easy to regenerate simply by running the code again. More importantly, when the notebook contains only code and text, it is easy to see what changes were made as part of each commit by examining the diffs.
Re-ordering Parts of a Book
You can’t drag and drop parts in the Organize section, but you can edit them and change the order number. Oddly, just changing the fourth part’s order to 3 doesn’t put the former part 3 into position 4, so you need to change both to get the expected behaviour. The order number needs to be an integer, but there don’t seem to be any consequences of skipping a number. If you create a new part with order number 0, it will be automatically assigned a value of one greater than the highest previous order number. (In ancient days Fortran code required explicit line numbers and numbering punch cards 5, 10, 15, 20, etc. made it easy to slip a new card into the middle of the code. Apparently those days are still with us.)
It is worth noting that the front and back matter components all display top level in the table of contents, making the appendices fairly prominent when you first open a book.
Copying and Importing from another Pressbook
This segment was copied from another book (publicly viewable) and the photo came along as a link to the other site, but doesn’t become part of the media list for this book, so it doesn’t it appear in the media attributions. Also, there doesn’t seem to be a way to export media from a book.
Signature is a boat, however there are multiple elements she has in common with a tiny house when it comes to small spaces and off-grid operations.
That first bit was part of the text from the original, but this isn’t. Editing out text seems to be OK.
The 10 kW drive from Thunderstruck Motors connects to a 20 inch, 2 blade MaxProp through a 3:1 belt drive reduction system. Although only used part time, the electrical loads are similar to what you would need for a small heat pump.
I would be worried about the long term availability of that photo if it is being served from another book, as is clearly the case from checking the background HTML under the text tab.
You can copy and paste sections with embedded video just the same way and the embed will sometimes make the transition, still pointing to the original source on YouTube or wherever. It seems to be more reliable to add the video again independently.
Importing from another Pressbook
I copied and pasted a link to a chapter and got the box above!
Following the process from the box, I imported a chapter from another book on another instance and got the whole chapter plus all the relevant media files copied to the media library. However, all the backslashes were gone, so all the LaTeX was broken!
OTOH, when I chose to export as an XML file and then import it, I didn’t get any of the media, but I got the backslashes. I also got a lot of the book info, like the title. This needs further exploration!
Cloning a whole book will change the internal references to point to the new version, usually a good thing unless you are cloning in order to split one book into two.