Skip to main content

Questions tagged [macros]

{macros} is for questions specifically concerning TeX's macro processor. Note that, because TeX uses macros ubiquitously, most questions about code that uses macros are not looking for information about how macros work, and so are not appropriate for this tag.

971 votes
1 answer
258k views

What do \makeatletter and \makeatother do?

Many LaTeX “hacks” begin with \makeatletter and end with \makeatother. What do these commands do?
Caramdir's user avatar
  • 89.8k
640 votes
12 answers
223k views

Space after LaTeX commands

I have a definition: \newcommand{\arnold}{Arnold Schwarzenegger} When I refer to it by: \arnold is a it is rendered as: Arnold Schwarzeneggeris a In order to have a space in front of "is" I ...
Kaarel's user avatar
  • 6,501
568 votes
4 answers
88k views

What's the difference between \newcommand and \newcommand*?

I just spotted someone use \newcommand* in an answer and realised that I'd never quite sorted out in my head what the star (asterisk) was there for. (This one is practically impossible to search for ...
Andrew Stacey's user avatar
403 votes
6 answers
44k views

What is the use of percent signs (%) at the end of lines? (Why is my macro creating extra space?)

I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines?
Federico Poloni's user avatar
392 votes
5 answers
153k views

What is the difference between \def and \newcommand?

Inspired by a question about \let and \def, I have some that essentially all boil down to asking What are the differences between \def and \newcommand? In particular, I wonder Is it possible to ...
Michael Underwood's user avatar
346 votes
5 answers
41k views

What is the difference between Fragile and Robust commands? When and why do we need \protect?

So I've read a few times about this, the “moving arguments” and all that. But what does it really mean? Could someone explain in a few words what is going on at the TeX level, what is the difference ...
Juan A. Navarro's user avatar
322 votes
3 answers
353k views

How do I create an invisible character?

I cannot remember how to create an invisible character in LaTeX, i.e. I want to put a space that has the width of a particular character, say `M'. I know there is a command for this, and this is a ...
Matt Leifer's user avatar
  • 4,020
270 votes
3 answers
76k views

What is the difference between \let and \def?

What is the difference between the \let and \def commands in TeX/LaTeX? Ideally please provide a simple example that will illustrate the difference between them.
bryn's user avatar
  • 10.4k
221 votes
5 answers
70k views

When to use \edef, \noexpand, and \expandafter?

I'm quite happy hacking TeX macros and cobbling together bits and pieces from different style files to suit my own ends, but I have a suspicion that my resulting hacks are not quite as elegant as they ...
Andrew Stacey's user avatar
213 votes
4 answers
171k views

newcommand vs. DeclareMathOperator

As far as I understand, whatever can be done using DeclareMathOperator can also be achieved using newcommand, but not the other way around. If this is the case, what are the circumstances where ...
Dror's user avatar
  • 22.7k
211 votes
3 answers
382k views

How to color math symbols?

One can use the command such as \textcolor[rgb]{1.00,0.00,0.00}{boundary} to color the word "boundary" in a document. Here is my question: How to color the math symbols in $$? For example, can one ...
user avatar
206 votes
3 answers
136k views

What do newcommand, renewcommand, and providecommand do, and how do they differ?

What do newcommand, renewcommand, and providecommand do, and how do they differ? I think \newcommand overwrites any previously existing command, while \providecommand creates the command only if it ...
keflavich's user avatar
  • 4,633
198 votes
6 answers
58k views

What exactly do \csname and \endcsname do?

What exactly do \csname and \endcsname do? What are their job? I have glanced at the Texbook and some other books, but none of them was clear enough to me. Can anyone please give a simple example to ...
Vahid Damanafshan's user avatar
186 votes
4 answers
632k views

\vspace vs. \vskip [duplicate]

What is the difference between \vspace{-1em} and \vskip -1em, for example? I guess the first is LaTeX, and the latter is TeX. When is the proper time to use one and not the other, and why?
Geoff's user avatar
  • 3,841
176 votes
5 answers
65k views

Can I redefine a command to contain itself?

I'd like to "add to" an existing command by writing something like \renewcommand{\somecommand}{\begin{something}\somecommand\end{something}} but (not surprisingly) I get errors about being "too ...
orome's user avatar
  • 10.5k

15 30 50 per page
1
2 3 4 5
554