Give the command of the custom command first: \ newcommand {} [<; Number of parameters >] [<; Default value >] {<; Define content >}.
It allows authors to define new commands. The required and optional parameters of this command are described below. The curly braces at both ends of the new command can be omitted, but it is not recommended.
The new command is a declarative command, usually placed in the introduction, so that it can be used in the whole text. If it is placed in the text, it can only be used in the contents of the command declaration, or in the environment and combination, that is, the command defined in the environment cannot be used outside the environment, and the command defined in the curly braces cannot be used in the curly braces, such as {\ new command {\ CmdA} {a} \ CmdA. The \ cmda in the curly braces will normally output a, while the \ outside the curly braces. In addition, the parameters of the custom command must not contain transcription command \ verbs or verbatim transcription environment.
Customize the command so that it can generate your own name.
However, it seems that some new problems have emerged. As we said in the command section, there is less room behind Zhong Haosun. The reason should be obvious. The space after the custom command is regarded as the sign of the end of the command, which makes the space between Sun and lost. Then why don't we actively add a space in the custom command? This is no good, because if you do this, there will be an extra space before' in the second sentence. How to solve this problem? The xspace macro package solves this problem. Call macro package \usepackage{xspace} and change the above definition to
Zhonghao sun \ x space
Yes, the command \xspace can automatically generate a space unless it is followed by punctuation. Try again, and the custom command is complete.
In the above example, the new command \myname \ is defined as your own name. You can generate a name every time you use this command. For a large number of characters appearing in paper typesetting, it can be simplified into custom commands to improve input efficiency and prevent mistakes.
Customize a command with parameters to convert some text into corresponding Chinese fonts.
In the above custom command, a necessary parameter is defined: font, which is used to select the required font. The following are examples of optional and required parameters:
Using optional parameters can simplify the command and make it more flexible, but optional parameters are also easier to forget. Here we only choose the command to change the font as an example, and we can also try other commands ourselves.
Custom command with asterisk: If the custom command is changed to \newcommand*, the difference is that the various parameters in the command cannot exceed one line, that is, the command cannot contain line breaks or \par, otherwise an error will occur.
The system still provides a command to prevent conflicts with the same name: \ providecommand {} [<; Number of parameters >] [<; Default value >] {<; Define content >}, the new command defined in this way will check whether the called macro package provides a command with the same name, and the defined content will be saved until the macro package providing the command with the same name is cancelled. In addition, if you want to customize the command with optional parameters, you can call the keycommand macro package and use the command \newkeycommand. For specific usage, please refer to the macro package documentation.
If we are not satisfied with the typesetting effect of a command or a command defined in the system, we can modify it:
This command can only be used to modify existing commands, and it is not easy to redefine existing commands, because the original meaning may hide what you need but haven't noticed. If you really need to redefine, you should first understand the definition of the existing command, and then modify it. Similarly, the modify command has the corresponding asterisk form \renewcommand*
If we don't find a satisfactory environment, then we can also customize an environment, just like a custom command, as follows.
Then, you can use this new environment:
The purpose of various parameters in the new environment definition command is as follows
Example of custom theorem environment:
\quad is a length setting command in the definition, which we will introduce in more detail in the chapter of mathematical formula. Both the start definition and the end definition of \par need to start a new paragraph. If we need to add some theorem names after them, we can use a custom environment with optional parameters, as shown in the following example.
We see that the theorems and definitions in the completed papers have serial numbers, and how to add this serial number to the theorems will be introduced in the next section of the counter.
Like modifying an existing command, this command is:
Similarly, commands to modify an existing environment and define a new environment are numbered in the form of \renewenvironment* and \newenvironment*, which are the same format as the commands to modify an existing environment.
When using custom commands or environments, unnecessary spaces may be generated. If you want to eliminate spaces, you can use the following commands when defining content or defining a new environment respectively:
Customize two reference environments, and the second one uses the Ignore Spaces command to compare their typesetting effects.
There will also be custom situations, such as custom counters, which will be introduced in the corresponding chapters.
¢Ù Question: How to use the analog/digital input/output module of Siemens plc200?
There is a wiring diagram in the product package of the module. After wiring connectio