0

The quotation command \say from the dirtytalk package doesn't seem to work in figure captions. Does anyone know why this is the case and how to fix it?

\documentclass{article}
\usepackage{dirtytalk}
\begin{document}
Say is working \say{fine} here.

\begin{figure} \caption{But it \say{doesn't} work here.} \end{figure}

\end{document}

Manually inserting the correct quotation marks and works fine though. But shouldn't \say produce the same result? enter image description here

vincirist
  • 11
  • 4
  • Using cprotect there works. (no idea why.) – user202729 Dec 29 '21 at 15:43
  • There are questions about caption not accepting fragile stuff https://tex.stackexchange.com/a/110831/250119 but none about \say being verbatim-like in particular. Duplicate? – user202729 Dec 29 '21 at 15:45
  • Actually cprotect isn't necessary, just normal protect works. Fragile command. – user202729 Dec 29 '21 at 15:45
  • 1
    "fragile command in moving argument" eg https://tex.stackexchange.com/questions/4736/what-is-the-difference-between-fragile-and-robust-commands-when-and-why-do-we-n – David Carlisle Dec 29 '21 at 15:55

2 Answers2

1

Another why to get around this is to use the csquotes package instead of dirtytalk and replace all \say commands by \enquote as suggested here.

The \enquote command works in captions by default.

csquotes has more functionality and is also included in the MikTex unlike dirtytalk. I stopped using dirtytalk because of this.

vincirist
  • 11
  • 4
0

The package does

\providecommand{\say}[1]{...}

and the used code cannot survive in moving arguments.

I'm not sure what's the purpose of \providecommand, but anyway you need to make the command robust.

Either use \protect\say{text} in captions or section titles, or add

\MakeRobust{\say}

in the preamble (after loading dirtytalk, of course).

egreg
  • 1,121,712