我正在使用pandoc
XeLaTeX 引擎。我遇到的問題是某些字元周圍的空間一側比另一側大。給出這樣的降價:
`X ≼ Y` // 3 spaces on the right
`X ≼ Y` // 2 spaces on the right
`X ≼ Y` // 1 space on the right
生成的乳膠(通過pandoc
)是:
\texttt{X\ ≼\ \ \ Y}
\texttt{X\ ≼\ \ Y}
\texttt{X\ ≼\ Y}
結果是:
請注意,左側的 1 個空格≼
大約等於右側的 3 個空格。此外,Y
當在 後使用時,該字元會使用錯誤的字體列印≼
。
可能是什麼問題呢?是因為我正在使用後備字體只是對於這個單一字符,它會影響間距嗎?
\usepackage{ucharclasses}
\newfontfamily{\fallbackfont}{FreeMono}
\newfontfamily{\mymainfont}{MyFont}
\setTransitionsForMathematics{\fallbackfont}{\mymainfont}
編輯包括整個 Markdown 和生成的 LaTeX:
我的降價:
# MWE
Test: `X ≼ Y` test test
`X ≼ Y`
`X ≼ Y`
`X ≼ Y`
X ≼ Y
metadata.yml
:
---
title: Title title
author: Michał Miszczyszyn
rights: All rights reserved
lang: pl-PL
toc: yes
documentclass: scrbook
papersize: b5
geometry: b5paper
mainfont: Merriweather
monofont: Fira Code
indent: true
thanks: Thanks
---
header.latex
:
\addtokomafont{disposition}{\rmfamily}
\usepackage{indentfirst}
\setlength\parindent{24pt}
\setlength{\parskip}{.2\baselineskip}
\usepackage{setspace}
\onehalfspacing
\makeatletter
\def\verbatim@nolig@list{}
\makeatother
\usepackage{ucharclasses}
\newfontfamily{\fallbackfont}{FreeMono}
\newfontfamily{\mymainfont}{Merriweather}
\setTransitionsForMathematics{\fallbackfont}{\mymainfont}
\usepackage[all]{nowidow}
Pandoc建置腳本:
pandoc \
-f markdown+line_blocks+escaped_line_breaks+smart+fenced_code_blocks+fenced_code_attributes+backtick_code_blocks+yaml_metadata_block+footnotes+inline_notes \
-F pandoc-citeproc \
--pdf-engine=xelatex \
--standalone \
--toc \
--include-in-header=header.latex \
--highlight-style=kate \
chapters/metadata.yaml \
chapters/test.md \
-o out/out.latex
Pandoc 產生的 LaTeX:
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
%
\documentclass[
polish,
b5paper,
]{scrbook}
\usepackage{lmodern}
\usepackage{amssymb,amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\setmainfont[]{Merriweather}
\setmonofont[]{Fira Code}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={Title title},
pdfauthor={Michał Miszczyszyn},
pdflang={pl-PL},
hidelinks,
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage[b5paper]{geometry}
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{-\maxdimen} % remove section numbering
\addtokomafont{disposition}{\rmfamily}
\usepackage{indentfirst}
\setlength\parindent{24pt}
\setlength{\parskip}{.2\baselineskip}
\usepackage{setspace}
\onehalfspacing
\makeatletter
\def\verbatim@nolig@list{}
\makeatother
\usepackage{ucharclasses}
\newfontfamily{\fallbackfont}{FreeMono}
\newfontfamily{\mymainfont}{Merriweather}
\setTransitionsForMathematics{\fallbackfont}{\mymainfont}
\usepackage[all]{nowidow}
\ifxetex
% Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
\usepackage{polyglossia}
\setmainlanguage[]{polish}
\else
\usepackage[shorthands=off,main=polish]{babel}
\fi
\title{Title title\thanks{Thanks}}
\author{Michał Miszczyszyn}
\date{}
\begin{document}
\frontmatter
\maketitle
{
\setcounter{tocdepth}{2}
\tableofcontents
}
\mainmatter
\hypertarget{mwe}{%
\chapter{MWE}\label{mwe}}
Test: \texttt{X\ ≼\ Y} test test
\texttt{X\ ≼\ \ \ Y}
\texttt{X\ ≼\ \ Y}
\texttt{X\ ≼\ Y}
X ≼ Y
\backmatter
\end{document}
答案1
顯然,在您的示例中,從回退切換回來是混亂的,即它甚至\mymainfont
在≼
之內 \texttt
。這就是為什麼你最終會得到不同長度的空間。
如果您只需要很少數量的後備字符,我建議手動設定它們:
\documentclass{scrbook}
\usepackage{unicode-math}
\setmainfont{Merriweather}
\setmonofont{FreeMono}
\usepackage{newunicodechar}
\newfontfamily{\fallbackfont}{FreeMono}
\DeclareTextFontCommand\textfallback{\fallbackfont}
\newunicodechar{≼}{\textfallback{≼}}
\begin{document}
Test: \texttt{X\ ≼\ Y} test test
\texttt{X\ ≼\ \ \ Y}
\texttt{X\ ≼\ \ Y}
\texttt{X\ ≼\ Y}
X ≼ Y
\end{document}