Using templates in SuperMemo

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 creating 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 components, 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 element toolbar). 

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 Temple : 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 : Template on the main menu

If you want a template to be used by default each time you choose Add new or press Alt+A, use Template : Save as default (Ctrl+Alt+M). 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. If you now use Add new (Alt+A), all newly added items will use the default template. The appearance of previously added items will not be affected. 

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 (Ctrl+Shift+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 : New font, Text : Edit font or Text : Link 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: 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: 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  

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:

  1. Define a template as described above (e.g. by reworking an existing template and saving it with Template : Save as default or with Ctrl+Alt+M)
  2. 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: 

  1. Choose Search : Categories on the main menu (if you are not at the professional level, switch the level, e.g. with Ctrl+Alt+F12)
  2. Select the category (e.g. by typing its name at the top of the category registry window)
  3. Click the Template button
  4. Choose the template from the template registry (e.g. by typing its name at the top of the template registry window)
  5. Click Accept (at the bottom of the template registry window)
  6. 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 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 element toolbar):

  • Save as template - save the currently displayed element as a template. This makes it possible to use the looks 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. Choosing Ctrl+Alt+M is the fastest way to make sure that all new items added to the current category assume a given look. 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 - 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 with Template : 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 Flags menu)
  • 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 the element
  • 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 looks will affect no template. After Detach template, View source will have no effect
  • Impose template - overwrite the source template with the currently applied template. After Impose template, 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 without changing the look of the element. This will ensure that changes to the element will not affect the detached global template
  • 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)

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 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. This way, you can create a template with an image and add this image to a selected group of elements by adding the image 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

See also: FAQ: Templates in SuperMemo