我想使用csquotes
激活报价。也就是说,
This is a "quote" inside other text.
并将其变成
This is a ``quote'' inside other text.
csquotes
使这成为可能
\usepackage{csquotes}% http://ctan.org/pkg/csquotes
\MakeOuterQuote{"}\EnableQuotes
\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}
但是,我的工作流程将内容写入宏:
\newcommand{\somemacro}{This is a "quote" inside other text.}
这不允许自动呈现引号:
\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}
我怎样才能解决这个问题?
答案1
您的选择包括:
调整您的工作流程以按原样设置内容而不是在宏内部设置,因为宏参数是在定义时使用 catcodes 存储的。
确保以这样的方式编写宏,即引号在定义时处于活动状态,因为
csquotes
发出激活\EnableQuotes
只是\AtBeginDocument
为了避免前导码内部的问题(来自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}}
例如,在环境里面插入定义
document
,从那时起它"
就会处于活动状态:\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}
使用中描述的技术“激活”作为宏传递的参数中的活动字符重新激活已激活的报价
"
:\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}