Latex note#6 use the force of Macros!

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}{centeringCross} 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 CenteringCross 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:

renewcommand{quote}[1]{textquotedblleft{}#1textquotedblright{}}

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

//