Latex note#6 use the force of Macros!

3 Jan

Latex is a time-saving tool due to many reasons (my favourite is: consistent formatting and auto-bibliography) but one of the famous latex-tricks is Macro definition.  Like it’s obvious macros are commands that encapsulate some information/commands/text/whatever, that we’ll be replaced automaticly before compilation.

A quick example that i use:

\newcommand{\cx}{\centering\Cross} this new command allows me to create a cross (x) that is centered automaticly within the cell of the table.

So as you can see, instead of typing \Centering\Cross every time, I simply type \cx !

A quick guide: An introduction to Macro in Latex

Another suitable example of a Macro is to display a a text within correct-latex-quotemarks. The macro uses an argument as input:


Input arguments are a way to make Macros more powerful. To adress an input parameter, simply type #n inside the \rewnewcommand enrvironment.

(note: maximum argument number for latex macros is 9)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: