Use templates to give your elements your favorite look
A template in SuperMemo is a definition of an element's appearance. Templates are used to create many similarly looking elements, e.g. with a given color, image, font, etc. The first thing to do with templates is to create a template (i.e. the "common look"). You can do it by first composing an element that looks the way you want other elements to look. This element will contain all components that are common to all elements that will be created with the use of the template (e.g. two text fields and one picture component, etc.). All components should have their properties set in the way as in the "common look" (e.g. color, position on the screen, font, etc.). You set the properties of components by using the component menu.
After creating the element with the desired look, you can use Template : Save as template on the element menu (this menu opens with Alt+F10 or with a right-click over the navigation bar).
Saving templates with Save as template makes it possible to keep a "gallery of looks" for future use. This gallery is called the template registry. You can save any element as a template. If you want particular texts, sounds or pictures to be associated with the template, use Template : Save with objects. Save as template does not save objects associated with components. For example, it will save the position and color of a text component, but it will not save the text (e.g. "US Constitution").
The template registry (i.e. the gallery of templates) can be viewed with Search : Templates on the main menu.
If you want a template to be used by default each time you choose Add new (or when you add topics with Alt+N or Ctrl+N), use Template : Save as default. Save as default will save the template in the same way as Save as template but will also make this template the default template for the currently used category. Only elements of the same type will be affected. This means that if you save an item template, new items will change their appearance, but the appearance of topics will remain the same. The appearance of previously added items or topics will not be affected (unless you save the new default template under an already used name).
To give an element a selected look, apply the appropriate template to this element. Any template can be selected from the template registry and applied to any element with Template : Apply template (Shift+Ctrl+M). After you choose a template in the registry, click the Accept button at the bottom of the template registry window (or press Enter). Applying a template does not overwrite the "old look". You can remove the applied template by choosing Template : Detach template.
Using fonts with a template
To associate a font with a text component in a template, use Text : Font : New font, Text : Font : Link font (Shift+Ctrl+F) or Text : Font : Edit font on the component menu (see more: Font options). If you want to change fonts globally in a set of existing items, you need to use plain text components. This comes from a difference between plain text components and HTML text components in the way they interpret the font associated with the template:
- plain text components: if you associate a font with a plain text component in a template (e.g. as in the Classic template), all texts used by the component in all elements that use the template will use the associated font. For example, if you choose a Greek font for such a template, all elements using this template will display in Greek
- HTML text components: if you associate a font with an HTML component in a template (e.g. as in the Item template), the font will be applied only when you begin writing the text. For example, if you choose a Greek font for such a template, all new texts typed into such a template will begin to show in Greek; however, old texts will not be affected. You will be able to change the font while typing the text and thus use Greek at the beginning of your text and, for example, Cyrillic towards its end. See: Fonts in SuperMemo
Category templates help you switch fast between different templates for different learning subjects
If you want to associate a template with a given subject, e.g. Chemistry, you can use category templates. You will need the following before you begin:
- Define a template as described above (e.g. by reworking an existing template and saving it with Template : Save as default)
- Define a new category or redefine an existing category. When you create a new collection, you begin with a single category whose name is the same as the name of the collection (see: Using categories)
To define a category template do as follows:
- Choose Search : Categories on the main menu (if you are not at the professional level, switch the level, e.g. with Ctrl+Alt+F12)
- Select the category (e.g. by typing its name at the top of the category registry window)
- Click the Template button
- Choose the template from the template registry (e.g. by typing its name at the top of the template registry window)
- Click Accept (at the bottom of the template registry window)
- Close the category registry window
The above will make sure that your template is used each time you choose Add new or press Alt+A as long as your category is selected as the current category in the category combo-box.
You can apply a template to many elements at once
You can change the look of many elements at the same time. If your elements use a given template, go to one of these elements and simply redefine the template. If your elements use different templates or use no template at all, you can apply a template to all of them by choosing File : Process collection> : Template : Apply template from the main menu, Process branch> : Template : Apply template in the contents window, or Process browser> : Template : Apply template in the browser
Template operations reference
Here is the summary of template operations on the Template submenu of the element menu (use Alt+F10 to open this menu or right-click over the empty element area or over the navigation bar):
- Save as template - save the currently displayed element as a template. This makes it possible to use the appearance of the element in other elements. Template objects such as pictures or texts are not saved with the template
- Save as default - save the current element as a template and make it the default template in the currently selected category. Save as default does not save template objects. If you would like to save objects in the default template, use Save with objects and then select this template as the default template for the current category (Search : Categories)
- Save with objects - save the currently displayed element as a template together with template objects. The saved template will include references to texts, pictures, sounds and other objects associated with the element. For example, if your question begins with "geography: ", this text will become part of the template and will show up in newly created elements using that template
- Apply template (Shift+Ctrl+M) - use a selected template from the template registry to modify the look of the element. The original look will remain untouched as the template source and can be inspected with Template : View source or restored with Template : Detach template. When using Apply template, after selecting the template in the template registry, you should click the button Accept, double-click the template or press Enter. After using Template : Apply template, the template source can be overwritten withTemplate : Impose template. In applying a template, SuperMemo transfers all matching registry objects (e.g. texts, images, etc.) from the source template to the applied template. Source components that do not find their match in the applied template will become invisible or will show up unchanged (depending on the settings in the Template : Template flags submenu)
- Replace with template - replace the current template source with a new template. The original look of the element will be lost. Replace with template is equivalent to Apply template and Impose template run in succession. The template is not detached and all its changes will be reflected in the looks of other elements
- Detach template - restore the original look of the element from before the time the template had been applied with Apply template. The element will become template-less until a new template is applied. Changes to the element's appearance will affect no other elements or templates. After Detach template, View source will have no effect
- Impose template (Shift+Ctrl+F2) - overwrite the source template (i.e. the original look that came with the element) with the currently applied template (i.e. the look superimposed on the original look with a template). After Impose template (that will make source equal to template, i.e. write the template over the original look), View source will have no effect as the source template will be the same as the applied template. Answer Yes to Detach template? if you want to detach the template (i.e. remove the connection between the element and the template) without changing the look of the element (i.e. keep the template's look but remove the connection - that makes the source look like the template but be connected to no template). This will ensure that changes to the element will not affect the detached global template (i.e. because there will be no link, the element has no template, so changes to the element stay local)
- Add template - add components from a selected template to the currently displayed element
- View source (Ctrl+Shift+U) - view the source template of the current element. The source template is the original look of the element before any template was applied with Template : Apply template
- Save to file - save the current element as a template file. This file can later be loaded into another collection with Template : Load from file. You can view template files with any text editor. Note that these files do not store registry objects but only references to appropriate files. This way a template file is useful only as long as the source collection remains in its original location on the disk. Once it is moved, references in the template file will be ignored
- Load from file - load a template file saved with Template : Save to file. Loading template file deletes all components and creates new components specified in the template
- Copy template - copy the currently used template to the clipboard
- Paste template - paste the template from the clipboard (currently displayed template will be overwritten)
- Template flags - advanced users may want to determine in detail how templates are interpreted where the template does not match the source. Template flags determine which unmatching components will be displayed (for details see: Template flags)
Advanced template operations
Adding components to a group of existing elements
If you want to add new components to a group of elements, use Add template on the main menu, in the contents window or in the browser. This will retain the old components and add new components from the added template. Add to template is similar to Apply template but the contents of the new template is simply superimposed over the old template
Transferring templates between collections
If you want to transfer templates (or single elements) between different collections, use Template : Save to file and Template : Load from file. You can also use Edit : Copy element with Edit : Paste template and Edit : Paste element to transfer templates and elements within a collection or between different collections using the clipboard
FAQ: Templates in SuperMemo