Skip to content

Easy-up user customization of \sphinxcode LaTeX macro #4370

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

Merged
merged 2 commits into from
Jan 3, 2018

Conversation

jfbu
Copy link
Contributor

@jfbu jfbu commented Jan 2, 2018

Split out fancy LaTeX macros from \sphinxcode into \sphinxupquote

Since #2627 (1.4.4), \code, and then again at #3116 (1.5) \sphinxcode which is the new name has become more complicated than the original \texttt{#1}. This was to obtain straight quotes in PDF output, and to allow long inline literals to break across lines.

This means though that users who want to customize \sphinxcode, for example to not only do \texttt but to use some colour, have to copy about 10 lines of complicated LaTeX macros which should be not modified in any way. This commit moves all the code out of \sphinxcode into a separate macro \sphinxupquote.

The LaTeX writer will output \sphinxcode{\sphinxupquote{foo}} in place of former \sphinxcode{foo}. Moving the \texttt from innermost to outermost level is with no consequence.

A second commit uses easier to understand way of defining the other styling macros, so that LaTeX user examining sphinx.sty sees more easily how the macros are supposed to be defined.

@jfbu jfbu added this to the 1.7 milestone Jan 2, 2018
Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM!

@jfbu
Copy link
Contributor Author

jfbu commented Jan 3, 2018

Thanks for quick review @tk0miya ! I will move the

\protected\def\sphinxstrong#1{{\textbf{#1}}}

line next to the other macro definitions, (i.e. after the long \sphinxupquote macro) and remove from this\sphinxstrong a superfluous brace pair which is a left-over from ab5d410 when \bf got replaced by \textbf.

Before merge I will force push this squashed change for a cleaner commit history.

I have been tempted to replace \sphinxcode when used in \sphinxbfcode, \sphinxstyleliteralemphasis etc... (in sphinx.sty file) by a simple \texttt in the spirit of separate customizability, but as the user can always herself redefine these macros if she changes \sphinxcode, this not such a pressing issue.

jfbu added 2 commits January 3, 2018 08:46
…te``

Since sphinx-doc#2627 (1.4.4), `\code`, and then again at sphinx-doc#3116 (1.5)
`\sphinxcode` which is the new name has become more complicated than the
original `\texttt{#1}`. This was to obtain straight quotes in PDF output,
and to allow long inline literals to break across lines.

This means though that users who want to customize `\sphinxcode`, for
example to not only do `\texttt` but to use some colour, have to copy
about 10 lines of complicated LaTeX macros which should be not modified
in any way. This commit moves all the code out of `\sphinxcode` into a
separate macro `\sphinxupquote`.

The LaTeX writer will output `\sphinxcode{\sphinxupquote{foo}}` in place
of former `\sphinxcode{foo}`. Moving the `\texttt` from innermost to
outermost level is with no consequence.
This make clearer to average LaTeX user the format which is expected for
these macros, in case of redefinitions.
@jfbu jfbu force-pushed the easier_sphinxcode branch from d75b434 to 680d676 Compare January 3, 2018 08:07
@jfbu jfbu merged commit 5d31fad into sphinx-doc:master Jan 3, 2018
jfbu added a commit that referenced this pull request Jan 3, 2018
This is subtle LaTeX thing. Prior to merge of #4370 there was a
`\texttt` which was hiding the potential problem. The fix is to leave a
brace pair in place.
@jfbu
Copy link
Contributor Author

jfbu commented Jan 3, 2018

a space gobbling issue in \sphinxupquote (if #1 ends with a space) got fixed at c892fe9

@jfbu jfbu deleted the easier_sphinxcode branch January 14, 2018 13:09
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants