编辑包括整个 markdown 和生成的 LaTeX:

编辑包括整个 markdown 和生成的 LaTeX:

我正在使用pandocXeLaTeX 引擎。我遇到一个问题,某些字符周围的空间一边比另一边大。给出如下 markdown:

`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}

结果是:

某些字符周围的不对称间距

请注意, 左侧的一个空格大约等于 右侧的 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

显然,在你的例子中,从 fallback 切换回来是混乱的,也就是说,它甚至\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}

在此处输入图片描述

相关内容