csquotes 中的单引号

csquotes 中的单引号

我正在使用csquotes以下建议修改的软件包这个答案,检测我的文本(从 Microsoft Word 粘贴)中的引号并使它们在输出中看起来不错。

有什么方法可以让它检测单引号,以便它们以正确的方式定位并且不被视为撇号,而不会弄乱现有的撇号?(我不想手动找到所有引号内的引号并替换为'`

\documentclass{article}

\usepackage{csquotes}
\usepackage[american]{babel}
\DeclareQuoteStyle[american]{english}% verified
  {\textquotedblleft}
  [\textquotedblleft]
  {\textquotedblright}
  [0.05em]
  {\textquoteleft}
  {\textquoteright}
\MakeOuterQuote{"}

\begin{document}
I say: "These quotes look nice, but 'if I quote someone else within a quote like this,'
or 'like this,' they don't."
\end{document}

引用截图

答案1

尽管该csquotes包允许您将某些字符定义为“活动”引号,正如您的示例文档对该"字符所做的那样,但单引号字符不能这样使用,因为它是 TeX 中的保留字符。

由于您提到您正在使用 MSWord 文档中的文本,在这种情况下,更好的解决方案是将源文件编码为 UTF-8,然后使用包inputenc(如果您使用的是 pdfLaTeX)或 UTF-8 感知引擎(XeLaTeX 或 LuaLaTeX)来编译您的文档。这样,您就可以在源文档中直接使用“智能”引号字符。MSWord 非常擅长自动正确转换引号。如果您的文档当前不使用智能引号,您可以将其打开,然后对和进行全局替换,'然后"所有引号都将正确更改。

带有这些引号的源代码随后可用于您的 LaTeX 文档。在这种情况下,您根本不需要使用该csquotes包(尽管您仍然可以,但如果源代码中混合了引号)。

使用 pdfLaTeX

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
I say: “These quotes look nice, but ‘if I quote someone else within a quote like
this,’ or ‘like this,’ they don’t.”
\end{document}

使用 XeLaTeX 或 LuaLaTeX

\documentclass{article}
\usepackage{fontspec}
\begin{document}
I say: “These quotes look nice, but ‘if I quote someone else within a quote like
this,’ or ‘like this,’ they don’t.”
\end{document}

代码输出

相关内容