LaTeX & Macros: Creating Macros & Macros without arguments
latexteada
Posted on November 10, 2021
Hello, how are you? :)
In this post I tell you
- How to declare the macros, and where
- How to create macros, in this time, macro without arguments
Let's Start!!!
Declaring Macros
This is valid for any kind of macros, but in this post I just talk about macros without arguments
First of all, you need to know that The names of the macros must not match with existing ones, so you will have an error if you create a macros with the equation
name.
Macros are declared in the preamble, the syntax is the following
\newcommand{\name}{task}
Where
-\name
is the way you will call the macro in your text
Be careful you need to use the
\
when declaring the macro, because now that word is going to be the name of the instruction
-task
are the actions that the macro will perform
Here you can use normal text or instructions already defined
Creating macros
Let's create our first macros, with name \post
and the action
that prints Hello
Produces
Here is an example, where you can play and modify
But, you can create macros with LaTeX
commands
Produces
Here is an example, where you can play and modify
This is the most basic macros, there are more, but these are for other post.
This is all!!!
Do not forget to follow me on Twitter @latexteada
Greetings :)
Posted on November 10, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.