sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.42k stars 2.09k forks source link

Inline literal with backticks stylization is missing in generated PDF file (in Sphinx v7.2.6) #11974

Closed pique-b closed 7 months ago

pique-b commented 7 months ago

Describe the bug

While checking why suddenly the latexpdf compilation had stopped working after I had added numfig = True, found another issue.

Till Sphinx version 3.1.2, the inline literal with backticks were being styled in way that would be different from the rest of the text (shown underlined in red). Please refer images below (if we compare between the HTML page and that from the PDF page).

And in v7.2.6, the texts are not stylized in the way as seen in the case of v3.1.2 (as seen in the above instance). Please check the images for a comparison:

Screen grab of HTML page (v3.1.2)

HTML_Scrn_312

Screen grab of PDF page (v3.1.2)

PDF_Scrn_312

Screen grab of HTML page (v7.2.6)

HTML_Scrn_726

Screen grab of PDF page (v7.2.6)

PDF_Scrn_726

In both the cases cited, I am using bare-bone sttings in conf.py.

How to Reproduce

For the inline literal I am using:

Should I ``now revert back to Sphinx v3.1.2`` or lower than ``v6.1.0`` 

Environment Information

Sphinx 3.1.2 and 7.2.6 (As stated above)
macOS 10.12.6
Python 3.9
Tex Live 2023

Sphinx extensions

No response

Additional context

As you would agree the difference in text style for the ones with backticks from the rest of the texts certainly helps visually.

Could somebody please check and advise if what I am finding in the above cases are to be expected i.e. between the versions 3.1.2 and 7.2.6.

jfbu commented 7 months ago

https://www.sphinx-doc.org/en/master/latex.html#the-latex-elements-configuration-setting

The monospace font has been changed to better match the Times clone.

'fontpkg'

    Font package inclusion. The default is:

    r"""\usepackage{tgtermes}
    \usepackage{tgheros}
    \renewcommand\ttdefault{txtt}
    """

    For 'xelatex' and 'lualatex' however the default is to use the GNU FreeFont.

    Changed in version 1.2: Defaults to '' when the [language](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-language) uses the Cyrillic script.

    Changed in version 2.0: Incorporates some font substitution commands to help support occasional Greek or Cyrillic in a document using 'pdflatex' engine.

    Changed in version 4.0.0:

        The font substitution commands added at 2.0 have been moved to the 'fontsubstitution' key, as their presence here made it complicated for user to customize the value of 'fontpkg'.

        The default font setting has changed: it still uses Times and Helvetica clones for serif and sans serif, but via better, more complete TeX fonts and associated LaTeX packages. The monospace font has been changed to better match the Times clone.
pique-b commented 7 months ago

@jfbu Thanks for your reply.

Sorry but I had used the options earlier which led to various issues. Your reply prompted me to look at using the package/s once again (in various combinations), but has not got me anywhere. (Sorry I know I need to be serious, but my head is still spinning with the number of compilations I have carried out!!)

  1. If I use combination of \usepackage[LGR,T1]{fontenc} I get an error

! LaTeX Error: Command \textrho unavailable in encoding T1 (I have used the letter in my doc)

So I end up using package \usepackage{textalpha,alphabeta} which eliminates the above cited error. (Earlier, for each Greek letter, I was adding , for example, \DeclareUnicodeCharacter{03C1}{$\rho$} separately).

  1. If I use only \usepackage[T1]{fontenc}, the compilation is completed without error. But then I need to use either:

\usepackage{textalpha,alphabeta}

Or

\DeclareUnicodeCharacter{03C1}{$\rho$}

as described above.

  1. Apart from above, I have used all kinds of permutations (I think) but to no avail.

In the interim, one thing has eluded me altogether: I could not figure out how to use fontsubstitution.

However, my original issue (the very reason for this present query) has not got resolved. The texts still do not get stylized for those marked with backticks (some_text).

May I ask you to kindly show me the way to resolve this.

jfbu commented 7 months ago

@pique-b I don't see how your comment is linked with your original post. And I don't see what is the problem you are trying to refer to in your post initiating this thread, beyond the fact that the modified looks is explained by the font change at 4.0.0. As per the other problems you seem to experience they don't seem to be related with your original post.

jayaddison commented 7 months ago

@pique-b is the problem that you'd like the monospaced text segments to look more visually distinct from text that surrounds it?

It sounds like you've tried a few things already, but can I check that you've looked at the LaTeX customization documentation for Sphinx?