From 30c7af788ca52bb484a6c576dbfa3b7c446000bf Mon Sep 17 00:00:00 2001 From: jfbu Date: Mon, 18 Nov 2019 21:15:35 +0100 Subject: [PATCH] LaTeX: revert in index entries to \textbar{} not \sphinxtextbar{} This is because of case of an index directive or role in a table cell. For the same reason tabulary is not compatible with code-cells, it affects index entries. The escaping of | char by a LaTeX macro needed to be by a "robus" or "protected" one, or by string like {"|}. This was not the choice of previous commit, by oversight. By reverting to \textbar{} (which is a "robust" command) we also maintain maximal backwards compatibility for the sorting in the index done by the makeindex program. --- sphinx/texinputs/sphinx.sty | 3 +-- sphinx/texinputs/sphinx.xdy | 2 +- sphinx/writers/latex.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 7e8421aed..5d9adb5bb 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -1881,10 +1881,9 @@ \let\sphinxtermref \@firstofone }} -% For curly braces and vertical bar inside \index macro +% For curly braces inside \index macro \def\sphinxleftcurlybrace{\{} \def\sphinxrightcurlybrace{\}} -\def\sphinxverticalbar{|} % Declare Unicode characters used by linux tree command to pdflatex utf8/utf8x \def\spx@bd#1#2{% diff --git a/sphinx/texinputs/sphinx.xdy b/sphinx/texinputs/sphinx.xdy index 0efbdef2f..1c0794cd9 100644 --- a/sphinx/texinputs/sphinx.xdy +++ b/sphinx/texinputs/sphinx.xdy @@ -109,7 +109,6 @@ (merge-rule "\sphinxleftcurlybrace{}" "{" :string) (merge-rule "\sphinxrightcurlybrace{}" "}" :string) -(merge-rule "\sphinxverticalbar{}" "|" :string) (merge-rule "\_" "_" :string) (merge-rule "{[}" "[" :string) (merge-rule "{]}" "]" :string) @@ -127,6 +126,7 @@ (merge-rule "\(\rightarrow\)" "→" :string) (merge-rule "\(\checkmark\)" "✓" :string) (merge-rule "\textendash{}" "–" :string) +(merge-rule "\textbar{}" "|" :string) (merge-rule "\(\sp{\text{0}}\)" "⁰" :string) (merge-rule "\(\sp{\text{1}}\)" "¹" :string) (merge-rule "\(\sp{\text{2}}\)" "²" :string) diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 7e79385f1..7695b31a9 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1816,7 +1816,7 @@ class LaTeXTranslator(SphinxTranslator): value = value.replace('"', '""') value = value.replace('@', '"@') value = value.replace('!', '"!') - value = value.replace('|', r'\sphinxverticalbar{}') + value = value.replace('|', r'\textbar{}') return value def style(string):