Skip to content

Macro

conceptions

Congratulations! You have learnt most of the basic usage of Liii STEM. For more advanced features, you need to learn the following terms. (note that the terms here may be a bit different from those you've learnt in the Quick Start ).

Environment

A structured region. Content inside follows a specific format.

Markup

The name of an environment. Such as section

Focus

The currently selected environment.

Primitive

The most basic, indivisible commands that Liii STEM can directly understand and execute. Such as <with|>,<if|>and <equal|>

Macro

A combination of primitives, and can be customized. Such as <assign|test-equal|<macro|arg1|arg2|msg|<if|<equal|arg1|arg2>|Same quantity:arg1|Not equal:msg>>>

Structure

The visual result of content, produced by the action of primitives.

Structured editing

Structured editing requires Liii STEM to understand a document's internal logic—such as mathematical formulas, code blocks, tables, or sections and allows users to manipulate these logical units directly. For example, in a table: Alt + / Alt + inserts columns. Alt + / Alt + inserts rows. Similarly, for deletion: Alt + Backspace deletes the column before the cursor. Alt + Delete deletes the column after the cursor.

What is a macro?

We aim to to simplify complex formulas or lengthy names. Customing macros allows us to achieve that.

  • A macro is a pre-recorded command, customized to our needs, used to handle repetitive tasks.

A simple example: suppose you need to frequently use the “Southern University of Science and Technology” in a document. In Liii STEM, you can custom a macro (e.g., sustech) as an abbreviation for these five words.

Macro Usage

Creating a Macro

Click ToolsMacroNew Macro in the menu bar.

Enter your needed macro name into the enter-name.

Enter the content of the macro into the enter-body.

Enter command mode (press \), enter your macro name, and press Enter to the macro.

Macro Parameters

Switch the bottom to math mode in the Macro Editor as shown below, to define math-type macros.

You can also add macro parameters to input different content for parameters each time the macro is used. For example, you can modify the symbols x and n as parameters in a matrix.

Customize Macros

Liii STEM includes many pre-defined macros. To customize them, open the Macro Editor by clicking Preference for tagEdit macro in the environment toolbar.

For advanced users or complex edits, we recommend:

  • Switch the Macro Editor to Source Code mode (see section 4 of this guide).
  • Edit macros in the Preamble (see section 3 of this guide).

Editing Macros in the Preamble

Enter the preamble

Click DocumentPartShow Preamble in the menu bar.

Or use the shortcut Ctrl + Shift + P .

Editing Macros in the Preamble

In the preamble, you can view previously created macros.

You can directly modify their parameters, names, or content in the preamble.

Creating Macros in the Preamble

You can also create macros directly in the preamble:

After pressing Enter, the <assign||> will appear. Insert the macro name after the first |. Insert the macro content after the second |.

Tips:

  • When defining parameters, wrap the macro content with the macro command (type \macro), then use Alt + to add cells for parameters.
  • You may nest existing macros within new definitions. As it for complex macros (e.g., matrices), type \matrix and activate it from the mode toolbar to expand the structure for easier editing.
  • Use the math command (\math) to enter math mode, where you can use macros available in math mode.
  • Creating macros in the preamble allows the use of conditional statements like if.

Example

The following macro checks whether two parameters are equal:

bash
<assign|test-equal|<macro|arg1|arg2|msg|<if|<equal|arg1|arg2>|Same quantity:arg1|Not equal:msg>>>

Pasting Macros from LaTeX\LaTeX

Liii STEM supports direct macro paste from LaTeX\LaTeX. Copy the LaTeX\LaTeX macro command. Enter the preamble. Right-click and select Paste fromLaTeX to complete the paste.

For a deeper understanding of underlying language, consult Scheme Quick Start