如何將所有大寫單引號和雙引號更改為基本的 ascii ' 和 " 引號?

如何將所有大寫單引號和雙引號更改為基本的 ascii ' 和 " 引號?

我注意到 XeLaTeX 使用不同的 unicode,例如單右引號(以及相關的其他),以及連字號。我怎麼能讓它只使用'and"-常規ascii 標記,就像你在程式設計中使用的那樣,所以(a) 當你從PDF 複製貼上內容時,它不會使用特殊的unicode 字元作為引號/連字符,並且(b )我不必\regularsinglequote為我想使用的每個引用寫或類似的東西,我可以只寫一個句子"hello world, I don't use unicode quotes-or-hyphens",它使用引號/連字符的普通 ascii 版本。

我使用的文檔基本上是這樣的:

\documentclass[a4paper]{book}

\renewcommand{\contentsname}{Contents}

\usepackage{fontspec}
\usepackage{fullpage}
\usepackage{geometry}
\usepackage{sectsty}
\usepackage[hidelinks]{hyperref}
\hypersetup{
  colorlinks,
  citecolor=black,
  filecolor=black,
  linkcolor=black,
  urlcolor=black
}
\setmainfont{MyMonospaceFont}
\newlength{\characterwidth}
\settowidth{\characterwidth}{\normalfont x}
\geometry{margin=0.7in,textwidth=96\characterwidth,lines=48}
\AtBeginDocument{\raggedright\setlength{\parindent}{3\characterwidth}}
\frenchspacing
\begin{document}
\title{xyz}
\maketitle
\tableofcontents

\chapter{Foo}
\section*{A}
hello world
\section*{B}
\section*{C}
\chapter{Bar}
\end{document}

答案1

您可以使用選項 [Ligatures=TeXReset] 禁止替換引號和破折號:

\documentclass[a4paper]{book}

\usepackage{fontspec}

\setmainfont{TeX Gyre Heros}[Ligatures=TeXReset]

\begin{document}
"abc--cde 'quote' text"
\end{document}

在此輸入影像描述

相關內容