Appearance
Creating Custom Macro Commands
Liii STEM supports custom macros and direct macro import from . Macros are useful for wrapping frequently used content, formula structures, and typesetting styles.
0 Terminology
- Environment: A region with a specific structure and behavior. The same content may be rendered differently in different environments.
- Markup: The name of an environment, such as
section. - Focus: The environment where the cursor is currently located. It is usually shown with a blue frame in the interface.
- Typesetting primitive (Primitive): A basic built-in operation in the Liii STEM style language, such as
<with|>,<if|>, and<equal|>. - Macro: A reusable command assembled from primitives. You can customize macros as needed.
- Tag: A basic typesetting unit in Liii STEM used to describe structure and formatting.
- Structure: The rendered typesetting result produced by primitives or macros.
- Structured input / movement: Insertion, deletion, and movement performed by document logic units. For example, in a table,
Alt+LeftandAlt+Rightinsert columns,Alt+UpandAlt+Downinsert rows, andAlt+BackspaceandAlt+Deleteperform structured deletion.
1 What Is a Macro?

A macro wraps repeated input into a short command. For example, you can define
Southern University of Science and Technologyassustech, then type only the macro name later.
2 Basic Macro Usage
Create a Macro


In the menu bar, click
Tools->Macro commands->New macro. Enter the macro name inenter-name, enter the macro content inenter-body, then clickUse->Confirm. After the macro is created, press\, type the macro name, and press Enter to call it.
Add Parameters


Open Macro editor and switch the lower-left mode to
Math. UseAlt+Rightto add parameter slots. After that, each macro call can fill those parameter slots with different content.
Define Existing Macros
Click
Preference for tag->Edit macroin the focus toolbar to open the macro editor. For complex macros, switch toSourcemode or edit directly in the preamble.
3 Edit Macros in the Preamble
Open the Preamble

Click
Document->Part->Show preamble, or use the shortcutCtrl+Shift+P.
Edit Macros in the Preamble

After entering the preamble, you can directly edit existing macro names, parameters, and bodies.
Create Macros in the Preamble

Type
\assignto generate the<assign||>structure. Enter the macro name after the first|, and enter the macro body after the second|.
Common Tips

- If a macro needs parameters, type
\macrofirst, then useAlt+Rightto add parameters. - Complex structures can nest existing macros. When editing structures such as matrices, you can first click
Activatein the mode toolbar to expand the structure, then edit it. - Type
\mathto enter Math Mode, so you can call Math Mode macros directly inside a macro body. - When using conditional primitives such as
if, editing in the preamble is usually more convenient.
Conditional Example
text
<assign|test-equal|<macro|arg1|arg2|msg|<if|<equal|arg1|arg2>|Same quantity:arg1|Not equal:msg>>>
This example defines a
test-equalmacro that checks whether two parameters are equal.
4 Import Macros from LaTeX

Liii STEM supports direct macro import from , which is convenient when migrating existing commands into Liii STEM.
5 Quickly Get Familiar with Macro Commands

Use
Ctrl+Shift+oto view the document source. Comparing the document output with the source structure is one of the fastest ways to become familiar with macro commands.
6 Mogan Style Language
If you need to write more complex macros, start with the following common structures.
Assignment
text
<assign|hi|<macro|Hi there!>>
assignpermanently sets an environment variable.
text
<with|font-series|bold|color|red|Bold red text>
withlocally changes environment variables.
text
<with|strong|<macro|body|<with|font-series|bold|color|red|body>>|<strong|strong> text>
withcan also be used for local macro redefinition. Thevalueprimitive is often used to read the value of an environment variable.
Macro Expansion
text
<assign|my-macro|<macro|x1|...|xn|body>>text
<my-macro|y1|...|yn>The first snippet defines a macro, and the second snippet calls it.
text
<assign|hello|<macro|name|Hello <arg|name>, you look nice today!>>

argreads an argument value.
text
<assign|hey|
<macro|first|second|
<if|
<equal|second|?>|
Hey <arg|first>, you look lonely today...|
Hey <arg|first> and <arg|second>, you form a nice couple!>>>

Extra arguments are ignored when calling a macro. Missing arguments are treated as
uninit.
text
<assign|my-macro-copy|my-macro>You can also assign one macro to another environment variable.
Formatting Primitives
fracis a typical inline tag, andTheoremis a typical block-level tag.concatis used for inline concatenation, whiledocumentis used for paragraph-level organization. When writing a macro, if you need inline text around a block-level tag, usesurround.
text
<assign|my-theorem|
<macro|body|
<surround|<no-indent><with|font-series|bold|Theorem. >|<right-flush>|
body>>>

text
<assign|very-important|<macro|body|<with|font-series|bold|color|red|body>>>text
<assign|very-important|
<macro|body|
<with|font-series|bold|color|red|
<document|body>>>>

If you want a tag to always be handled as a block-level structure, use
documentinside it.
Basic Table Structure Tags
text
<assign|eqnarray*|
<macro|body|
<with|par-mode|center|mode|math|math-display|true|par-sep|0.45fn|
<surround|<no-page-break*><vspace*|0.5fn>|<vspace|0.5fn><no-indent*>|
<tformat|
<twith|table-hyphen|y>
<twith|table-width|1par>
<twith|table-min-cols|3>
<twith|table-max-cols|3>
<cwith|1|-1|1|1|cell-hpart|1>
<cwith|1|-1|-1|-1|cell-hpart|1>
body>>>>>In this example,
surroundwraps a block-level environment,tformatdescribes the table structure, andtwithandcwithset table-level and cell-level properties.
text
<tabular|
<tformat|
<table|
<row|<cell|A1>|<cell|B1>>
<row|<cell|A2>|<cell|B2>>>>>

This is the most basic table structure example.
text
<tabular|
<tformat|
<!-- Table-level property settings -->
<twith|property-name|property-value>
<twith|property-name|property-value>
...
<!-- Cell-level property settings -->
<cwith|row-range|column-range|property-name|property-value>
<cwith|row-range|column-range|property-name|property-value>
...
<!-- Table content -->
<table|
<row|<cell||>|<cell||>>
<row|<cell||>|<cell||>>>>>To learn more about the underlying language, see Scheme Quick Start.