从此代码中:
\subsubsection{General Escaping Format}
Generally, escaping MUST be done in a manner similar to most programming
languages, such as C, C++, Java, or similar, for quoted string escapes. Such an
escaping scheme is defined by three characters: a starting delimiter, a
termination delimiter, and an escape character. For instance, in C, the starting
delimiter is the quote mark, ", the ending delimiter is also a quote
mark ", and the escape character is the backslash \textbackslash.
XeTeX 给出了这样的结果:
特别注意,我希望将引号转换为原始 C 样式"
字符,并将其转换为一对右花括号。当然,我在本节中讨论的是编程语言,因此我需要将引号显示为打字机样式的直引号。如果我使用,我可以强制使用直引号\verb
,但这会导致引号看起来很奇怪,因为实际字体不同。
答案1
您可以\textquotedbl
使用
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
以下是输出结果:
\documentclass{article}
\usepackage[T1]{fontenc}% http://ctan.org/pkg/fontenc
\begin{document}
\setcounter{section}{3}\setcounter{subsection}{1}% Just for this example
\subsubsection{General Escaping Format}
Generally, escaping MUST be done in a manner similar to most programming
languages, such as C, C++, Java, or similar, for quoted string escapes. Such an
escaping scheme is defined by three characters: a starting delimiter, a
termination delimiter, and an escape character. For instance, in C, the starting
delimiter is the quote mark, \textquotedbl, the ending delimiter is also a quote
mark \textquotedbl, and the escape character is the backslash \textbackslash.
\end{document}
答案2
问题在于Ligatures=TeX
当您说仅
\usepackage{fontspec}
因此使用拉丁现代字体。如果你重新定义字体没有选项,则输入"
将给出直引号。因此
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
但是,如果你想保留其他“传统连字符”,你可以复制text-tex.map
,调用它text-tex-sq.map
(例如),然后将其修改为
; TECkit mapping for TeX input conventions <-> Unicode characters
LHSName "TeX-text"
RHSName "UNICODE"
pass(Unicode)
; ligatures from Knuth's original CMR fonts
U+002D U+002D <> U+2013 ; -- -> en dash
U+002D U+002D U+002D <> U+2014 ; --- -> em dash
U+0027 <> U+2019 ; ' -> right single quote
U+0027 U+0027 <> U+201D ; '' -> right double quote
;U+0022 > U+201D ; " -> right double quote ; no change!
U+0060 <> U+2018 ; ` -> left single quote
U+0060 U+0060 <> U+201C ; `` -> left double quote
U+0021 U+0060 <> U+00A1 ; !` -> inverted exclam
U+003F U+0060 <> U+00BF ; ?` -> inverted question
; additions supported in T1 encoding
U+002C U+002C <> U+201E ; ,, -> DOUBLE LOW-9 QUOTATION MARK
U+003C U+003C <> U+00AB ; << -> LEFT POINTING GUILLEMET
U+003E U+003E <> U+00BB ; >> -> RIGHT POINTING GUILLEMET
编译teckit_compile tex-text-sq.map
并保存text-text-sq.tec
将生成的文件与您的文件放在同一目录中:现在调用
\usepackage{fontspec}
\setmainfont[Mapping=tex-text-sq]{Latin Modern Roman}
将提供“传统连字符”,但保持直双引号笔直。
答案3
加载字体规格后立即重置字体功能。
\usepackage{fontspec}
\defaultfontfeatures[\rmfamily,\sffamily,\ttfamily]{}