1

I would like to use csquotes to activate quotes. That is, taking

This is a "quote" inside other text.

and turning it into

This is a ``quote'' inside other text.

csquotes makes this possible via

\usepackage{csquotes}% http://ctan.org/pkg/csquotes
\MakeOuterQuote{"}\EnableQuotes

enter image description here

\documentclass{article}
\usepackage{csquotes}% http://ctan.org/pkg/csquotes
\begin{document}

This is a "quote" inside other text.

\MakeOuterQuote{"}\EnableQuotes

This is a "quote" inside other text.

\end{document}

However, my workflow writes content into a macro:

\newcommand{\somemacro}{This is a "quote" inside other text.}

This does not allow one to render the quotes automatically:

enter image description here

\documentclass{article}
\usepackage{csquotes}% http://ctan.org/pkg/csquotes
\newcommand{\somequote}{This is a "quote" inside other text.}
\begin{document}

This is a "quote" inside other text.

\MakeOuterQuote{"}\EnableQuotes

\somequote

\end{document}

How can I fix this?

2

Your choices include:

  1. Adjusting your workflow to set the content as-is rather than inside a macro, since macro arguments are stored using the catcodes at the time of definition.

  2. Make sure to write your macro in such a way that the quotes are active at the time of definition, since csquotes issues the activation \EnableQuotes only \AtBeginDocument to avoid problems inside the preamble (from csquotes.sty):

    \newrobustcmd*{\EnableQuotes}{}
    \newrobustcmd*{\DisableQuotes}{}
    \newrobustcmd*{\VerbatimQuotes}{}
    \newrobustcmd*{\DeleteQuotes}{\csq@mkdelete}
    
    \AtBeginDocument{%
      \protected\def\EnableQuotes{\csq@mkenable}%
      \protected\def\DisableQuotes{\csq@mkdisable}%
      \protected\def\VerbatimQuotes{\csq@mkverbatim}}
    

    For example, insert the definition inside the document environment, since then " will be active:

    enter image description here

    \documentclass{article}
    \usepackage{csquotes}% http://ctan.org/pkg/csquotes
    \MakeOuterQuote{"}\EnableQuotes
    \begin{document}
    
    This is a "quote" inside other text.
    
    \newcommand{\somequote}{This is a "quote" inside other text.}% " is active here
    
    \somequote
    
    \end{document}
    
  3. Use the technique described in "Activate" active characters in argument passed as macro to re-activate the made-active quotes ":

    enter image description here

    \documentclass{article}
    \usepackage{csquotes}% http://ctan.org/pkg/csquotes
    \MakeOuterQuote{"}\EnableQuotes
    \newcommand{\somequote}{This is a "quote" inside other text.}% " is not active here
    \begin{document}
    
    This is a "quote" inside other text.
    
    \begingroup
    \catcode`\"=\active% Re-activate "
    \scantokens\expandafter{\somequote\empty}%
    \endgroup
    
    \end{document}
    
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.