2 Custom Formatting and Shortcodes
Since much of your formatting in Word will not be transferred over to Pressbooks, there are a few ways you can indicate that you want special formatting in your text. This might include the use of “shortcodes” or simple notes for later additions.
Note: for this section, the shortcode will be contained in braces rather than brackets; this is so that Pressbooks will display the code as text rather than rendering the code properly. If you copy and paste directly from this book, your shortcode won’t work unless you change the braces to brackets.
{codeword}this is how I’m writing the code currently{/codeword}
[codeword]this is how the code should actually look in your document[/codeword]
Shortcodes
Shortcodes are small blocks of square-bracketed code which Pressbooks recognizes and handles in special ways in the webbook and export files. Shortcodes can be used both in the Visual Editor and in the Text editor. For most users, inserting content via the Visual Editor will be the easiest option. Shortcodes also provide a convenient way to include Pressbooks-specific elements in an external document which is intended for import into pressbooks. For more information on shortcodes, see Use Shortcodes – Pressbooks User Guide.
Blockquote:
If you have a long quote or section of text you want to pull away from the rest of a paragraph, you can use the blockquote shortcode:
{blockquote} Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.{/blockquote}
Columns:
Using the columns count shortcode will display your text in 2 or more columns. For example, this text should display in two columns after import:
{columns count=2}Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.{/columns}
Equation/LaTeX:
This shortcode is used for formatting mathematics. For example, when wrapped in {equation}{/equation} or {latex}{/latex}, this:
begin{align} &P= IECosθ \\ &P= I^2R \\ &P= \frac{E^2}{R}\end{align}
Becomes this:
[latex]\begin{align} &P= IECosθ \\ &P= I^2R \\ &P= \frac{E^2}{R}\end{align}[/latex]
Footnote: You can format references as footnotes which link back to their point in the text by using the footnote shortcode[1]
Textboxes
There are 6 types of textboxes available in Pressbooks for additional formatting:
- Simple Textbox (this is a basic white box with a black outline)
- Shaded Textbox (this is a light blue box with text within it)
- Examples
- Exercises
- Key Takeaways
- Learning Objectives[2]
To add a simple or shaded textbox, use this shortcode:
{textbox}This is a simple textbox.{/textbox}
{textbox class=shaded}This shaded textbox is a bit more attractive.{/textbox}
The final four box types have colorful headers to distinguish them. These textboxes need to be added manually. For examples of each of these text boxes and instructions for implementing them, see Tables & Textboxes – Pressbooks User Guide
For your manuscript, since you can’t use shortcode for these elements, we recommend leaving yourself a note similar to the one below so that you can quickly and accurately add any additional text boxes after importing your manuscript into pressbooks.
[Examples textbox]
Header text: Video Example.
Body text: The following video tells the story of someone who…
[/Examples textbox]
NOTE: If you are using textboxes, use them consistently. This will ensure that your readers can recognize the purpose of the textbox from its color (in addition to its title and placement). For example, you might choose to always use the Exercises textbox to display interactive quiz questions, “stories from the field,” or “things to watch out for.”
Additional Formatting Post-Import
After your text is imported into Pressbooks, you can make additional edits as needed and add interactive content available in Pressbooks, such as H5P exercises or glossary terms.
H5P Exercises
If you want to place a self-assessment in your text as an H5P element, leave a note in bold like you would for an image or a textbox (see example below). You can draft the exercise you want to build ahead of time, or develop it after your Pressbook is created. Explore examples of H5P content types beforehand to brainstorm potential integrations.
[insert Multiple Choice H5P exercise here]
You can build H5P exercises directly within your Pressbook, or you can import existing H5P exercises from elsewhere. You do not need an H5P account to create H5P exercises in Pressbooks.
Glossary Terms
Glossary terms in Pressbooks can be used to click on a word and show a definition of it.
Glossary terms do not have to be used within a chapter directly, though. If you prefer, you can create glossary terms for use in a Back Matter page showing all the Key Terms for your book. You can see the Glossary for The Handbook of Software Engineering Methods, as an example.
These can be added pre import by creating a list at the end of your manuscript and setting each term to the “Heading 1” style. Just remember to assign the terms to the glossary, or they’ll end up being very short chapters!
References
Want to share your sources? You have a couple of options. You can place footnotes throughout your text with the footnote shortcode or you can place a section at the end of your page or chapter for your sources, like you might in any other published work.
This Glossary definition was created by adding the term as a “heading 1” style text at the end of the document, and assigning it to the Glossary upon import!