="http://www.w3.org/2000/svg" viewBox="0 0 512 512">

9 Shortcodes

9.1 – Overview

A shortcode is code similar to HTML, but it is PolyBook-specific and allows you to easily insert formatting or content elements. Shortcodes are typically easier to use than HTML and 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. However, for users whose workflow involves importing Word documents into PolyBook or copy/pasting from a manuscript written in a different editor, shortcodes are a convenient way to insert or format content elements that are PolyBook-specific.

Most of these shortcodes support custom classes. For more information on applying custom classes, see the “Applying Custom Classes” section at the end of this chapter.

9.1.1 – Headings and subheadings

Top-level heading inside chapter (H1)

Second-level heading inside chapter (H2)

Description: Formats the text as a heading (h1) or subheading (h2). Note that the “heading” is not the chapter title, but the next level of headings.

Custom classes may be applied to this shortcode.

Example Code Example Output

9.1.2 – Equations/Latex


latex code here[/latex]

Description: Treats the content as latex code and renders it using PbLaTeX, or QuickLaTeX if the plugin is enabled on the book.
Example Code Example Output

[latex]e^{\i \pi} + 1 = 0[/latex]

9.1.3 – Anchor

Description: Creates an anchor which can then be linked to via href=”#anchorname”.

The ID is required. It is recommended to only use letters, numbers, hyphens (-) and underscores (_) in the ID. Note that the ID is case-sensitive.

A custom class may be applied to this element.

Example Code Example Output
Example of the anchor shortcode in use. When rendered, the anchor displays no visible features.

Note: by default, the anchor is “invisible”; it is displayed without any visual element associated with it.

9.1.4 – Textbox

Your text here


Your text here

Description: Wraps the text inside a box with an outline. Depending on the selected theme, the box may have a background color.

The preset “shaded” class or custom classes may be applied to the textbox shortcode in order to change the appearance upon display.

Example Code Example Output
Shortcode for textboxes Rendered textbox
Usage of the textbox shortcode with shaded class. Rendered shaded textbox

9.1.5 – Media


Description: Embeds media content (usually videos) in an iframe, with an optional caption. The video must be oEmbed-compatible.

Please note that videos do not support alt-text.

Example Code Example Output
Example of the Media shortcode in use, with the caption parameter. Rendered video with caption.

9.2 – Applying Custom Classes

If you are familiar with CSS, you may apply custom classes and use custom CSS to modify the appearance of some of the elements. Shortcodes that support custom classes are indicated in the descriptions above. Custom classes in the shortcodes work the same way as custom classes in HTML, by adding class="".

For example, adding a custom class to a textbox:

Your text here

9.3 – Nested Shortcodes

There are known issues with nesting shortcodes within other shortcodes. In general, we would recommend that you avoid using shortcodes within shortcodes in your book content and suggest that when possible you use another formatting method for one of the nested functions.

Almost every shortcode has an alternate styling method available from the visual editor toolbar. The only shortcode elements that do not have a non-shortcode alternative are:

  • Footnotes
  • Glossary terms
  • Captions
  • Image gallery

We cannot guarantee that all combinations of nested shortcodes will function correctly in webbooks and various exports, but the following have been tested and verified:

  • [latex][/latex] shortcodes inside of and  shortcodes
  • shortcodes inside of [glossary] shortcodes
  • shortcodes inside of shortcodes



How to PolyBook Copyright © Melanie Walter und Sarah Frederickx. Alle Rechte vorbehalten.