Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #9305 LaTeX: backslash in sphinxupquote error with Japanese #9335

Merged
merged 1 commit into from Jun 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -19,6 +19,8 @@ Bugs fixed
* #9330: changeset domain: :rst:dir:`versionchanged` with contents being a list
will cause error during pdf build
* #9313: LaTeX: complex table with merged cells broken since 4.0
* #9305: LaTeX: backslash may cause Improper discretionary list pdf build error
with Japanese engines

Testing
--------
Expand Down
3 changes: 2 additions & 1 deletion sphinx/texinputs/sphinxlatexliterals.sty
Expand Up @@ -765,7 +765,8 @@
% break at . , ; ? ! /
\sphinxbreaksviaactive
% break also at \
\let\sphinx@textbackslash\textbackslash
\setbox8=\hbox{\textbackslash}%
\def\sphinx@textbackslash{\copy8}%
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should perhaps use a proper scratch box but the contents of \sphinxupquote should be a text string hence it seems legit to use say \box8 as here (as this is enclosed in braces).

The \textbackslash is a complex command which checks the current font encoding and triggers a fall-back font encoding (OMS, math character) for example if character not available. So the former method with \let did not have expected effect and the \textbackslash was trying to redefine itself in a \discretionary context where only boxes are allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I mentioned OMS from my pure latex testing, but in Sphinx context this will be T1 encoding)

\let\textbackslash\sphinxtextbackslash
% by default, no continuation symbol on next line but may be added
\let\sphinxafterbreak\sphinxafterbreakofinlineliteral
Expand Down