102

Possible Duplicate:
What is the difference between Fragile and Robust commands?

I've never understood the purpose of the command \protect? When and why should it be used?

4

1 Answer 1

54

To understand how to use \protect you need to understand the concept of fragile commands and to understand this concept, you need to understand what a moving argument is. Some commands called fragile commands causes an error when they use a moving argument. It's a command that expands into illegal TeX code during the save process. Some arguments are called moving arguments because they may be "moved" to other places in the document. A fragile command that appears in a moving argument must be preceded by a \protect command. For example,

  • sectioning commands
  • arguments of \caption commands
  • commands that produce page headings

An example :

\caption{Beautiful picture from \protect \citeauthor{allan}
  \protect \shortcite{allan}}
4
  • 58
    "[A fragile command is a command that] expands into illegal TeX code during the save process." - What does this mean? What is the "save" process? How does a command that expands into illegal TeX successfully compile? Are there circumstances wherein a so-called "fragile command" expands into legal TeX?
    – Jake
    Aug 5, 2016 at 6:17
  • 8
    I'm with @Jake here. While the answer technically answers the question, it leaves open a lot of questions. However this question is a duplicate anyway and the answer on the other question as linked on top is far more detailed.
    – Sunday
    Dec 7, 2017 at 10:18
  • 5
    This technically isn't even an answer to the question.It didn't answer what is the purpose of the \protect command?, it just lists a few cases where I need one.This doesn't explain why LaTeX can't just put the protect in for me or what it actually does. May 14, 2020 at 5:01
  • 1
    The information here latexref.xyz/_005cprotect.html seems elucidative.
    – LEo
    Feb 10, 2021 at 13:43

Not the answer you're looking for? Browse other questions tagged .