在文本中添加引文时,需要遵循一些样式。一种样式是始终将最后一个引文放在实际引文结束的位置,无论下一个字符是什么(例如 )... and then he said, "This is a disgrace", which is uncommon even for him.
。另一种样式是如果引文后面有标点符号,则在引文内添加标点符号(例如... and then he said, "This is a disgrace," which is uncommon even for him.
)。
一旦选定,样式就应该在整个文档中保持一致。因此,我认为最好使用一个宏来处理这个问题,如下所示:
... and then he said, \quote{This is a disgrace}, which is uncommon even for him.
然后,宏应该能够将参数括在引号中,扫描下一个字符,并根据所需的样式将最后一个引号放在适当的位置。(我知道可以\ifnextchar
用来扫描以下字符,但不知道如何在必要时将其移动到引号内。)
答案1
这个包csquotes
完成了这个工作,没有必要重新发明轮子。:)
只是为了玩一下,\futurelet
这里有一种在结束引号前放置逗号、句号、冒号和分号的方法:
\documentclass{article}
\makeatletter
\DeclareRobustCommand{\squote}[1]{``#1\futurelet\@squotenext\@squotedecide}
\def\@squotedecide{%
\if\noexpand\@squotenext,\let\next\@squotecorrect\else
\if\noexpand\@squotenext.\let\next\@squotecorrect\else
\if\noexpand\@squotenext:\let\next\@squotecorrect\else
\if\noexpand\@squotenext;\let\next\@squotecorrect\else
''\let\next\relax
\fi
\fi
\fi
\fi\next}
\def\@squotecorrect#1{\@squotenext''}
\makeatother
\begin{document}
and then he said, \squote{This is a disgrace}, which is uncommon even for him.
and then he said, \squote{This is a disgrace,} which is uncommon even for him.
\end{document}