如果链接中有重音符号,XeLaTeX href 会失败

如果链接中有重音符号,XeLaTeX href 会失败

这段代码应该创建一个带有链接的文档 https://fr.wikipedia.org/wiki/Alignement_en_mémoire

相反,链接指向https://fr.wikipedia.org/wiki/Alignement_en_mémoire

这是为什么?该如何解决?

已编辑:百分比编码提供了一个有效的链接,但indent-region在 emacs(在 OS X 上)中现在给出了错误的缩进,并且日志文件显示了一个问题。

% Pour XeTeX
\XeTeXdefaultencoding utf-8

\documentclass[10pt,svgnames]{beamer}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes} % gestion des guillemets (pas sûr que cela reste indispensable avec polyglossia)
\definecolor{links}{HTML}{2A1B81}
\hypersetup{colorlinks,linkcolor=,urlcolor=links}

\begin{document}
\begin{frame}
  \begin{itemize}
  \item Pour des raisons d'\href{https://fr.wikipedia.org/wiki/Alignement_en_mémoire}{alignement
      en mémoire}, le format BMP a recours au padding.

  \item Pour des raisons d'\href{https://fr.wikipedia.org/wiki/Alignement_en_m%C3%A9moire}{alignement en mémoire}, le format BMP a recours au padding.
    \end{itemize}
  \end{frame}
\end{document}

日志文件的开始和结束:

This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019) (preloaded format=xelatex 2020.2.18)  19 JUN 2020 09:32
entering extended mode
 restricted \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**test.tex
(./test.tex
LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
(/usr/local/texlive/2019/texmf-dist/tex/latex/beamer/beamer.cls
Document Class: beamer 2019/09/29 v3.57 A class for typesetting presentations
(/usr/local/texlive/2019/texmf-dist/tex/latex/beamer/beamerbasemodes.sty
(/usr/local/texlive/2019/texmf-dist/tex/latex/etoolbox/etoolbox.sty
Package: etoolbox 2019/09/21 v2.5h e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count163
)
\beamer@tempbox=\box45
\beamer@tempcount=\count164
\c@beamerpauses=\count165

(/usr/local/texlive/2019/texmf-dist/tex/latex/beamer/beamerbasedecode.sty
\beamer@slideinframe=\count166
\beamer@minimum=\count167
\beamer@decode@box=\box46
)
\beamer@commentbox=\box47
\beamer@modecount=\count168
)
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifpdf.sty
Package: ifpdf 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.

(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2019/11/07 v1.0c TeX engine tests
))

---------------------------------------------------   

(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-basic-dicti
onary-English.dict
Dictionary: translator-basic-dictionary, Language: English 
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-bibliograph
y-dictionary-English.dict
Dictionary: translator-bibliography-dictionary, Language: English 
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-environment
-dictionary-English.dict
Dictionary: translator-environment-dictionary, Language: English 
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-months-dict
ionary-English.dict
Dictionary: translator-months-dictionary, Language: English 
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-numbers-dic
tionary-English.dict
Dictionary: translator-numbers-dictionary, Language: English 
)
(/usr/local/texlive/2019/texmf-dist/tex/latex/translator/translator-theorem-dic
tionary-English.dict
Dictionary: translator-theorem-dictionary, Language: English 
)

Package fontspec Info: Adjusting the maths setup (use [no-math] to avoid
(fontspec)             this).

\symlegacymaths=\mathgroup8
LaTeX Font Info:    Overwriting symbol font `legacymaths' in version `bold'
(Font)                  OT1/cmr/m/n --> OT1/cmr/bx/n on input line 12.
LaTeX Font Info:    Redeclaring math accent \acute on input line 12.
LaTeX Font Info:    Redeclaring math accent \grave on input line 12.
LaTeX Font Info:    Redeclaring math accent \ddot on input line 12.
LaTeX Font Info:    Redeclaring math accent \tilde on input line 12.
LaTeX Font Info:    Redeclaring math accent \bar on input line 12.
LaTeX Font Info:    Redeclaring math accent \breve on input line 12.
LaTeX Font Info:    Redeclaring math accent \check on input line 12.
LaTeX Font Info:    Redeclaring math accent \hat on input line 12.
LaTeX Font Info:    Redeclaring math accent \dot on input line 12.
LaTeX Font Info:    Redeclaring math accent \mathring on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Gamma on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Delta on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Theta on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Lambda on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Xi on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Pi on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Sigma on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Upsilon on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Phi on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Psi on input line 12.
LaTeX Font Info:    Redeclaring math symbol \Omega on input line 12.
LaTeX Font Info:    Redeclaring math symbol \mathdollar on input line 12.
LaTeX Font Info:    Redeclaring symbol font `operators' on input line 12.
LaTeX Font Info:    Encoding `OT1' has changed to `TU' for symbol font
(Font)              `operators' in the math version `normal' on input line 12.
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  OT1/cmss/m/n --> TU/lmr/m/n on input line 12.
LaTeX Font Info:    Encoding `OT1' has changed to `TU' for symbol font
(Font)              `operators' in the math version `bold' on input line 12.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  OT1/cmss/b/n --> TU/lmr/m/n on input line 12.
LaTeX Font Info:    Overwriting symbol font `operators' in version `normal'
(Font)                  TU/lmr/m/n --> TU/lmr/m/n on input line 12.
LaTeX Font Info:    Redeclaring math alphabet \mathrm on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `normal'
(Font)                  TU/lmss/m/it --> TU/lmr/m/it on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathbf' in version `normal'
(Font)                  TU/lmss/b/n --> TU/lmr/b/n on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `normal'
(Font)                  TU/lmss/m/n --> TU/lmss/m/n on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `normal'
(Font)                  TU/lmtt/m/n --> TU/lmtt/m/n on input line 12.
LaTeX Font Info:    Overwriting symbol font `operators' in version `bold'
(Font)                  TU/lmr/m/n --> TU/lmr/b/n on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathit' in version `bold'
(Font)                  TU/lmss/b/it --> TU/lmr/b/it on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathsf' in version `bold'
(Font)                  TU/lmss/b/n --> TU/lmss/b/n on input line 12.
LaTeX Font Info:    Overwriting math alphabet `\mathtt' in version `bold'
(Font)                  TU/lmtt/b/n --> TU/lmtt/b/n on input line 12.
LaTeX Info: Redefining \rmfamily on input line 12.
LaTeX Info: Redefining \sffamily on input line 12.
LaTeX Info: Redefining \ttfamily on input line 12.
 (./test.nav))
Runaway argument?
\begin {itemize} \item Pour des raisons d'\href {https://fr.wikipedia\ETC.
! File ended while scanning use of \frame.
<inserted text> 
                \par 
<*> test.tex
            
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! Emergency stop.
<*> test.tex
            
*** (job aborted, no legal \end found)

 
Here is how much of TeX's memory you used:
 24768 strings out of 479819
 500728 string characters out of 5893613
 811726 words of memory out of 5000000
 41412 multiletter control sequences out of 15000+600000
 532730 words of font info for 29 fonts, out of 8000000 for 9000
 1348 hyphenation exceptions out of 8191
 58i,4n,67p,792b,289s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.

答案1

macOS 中可能存在一些错误。

% url-test.tex
\documentclass{article}
\usepackage{hyperref}

\begin{document}
\href{https://www.wikiwand.com/fr/Alignement_en_mémoire}{alignement en mémoire}
\end{document}

使用以下命令运行上述示例

xelatex -no-pdf url-test.tex
dviasm url-test.xdv > url-test.dviasm
xdvipdfmx -C 0x40 url-test.xdv

然后

  • .dviasm文件包含URI(https://www.wikiwand.com/fr/Alignement_en_mémoire),并且
  • .pdf文件包含URI(https://www.wikiwand.com/fr/Alignement_en_m\303\251moire)

两者都正确。

如果我单击 TeXstudio 的内部 pdf 查看器或 Skim.app 中的 url,则它们都会打开https://www.wikiwand.com/fr/Alignement_en_m%EF%BF%BDmoire,这是错误的。但是,Adobe Reader 会打开正确的 url。

我在 macOS 10.15.5 上,带有 texlive 2020 和最新的 latex 包。

答案2

如果我们用反斜杠转义百分比符号,百分比编码就可以解决问题,并且不会产生额外的错误。

% Pour XeTeX
\XeTeXdefaultencoding utf-8

\documentclass[10pt,svgnames]{beamer}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}
\usepackage{csquotes} % gestion des guillemets (pas sûr que cela reste indispensable avec polyglossia)
\definecolor{links}{HTML}{2A1B81}
\hypersetup{colorlinks,linkcolor=,urlcolor=links}

\begin{document}
\begin{frame}
  \begin{itemize}
  \item Pour des raisons d'\href{https://fr.wikipedia.org/wiki/Alignement_en_mémoire}{alignement
      en mémoire}, le format BMP a recours au padding.

  \item Pour des raisons d'\href{https://fr.wikipedia.org/wiki/Alignement_en_m\%C3\%A9moire}{alignement en mémoire}, le format BMP a recours au padding.
  \end{itemize}
\end{frame}
\end{document}

因此,程序是从 Firefox 复制地址以获取百分比编码,然后添加反斜杠。

相关内容