是否有可能停用整個文件的智慧(上下文)引用?如果是,怎麼辦?
特別是,是否可以透過某些選項或方法將單引號 '、雙引號 " 和反引號 ` 保留為原樣以直接停用此類替換?
\documentclass{article}
% minimal document which illustrates the issue.
\begin{document}
Can "double quotes", 'single quotes' and `backticks`
substitutions to any curly, smart, quote, contextual
be switched off for the whole document?
\end{document}
套餐upquote
似乎僅限於\verbatim
類型部分。套餐csquotes
具有用戶可定義的“智慧引號”的命令和環境……然而,一些完全禁用智慧引號的切換一直難以實現。
問題“是否有類似正文的上引號包,而不僅僅是逐字文字?”正在尋找一個套件加宏而不是一個關閉開關。
系統性影響添加包與切換開關(選項?)具有本質的差異。
一方面,“添加包”是一個下游方法。下游文件增加了作者文件的群集和複雜性。 例如x
,為巨集新增此包y
,然後新增該包z
,然後覆蓋a
,然後定義b
,以便b
可以覆寫它本身。每個新增的套件、定義和覆蓋也可能為動態運行時執行增加一些計算複雜度。
另一方面,“切換一個開關”是一個上游方法。我猜測這些引用替換源自於各種 TeX/LaTeX 引擎。假設或理想情況下,可以編譯和連結智慧報價選項開關,以便在源頭有效執行…使用一些偽邏輯,例如:
// over simplified pseudo code
if smartQuotesOption == true {
// make quote substitutions happen
}
else {
// just skip the substitutions.
// so, maybe nothing or little to do.
}
那麼從概念上講,用戶將使用命令列選項:
pdflatex --no-smart-quotes document.tex
或在 LaTeX/TeX 檔案中使用一些直接開關,如下所示:
\smartquotesdisable
\smartquotesenable % default for backward compatibility
這種智慧替換啟用/停用切換確實存在於文件建立環境中,例如各種 Markdown 工具pandoc
和主流文字處理器。
所以,「智慧引用替換可以嗎?關閉?
如果是的話,那就太好了。
如果不是,那麼人們將在哪裡提交智慧替換切換的功能請求?或者,查明此類功能是否已在路線圖中? :-)
答案1
我對更改 和 the 的目錄代碼持保留態度asciigrave
,quotedbl
因為這些字元經常用於更改其他字元的目錄代碼。但也許沒關係。
已更新以使用pdflatex
、xelatex
和lualatex
。
\documentclass{article}
\usepackage{ifxetex}
\usepackage{ifluatex}
\newif\ifxetexorluatex
\ifxetex
\xetexorluatextrue
\else
\ifluatex
\xetexorluatextrue
\else
\xetexorluatexfalse
\fi
\fi
\ifxetexorluatex
\usepackage{fontspec}
\begingroup
\catcode 34=13
\catcode 39=13
\catcode 96=13
\gdef"{\textquotedbl}
\gdef'{\textquotesingle}
\gdef`{\textasciigrave}
\endgroup
\else
\usepackage[TS1,T1]{fontenc}
\begingroup
\catcode 39=13
\catcode 96=13
\gdef'{{\fontencoding{TS1}\selectfont\textquotesingle}}
\gdef`{{\fontencoding{TS1}\selectfont\textasciigrave}}
\endgroup
\fi
\def\smartquotedisable{%
\ifxetexorluatex
\catcode 34=13
\fi
\catcode 39=13
\catcode 96=13
}
\def\smartquoteenable{%
\ifxetexorluatex
\catcode 34=12
\fi
\catcode 39=12
\catcode 96=12
}
\begin{document}
`Hello'
"Hello"
``Hello''
\smartquotedisable
`Hello'
"Hello"
``Hello''
\smartquoteenable
`Hello'
"Hello"
``Hello''
\end{document}