Skip to content

Liii STEM's Macro Command Creation

Liii STEM supports custom macros and direct import of macros from LaTeX\LaTeX. This guide will help you understand macros and master their usage methods.

1 What are Macros?

In Mathematical Formula Editing, we have already learned how to label formulas, etc. Why add another layer of annotation to existing formulas? One reason is that we want to introduce abbreviations to simplify lengthy names or complex symbols, thereby saving input time. By defining macros, we can achieve this as well.

  • A macro is a pre-recorded command or code snippet that we create according to our needs to automatically perform repetitive tasks.

Let's take another simple example. Suppose you need to mention Southern University of Science and Technology multiple times in your article. You can introduce a new macro sustech in Liii STEM as an abbreviation for these five words. The defined macro can be reused, greatly reducing your input burden.

sustech Example

2 Basic Methods for Using Macros

2.1 Creating a Macro

  • In the menu bar, click Tools -> Macro Commands -> New Macro.

Creating Macro

  • Click enter-name, enter the name of the macro you want to define.
  • In the enter-body section, enter the content of the macro.
  • Finally click Use -> Confirm.

Defining Macro

  • Press \ to enter Command Mode, enter the macro name you defined, press Enter to complete macro creation and usage.

2.2 Adding Parameters

Following the steps in section 2.1, set the Macro editor panel bottom left to Math, and you can define mathematical type macros.

Panel - Math Type

You can also add additional macro parameters, allowing you to input different content at parameter positions each time you use the macro. For example, you can change the symbols x and n in the matrix shown in the image above each time. The specific methods are as follows:

  • After entering the macro name, click Alt + to add macro parameters.
  • At the corresponding parameter position in the macro content, click \, enter the parameter name, press Enter.

Adding Parameters

2.3 Defining Existing Macros

Liii STEM has many predefined macros. You can open the Macro Editor by clicking Tools -> Macro Commands -> Edit Macro on the menu bar for personalized definition.

If you are proficient in operation or need to edit more complex macros, we recommend using the following two methods:

  • Set the Macro editor panel bottom left to Source to edit macros.
  • Click Document -> Section -> Show Preamble on the menu bar, and edit macros in the Preamble Area.

3 Editing Macros in the Preamble Area

3.1 Entering the Preamble Area

  • In the menu bar, click Document -> Section -> Show Preamble.
  • Or use the shortcut Alt + Cmd + P on MacBook, or Alt + Windows + P on Windows systems.

Entering Preamble Area

3.2 Editing Macros in the Preamble Area

After entering the preamble area, you can see the macros you previously created. At this point, you can directly edit them in the preamble area, modifying parameters, names, and content.

Editing in Preamble Area

3.3 Creating Macros in the Preamble Area

You can also directly create macros in the preamble area.

  • After entering the Preamble Area, enter \ to enter Command Mode, then enter assign, press Enter.
  • Or use the shortcut Ctrl + Alt + = to quickly start creation.
  • At this point, <assign||> will appear, enter the macro name after the first |, and add the macro content after the second |.

Input Position

Some Tips

  1. When defining parameters, you need to use the macro command (i.e., enter \+macro) to wrap the macro content; afterwards you can use Alt + to add macro parameters.
  2. Macros can nest already defined macros. For some complex macros, such as matrices, you can click Activate in the command bar after entering \+matrix, which allows you to expand macro structures for convenient quick editing.

Activation

  1. Through the math command (\ + math) you can enter Math Mode for editing, and after entering Math Mode you can call some macros that are available in Math Mode.
  2. Through the preamble area you can use conditional judgment instructions like if.

An Example

Here is an example of creating a macro through the preamble area. This macro implements the function of judging whether two parameters are equal.

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

Editing Example in Preamble Area

4 Importing Macros from LaTeX

We support direct import of macros from LaTeX\LaTeX. The specific methods are as follows:

  • Copy the macro commands from LaTeX\LaTeX.
  • Click Document -> Section -> Show Preamble; or use the shortcut Alt + Cmd + P to enter the Preamble Area.
  • Right-click -> Paste From -> LaTex, and the macro import is completed.

Importing from LaTex