sphinx-doc / sphinx

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

latex/xelatex: Section numbers are missing from section titles #3210

Closed rakhimov closed 7 years ago

rakhimov commented 7 years ago

html works as expected, but pdf doesn't have section numbers. 1.5 version with xelatex The code: https://github.com/open-psa/mef

tk0miya commented 7 years ago

What did you mean? At my local, section numbers are shown like following. 2016-12-10 22 17 28

Please let me know your problem in detail.

rakhimov commented 7 years ago

@tk0miya Honestly, I don't know where the problem is. The code is on https://github.com/open-psa/mef configured for xelatex. Also, for some reason, latex_engine=xelatex has no effect in conf.py. I have to set it in makefile via PDFLATEX.

I tried to configure the secnumdepth counter via preamble and hardcoding to style files in the build/latex, but no luck there also.

jfbu commented 7 years ago

I have tried your repo and have no issue. (tried with Sphinx 1.5).

[82] [83] (./opsa_mef.aux) )
(see the transcript file for additional information)
Output written on opsa_mef.pdf (91 pages).
Transcript written on opsa_mef.log.
make[1] : on quitte le répertoire « /Users/xxxxxxxxx/_gits/mef/build/latex »
pdflatex finished; the PDF files are in build/latex.

It is true that make latexpdf mentions pdflatex but the compilation did happen with xelatex:

This is XeTeX, Version 3.14159265-2.6-0.99996 (TeX Live 2016) (preloaded format=xelatex 2016.11.28)  10 DEC 2016 19:04
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**opsa_mef.tex
(./opsa_mef.tex
LaTeX2e <2016/03/31> patch level 3
Babel <3.9r> and hyphenation patterns for 52 language(s) loaded.
(./sphinxmanual.cls
Document Class: sphinxmanual 2016/10/12 v1.5 Document class (Sphinx manual)
(/usr/local/texlive/2016/texmf-dist/tex/latex/base/report.cls

I see no issue with section numbers in produced pdf.

Side note: I needed to modify make rule for inkscape into

# Pattern rule for converting SVG to PDF
%.pdf : %.svg
    $(SVG2PDF) -f ~/_gits/mef/$< -A ~/_gits/mef/$@

i.e. with full path, else inkscape complained. (but this might due to the fact that I am unfamiliar with inkscape -- I installed mac os x application and added suitable string to PATH for command line use)

rakhimov commented 7 years ago

@jfbu Thanks for reviewing. Indeed, somehow, latex_engine=xelatex didn't work so I had to put in makefile directly.

This more and more seems to be an issue on my system. Very strange issue. What could possibly affect sphinx to not generate the section numbers for latex? (it does ok with html for me.)

I tried with virtualenv but getting the same issue. I think I have to find some away to completely isolate sphinx/tex setup. Is it possible that latex/xetex/tex can be messing things, not sphinx?

jfbu commented 7 years ago

when I wrote my earlier comment I had not seen the PDFLATEX=xelatex added in the Makefile, I have removed it and tried again, and it does work the latex_engine conf.py setting is obeyed, according to latex compilation log.

Can you post somewhere opsa_mef.log after make latexpdf ?

jfbu commented 7 years ago

also add

latex_elements = {
   'preamble': '\\listfiles',
}

just to check if you have a TeX installation problem.

rakhimov commented 7 years ago

The logs: https://gist.github.com/rakhimov/e41e6bfa3b6b21884c242bf64ec43590 I am on Ubuntu 16.04.

jfbu commented 7 years ago

ok got the log. Nothing obvious so far, scanning.

jfbu commented 7 years ago

well, so far I have no explanation. I also compiled it on TeXLive 2015 (which is what you have on Ubuntu 16.04 according to the latex log) and I get the section numbers.

capture d ecran 2016-12-10 a 19 35 15

I found nothing obvious about missing fonts in your log. Your latex has a Package: titlesec 2016/03/15 v2.10.1 Sectioning titles whereas I have the marginally more recent titlesec 2016/03/21 v2.10.2. This is very weird. Can you share the tex file also just to be sure I can compile it on my system.

rakhimov commented 7 years ago

The whole generated files: https://github.com/rakhimov/tex.sx

jfbu commented 7 years ago

I cloned it, only thing is that Makefile strangely contains PDFLATEX = pdflatex (which doesn't happen with me when I do make latex from top repertory). After manually fixing this to PDFLATEX=xelatex I ran make all-pdf and the pdf is ok. The section numbers are there. I did this with TeXLive 2015.

This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex 2016.4.5)  10 DEC 2016 19:59
entering extended mode

....

 *File List*
sphinxmanual.cls    2016/10/12 v1.5 Document class (Sphinx manual)
  report.cls    2014/09/29 v1.4h Standard LaTeX document class
  size12.clo    2014/09/29 v1.4h Standard LaTeX file (size option)
geometry.sty    2010/09/12 v5.6 Page Geometry
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
    cmap.sty    2008/03/06 v1.0h CMap support: searchable PDF
 amsmath.sty    2016/03/10 v2.15b AMS math features
 amstext.sty    2000/06/29 v2.01 AMS text
  amsgen.sty    1999/11/30 v2.0 generic functions
  amsbsy.sty    1999/11/29 v1.2d Bold Symbols
  amsopn.sty    2016/03/08 v2.02 operator names
 amssymb.sty    2013/01/14 v3.01 AMS font symbols
amsfonts.sty    2013/01/14 v3.01 Basic AMSFonts support
polyglossia.sty    2015/03/25 v1.42.4 Alternative to Babel for XeLaTeX and LuaL
aTeX
etoolbox.sty    2015/08/02 v2.2a e-TeX tools for LaTeX (JAW)
makecmds.sty    2009/09/03 v1.0a extra command making commands
 xkeyval.sty    2014/12/03 v2.7a package option processing (HA)
 xkeyval.tex    2014/12/03 v2.7a key=value parser (HA)
fontspec.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
   expl3.sty    2016/03/28 v6468 L3 programming layer (loader) 
expl3-code.tex    2016/03/28 v6468 L3 programming layer 
l3xdvipdfmx.def    
  xparse.sty    2016/03/28 v6468 L3 Experimental document command parser
fontspec-xetex.sty    2016/02/01 v2.5a Font selection for XeLaTeX and LuaLaTeX
 fontenc.sty
  eu1enc.def    2010/05/27 v0.1h Experimental Unicode font encodings
  eu1lmr.fd    2009/10/30 v1.6 Font defs for Latin Modern
xunicode.sty    2011/09/09 v0.981 provides access to latin accents and many oth
er characters in Unicode lower plane
 eu1lmss.fd    2009/10/30 v1.6 Font defs for Latin Modern
graphicx.sty    2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2016/01/03 v1.0q Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg    2010/04/23 v1.9 graphics configuration of TeX Live
   xetex.def    2015/09/11 v4.06 LaTeX color/graphics driver for XeTeX (TeX Liv
e/RRM/JK)
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
fontspec.cfg
ifluatex.sty    2010/03/01 v1.3 Provides the ifluatex switch (HO)
gloss-english.ldf    polyglossia: module for english
fncychap.sty    2007/07/30 v1.34 LaTeX package (Revised chapters)
longtable.sty    2014/10/28 v4.11 Multi-page Table package (DPC)
  sphinx.sty    2016/10/29 v1.5 LaTeX package (Sphinx markup)
fancyhdr.sty    
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
titlesec.sty    2016/03/21 v2.10.2 Sectioning titles
tabulary.sty    2008/12/01 v0.9 tabulary package (DPC)
   array.sty    2014/10/28 v2.4c Tabular extension package (FMi)
 makeidx.sty    2014/09/29 v1.0m Standard LaTeX package
  framed.sty    2011/10/22 v 0.96: framed or shaded text with page breaks
  xcolor.sty    2007/01/21 v2.11 LaTeX color extensions (UK)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
fancyvrb.sty    2008/02/07
threeparttable.sty    2003/06/13  v 3.0
footnotehyper-sphinx.sty    2016/10/27 v0.9f hyperref aware footnote.sty for sp
hinx (JFB)
footnote.sty    1997/01/28 1.13 Save footnotes around boxes
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
 wrapfig.sty    2003/01/31  v 3.6
 parskip.sty    2001/04/09 non-zero parskip adjustments
   alltt.sty    1997/06/16 v2.0g defines alltt environment
 upquote.sty    2012/04/19 v1.3 upright-quote and grave-accent glyphs in verbat
im
kvoptions.sty    2011/06/30 v3.11 Key value format for package options (HO)
kvsetkeys.sty    2012/04/25 v1.16 Key value parser (HO)
etexcmds.sty    2011/02/16 v1.5 Avoid name clashes with e-TeX commands (HO)
 capt-of.sty    2009/12/29 v0.2 standard captions outside of floats
needspace.sty    2010/09/12 v1.3d reserve vertical space
sphinxhighlight.sty    2016/05/29 stylesheet for highlighting with pygments
multirow.sty    
eqparbox.sty    2013/03/15 v4.0 Create equal-widthed boxes
 environ.sty    2014/05/04 v0.3 A new way to define environments
trimspaces.sty    2009/09/17 v1.1 Trim spaces around a token list
hyperref.sty    2012/11/06 v6.83m Hypertext links for LaTeX
hobsub-hyperref.sty    2012/05/28 v1.13 Bundle oberdiek, subset hyperref (HO)
hobsub-generic.sty    2012/05/28 v1.13 Bundle oberdiek, subset generic (HO)
  hobsub.sty    2012/05/28 v1.13 Construct package bundles (HO)
 intcalc.sty    2007/09/27 v1.1 Expandable calculations with integers (HO)
kvdefinekeys.sty    2011/04/07 v1.3 Define keys (HO)
pdftexcmds.sty    2011/11/29 v0.20 Utility functions of pdfTeX for LuaTeX (HO)
pdfescape.sty    2011/11/25 v1.13 Implements pdfTeX's escape features (HO)
bigintcalc.sty    2012/04/08 v1.3 Expandable calculations on big integers (HO)
  bitset.sty    2011/01/30 v1.1 Handle bit-vector datatype (HO)
uniquecounter.sty    2011/01/30 v1.2 Provide unlimited unique counter (HO)
letltxmacro.sty    2010/09/02 v1.4 Let assignment for LaTeX macros (HO)
 hopatch.sty    2012/05/28 v1.2 Wrapper for package hooks (HO)
xcolor-patch.sty    2011/01/30 xcolor patch
atveryend.sty    2011/06/30 v1.8 Hooks at the very end of document (HO)
atbegshi.sty    2011/10/05 v1.16 At begin shipout hook (HO)
refcount.sty    2011/10/16 v3.4 Data extraction from label references (HO)
 hycolor.sty    2011/01/30 v1.7 Color options for hyperref/bookmark (HO)
 auxhook.sty    2011/03/04 v1.3 Hooks for auxiliary files (HO)
  pd1enc.def    2012/11/06 v6.83m Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
   puenc.def    2012/11/06 v6.83m Hyperref: PDF Unicode definition (HO)
     url.sty    2013/09/16  ver 3.4  Verb mode for urls, etc.
  hxetex.def    2012/11/06 v6.83m Hyperref driver for XeTeX
stringenc.sty    2011/12/02 v1.10 Convert strings between diff. encodings (HO)
rerunfilecheck.sty    2011/04/15 v1.7 Rerun checks for auxiliary files (HO)
  hypcap.sty    2011/02/16 v1.11 Adjusting the anchors of captions (HO)
   t3cmr.fd    2001/12/31 TIPA font definitions
  ts1cmr.fd    2014/09/29 v2.5h Standard LaTeX font definitions
 nameref.sty    2012/10/27 v2.43 Cross-referencing by name of section
gettitlestring.sty    2010/12/03 v1.4 Cleanup title references (HO)
opsa_mef.out
opsa_mef.out
opsa_logo.pdf    Graphic file (type QTm)
    umsa.fd    2013/01/14 v3.01 AMS symbols A
    umsb.fd    2013/01/14 v3.01 AMS symbols B
opsa_logo.pdf    Graphic file (type QTm)
 eu1lmtt.fd    2009/10/30 v1.6 Font defs for Latin Modern
architecture.pdf    Graphic file (type QTm)
 anatomy.pdf    Graphic file (type QTm)
fault_tree.pdf    Graphic file (type QTm)
fault_tree_with_components.pdf    Graphic file (type QTm)
periodic_test.png    Graphic file (type QTm)
multi_phase_markov_graph.png    Graphic file (type QTm)
lambda_histogram.pdf    Graphic file (type QTm)
small_event_tree.pdf    Graphic file (type QTm)
event_tree_structure.pdf    Graphic file (type QTm)
containers_and_constructs.pdf    Graphic file (type QTm)
 ***********
jfbu commented 7 years ago

Indeed, somehow, latex_engine=xelatex didn't work so I had to put in makefile directly.

it should be latex_engine='xelatex' but I see you have this right in your conf.py.

rakhimov commented 7 years ago

I've been trying many things: reinstalling latex/sphinx/virtualenv. The first thing that was corrected is the 'xelatex' is now picking up into makefile in python3 env virtualenv.

The weird thing is that if I write latex by hand, the sections get numbered and the latex reacts to my secnumdepth.

If I create a new/fresh sphinx project with the same file but in rst, it is the old story.

jfbu commented 7 years ago

I have no clue, because if I latex on my locale your https://github.com/rakhimov/tex.sx file, I see no issue with section numbers in pdf. Side remarks: you have files there which are remnants of earlier Sphinx. Formerly, some style files where distributed with Sphinx: fncychap.sty, iftex.sty, needspace.sty, newfloat.sty, tabulary.sty. Among them only needspace.sty is still there because its latest version is not in TL2009. Thus, when you upgraded to Sphinx 1.5 you did not make clean. However, as I said, I did compile from the repo and obtain correct result.

Now if you want to debug, you should remove from opsa_mef.tex document body all but one chapter and one section therein with one line of contents.

If the problem is there, you have an issue in the preamble. Start removing things therein. Compile with both xelatex and pdflatex to see if difference.

If the problem went away, you have an issue in body. Hence proceed by dichotomy.

... but I have no issue on my locale with your files as produced by Sphinx on your locale, hence this is all very much a mystery to me, too.

Of course you should also first make sure you don't have dual TeX installations, but the log you showed looked ok. You can run pdflatex with -recorder option to see where it picks files.

jfbu commented 7 years ago
  1. I will try a silly question: you are not referring to the PDF bookmarks, but really to the section titles inside the PDF text ? (I said it was silly).

  2. In the log you shared, all looks perfectly fine, but I noticed

(/usr/share/texmf/tex/latex/tipa/t3enc.def
File: t3enc.def 2001/12/31 T3 encoding
....
 (/usr/share/texmf/tex/latex/tipa/t3cmr.fd
File: t3cmr.fd 2001/12/31 TIPA font definitions

which is strange because all other input files are under /usr/share/texlive/texmf-dist/tex/latex/ and if I try on my locale with TeXLive2015 those t3enc.def and t3cmr.fd files are not treated differently they are found under same path prefix /usr/local/texlive/2015/texmf-dist/tex/latex as other files.

Please check your PATH and why there is this /usr/share/texmf which is a sign to problematic TeX install. The file versions are OK though. But perhaps something happens because of this /usr/share/texmf. Can you remove /usr/share/texmf from PATH and report the result of make latexpdf ?

jfbu commented 7 years ago

actually more likely than PATH (which would influence location of kpsewhich) you should check if there is a /usr/share/texlive/texmf.cnf file and report its contents. For example on my install, something like this

TEXMFLOCAL = $SELFAUTOPARENT/texmf-local
TEXMFHOME = ~/Library/texmf
TEXMFVAR = ~/Library/texlive/2016/texmf-var
TEXMFCONFIG = ~/Library/texlive/2016/texmf-config

which is typical of TeXLive installs on Mac OS X. Is there is /usr/share/texmf there in ?

Also try tlmgr conf which will output in command line console all the config of your Debian/TeXLive2015 install.

rakhimov commented 7 years ago

@jfbu Strangly, I don't usr/share/texlive/texmf.cnf. The pdf is available on https://open-psa.github.io/mef (with section numbers missing in titles) tlmgr conf output Actually, my PATH contains no tex related parts, only path to general binary locations.

I am going to try with 'texlive-fonts-extra' to see if that can be the source. (I don't know) Thanks @jfbu for investigating this mystery ( misery :()!

rakhimov commented 7 years ago

texlive-fonts-extra didn't help.

jorispz commented 7 years ago

Just a 'me too' from me on this issue. Today I created a clean install in a Docker image, installing the full TeX Live distribution on an Ubuntu 16.04 install and Sphinx 1.5 (the latest available in the Ubuntu repos).

I get the exact same problem, no section numbers appearing in the actual section headers in the PDF. They do show up in the TOC, and the also show up fine in HTML.

I have two texmf.cnf on my system, in /usr/share/texlive/texmf-dist/web2c/texmf.cnf and /user/share/texmf/web2c/texmf.cnf respectively. They have the same contents, I have attached the file here (with .txt extension so Github accepts it). texmf.cnf.txt

I'll be happy to help debugging this, let me know if I can help! I can share my Dockerfile if that would help?

jorispz commented 7 years ago

Oh, and attached is the output of tlmgr conf on my system (i.e. Docker container) tlmgr_conf_output.txt

jfbu commented 7 years ago

Hi guys. Mystery solved, and sorry for letting you dig into the bowels of your respective TeX installations. I said above:

I found nothing obvious about missing fonts in your log. Your latex has a Package: titlesec 2016/03/15 v2.10.1 Sectioning titles whereas I have the marginally more recent titlesec 2016/03/21 v2.10.2. This is very weird. Can you share the tex file also just to be sure I can compile it on my system.

Turns out that titlesec 2.10.1 had this bug http://tex.stackexchange.com/questions/299969/titlesec-loss-of-section-numbering-with-the-new-update-2016-03-15

The TeXLive2015 on your systems is not fully updated. I will think about easiest fix and write again.

jfbu commented 7 years ago

Ubuntu bug 1574052

rakhimov commented 7 years ago

Man, don't they have some regression test for this sort of simple things? Ridiculous.

jfbu commented 7 years ago

Try this:

  1. download http://mirrors.ctan.org/install/macros/latex/contrib/titlesec.tds.zip

  2. run kpsewhich --var-value TEXMFHOME, let /my/path/to/my/texmfhome be the result

  3. run unzip titlesec.tds.zip -d /my/path/to/my/texmfhome

This could work.

jfbu commented 7 years ago

@rakhimov in your case unzip titlesec.tds.zip -d /home/olzhas/texmf should do it. Make sure you don't have a ls-R file in this repertory. If you do have one run texhash /home/olzhas/texmf, if you don't have ls-R file, don't do the texhash

@jorispz in your case you installed as root. I am not sure about best procedure then, I would rather install in TEXMFLOCAL, hence in your case use /usr/local/share/texmf as installation for the unzip. You may need sudo. Most probably there is a ls-R file there. Hence do also sudo texhash /usr/local/share/texmf. Don't use sudo if you have the access rights already.

jfbu commented 7 years ago

@jorispz You may try sudo install in /root/texmf which is your TEXMFHOME. Don't run texhash on it if no ls-R file there. I never do any TeX install as root myself and have full access rights to all its repertories, hence I have no experience with such set-up.

(I didn't pay enough attention to your Docker container context; perhaps thus the above does not make sense.)

jfbu commented 7 years ago

@rakhimov If you open the doc of titlesec now which is still at 2.10.2, there is no hint whatsoever that it was issued to fix that bad bug.

rakhimov commented 7 years ago

@jfbu Great! Your suggestion for simple unzip to ~/texmf fixed it. Thanks for taking care of the issue even if it wasn't from Sphinx. Feel free to close the issue as you wish.

jfbu commented 7 years ago

@rakhimov thanks for confirming fix. I hope @jorispz will solve his issue as well.

We could at Sphinx add some code to our own LaTeX style file to detect if bad version of titlesec is in use and print an explanatory warning to console output (unfortunately LaTeX console output is so humongous it is hard to make it noticeable to the user, except if we make this an Error message). What do you think @tk0miya ? because the problem might arise again in future if Ubuntu or other distros keep on distributing buggy titlesec by default. We can not force use of 2.10.2 which is far too recent (Sphinx still supports TeXLive 2009).

Now closing.

jorispz commented 7 years ago

I can confirm this fixes the issue for me was well. Thank you @jfbu for putting so much effort into debugging something that's not even a problem with sphinx itself. Much appreciated!

FYI, since this is a Docker container solely for running sphinx on my Windows box, and everything is running as root anyway, I didn't feel much need to install packages 'properly'. So I did the simple thing and just unzipped into /root/texmf, it worked without further action.

Thanks again!

jfbu commented 7 years ago

Thanks @jorispz for reporting back. I leave in an ethereal word were OpenOffice and LibreOffice have freed me of need of knowing anything about Windows, hence I didn't even know about Docker !

Thanks @rakhimov for original report. I think it is needed for Sphinx to intercept this buggy titlesec, hence addressed at 22167b7245770e9338762a1610b789684d5ced6e. (#3241)

The LaTeX warning in case of buggy titlesec has now been merged for 1.5.2 release. It might help people not lament too long about the mistery of missing numbers.