csquotes の MakeAutoQuote に似たメカニズムを持つ括弧付き句

csquotes の MakeAutoQuote に似たメカニズムを持つ括弧付き句

括弧内の句を記述するための次のマクロがあります。

\makeatletter
\newcommand\incise[1]{%
    ---\,#1%
    \@ifnextchar.\relax{\@ifnextchar?{\@ifnextchar!{\@ifnextchar:{\@ifnextchar;\relax{\,---}}}}}
}
\makeatother

しかし、私は引用符で csquote パッケージが行うのと同じことをしたかったのです。これは、LaTeX マクロの代わりにアクティブ文字を使用します。

では、LaTeX では次のようなことが可能でしょうか:

The main sentence -(the parenthetical clause)-.

次のように変換されます:

The main sentence \incise{the parenthetical clause}.

答え1

\catcode`*\active
\def*(#1)*{\incise{#1}}

*(xxxx)*他の場所で使用しない限り、好きなように動作します*

答え2

csquotes コマンドを使用できます。David のトリックを直接使用できない utf8 文字でも機能します\catcode。主な問題は、ドキュメントの残りの部分に副作用が生じないように文字を選択することです。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{csquotes,xcolor}

\makeatletter
\csq@addspecial{ä}{\begingroup---!ups\color{red}}{}{}%
\csq@addspecial{ö}{\endgroup!ups---}{}{}
\makeatother

 \begin{document}
 äblubö blabla 

 \end{document} 

関連情報