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

Latex produces empty pages after title and table of contents #2622

Closed
nmat opened this issue Jun 5, 2016 · 23 comments
Closed

Latex produces empty pages after title and table of contents #2622

nmat opened this issue Jun 5, 2016 · 23 comments
Assignees

Comments

@nmat
Copy link

nmat commented Jun 5, 2016

Reported before. Empty pages are created using miktex and latexpdf during make process.

Even if make goes through.

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

is it possible you try to present minimal rst source creating the problem ?

@nmat
Copy link
Author

nmat commented Jun 5, 2016

@jfbu sorry I am not following?

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

@nmat perhaps I missed something from your original report, I will check. But I can not reproduce your problem without appropriate source which I can use. (assuming this is not a MikTeX issue).

@nmat
Copy link
Author

nmat commented Jun 5, 2016

This could be only miktex related. I am not 100% sure. Should I try to build it on linux also?

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

as far as I know MikTeX is very much alike TeXLIve, in so far as packages are fetched from CTAN. It is very rare a problem is only with MikTeX. I am quite confident all packages used by Sphinx for LaTeX are the same on MikTeX and TeXLive, if both are up-to-date. It would be useful if you can reduce the problematic document to a minimal project. Because apart from concluding that pdflatex compilation presumably ended in error, I can't say anything from the fact that there are blank pages in output.

@nmat
Copy link
Author

nmat commented Jun 5, 2016

I can make it simple really.

  1. Created a new directory
  2. Ran the quickstart (standard settings) no changes in conf.py
  3. In index.rst I added

testing/index.rst

  1. In testing/index.rst I added a simple header and paragraph

Ran the latexpdf and boom several pages of empty information.

NOTE also that I use 2 spaces for indenting in the rst files.

Build output: https://gist.github.com/nmat/273a28fbb3a406840da3d7c2c98ed84e

System information:
Sphinx: 1.4.3
Python: 3

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

I did reproduce your issue following your instructions.

Remove in index.rst the line above .. toctree:: containing the word Contents:.

I never observed it because I have not used for a long time the quickstart script. I always copy an earlier project skeleton. Instead.

Does this fix it for you ?

@nmat
Copy link
Author

nmat commented Jun 5, 2016

It did fix the content header page not generated as blank.....but there are still other pages that are blank. :/

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

With

latex_elements = {
     # The paper size ('letterpaper' or 'a4paper').
     #
     # 'papersize': 'letterpaper',

     # The font size ('10pt', '11pt' or '12pt').
     #
     # 'pointsize': '10pt',

     # Additional stuff for the LaTeX preamble.
     #
     # 'preamble': '',

     # Latex figure (float) alignment
     #
     # 'figure_align': 'htbp',
    'extraclassoptions': 'openany',
}

you get rid of blank pages needed by default for manual, which is that chapters open on odd pages.

I observe only one blank page after first one of table of contents.

This is no bug I think, but probably standard behaviour of report LaTeX class.

Perhaps howto in latex_documents in conf.py is more suited to your needs ?

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

ah ok I see some code including

    \cleardoublepage%

after table of contents in sphinxmanual.cls. It is late here, I will investigate another time the code above which looks strange, because \cleardoublepage should do the job by itself.

@nmat
Copy link
Author

nmat commented Jun 5, 2016

makes sense. Yeah I tested it. And still get 1 blank page after header and one after contents.

So it did remove a lot but still kept a few blank pages. Late here also. so will continue tomorrow.

If you want to talk directly to me then I am on IRC also.

@jfbu
Copy link
Contributor

jfbu commented Jun 5, 2016

seems like sphinxmanual.cls does not obey openany option for first chapter after table of contents, hence you possibly found a Sphinx bug. I will investigate tomorrow.

@jfbu
Copy link
Contributor

jfbu commented Jun 6, 2016

I have possibly fixed it, can you test PR #2626 ?

  • you must use 'extraclassoptions': 'openany', in latex_elements,
  • to avoid the issue with the Contents: line in index.rst, you should set sixth element of latex_documents to True:
latex_documents = [
    (master_doc, 'testnmat.tex', 'testnmat Documentation',
     'jfbu', 'manual', True),
]

This way you can still have Contents: in html output.

@tk0miya shouldn't default value of sixth element to latex_documents be True? the Contents: line in index.rst from quickstart script is very bad for LaTeX.

@nmat
Copy link
Author

nmat commented Jun 6, 2016

Verified and works here.

Both solutions fixes blank pages and also the extra content while still keeping html content.

Nicely done!

@jfbu
Copy link
Contributor

jfbu commented Jun 6, 2016

@nmat good to know, thanks.

jfbu added a commit to jfbu/sphinx that referenced this issue Jun 6, 2016
This cleans up comments from sphinxmanual.cls.

Memo: the logic behind the earlier sphinxmanual.cls is obscure, besides
the fact that it didn't work correctly if conf.py used openany option.
The parent commit corrected the implementation, but not the logic.

Were it not for the log message about added blank page, there would be
no need to patch \tableofcontents, because by default it will use
\chapter* which does the right thing. Similarly after the end of
abstract, a \chapter or \part (or \tableofcontents, once abstract is
properly handled by LaTeX writer (*)), currently one seems to be
contrived to use raw directive and the abstract is then after
\tableofcontents) will do the right thing in case of openany. Also the
\maketitle wrongly ended with \cleardoublepage, which was corrected in parent
commit, but better would be that it does nothing. Indeed it is not
logical for \maketitle, abstract or \tableofcontents to worry about what
comes next. Anything which comes next should be a \part or \chapter
which will do the right thing.

(*) currently one seems to be contrived to use raw directive and the
abstract is then after \tableofcontents) will do the right thing in case
of openany.
jfbu added a commit to jfbu/sphinx that referenced this issue Jun 6, 2016
Clean sphinxmanual.cls of superfluous unneeded code. And also avoid
skipping blank pages if openany for bibliography and index.
@nmat
Copy link
Author

nmat commented Jun 6, 2016

Should I close the ticket?

@jfbu
Copy link
Contributor

jfbu commented Jun 6, 2016

@nmat keep it open please until PR is reviewed and perhaps merged. I have modified it substantially, does latest version still work for you ?

@nmat
Copy link
Author

nmat commented Jun 6, 2016

Yes the latest version works just fine.

@nmat
Copy link
Author

nmat commented Jun 6, 2016

Will keep it open until it is commited and pushed. Nice work @jfbu

@jfbu
Copy link
Contributor

jfbu commented Jun 6, 2016

Thanks @nmat for patience in explaining the problem and checking proposed fixes 👍

@nmat
Copy link
Author

nmat commented Jun 7, 2016

You are most welcome! I will try to help as much as I can with testing.

@tk0miya
Copy link
Member

tk0miya commented Jun 7, 2016

@jfbu I think the sixth element of latex_documents a.k.a toctree_only is too complicated for users.
It ignores all contents in the startdoc. Then users should write contents to except startdocs.

So it is not good for me to enable it by default

@jfbu
Copy link
Contributor

jfbu commented Jun 7, 2016

@tk0miya yes I understand. If quickstart script wrote something (put here some optional contents) rather than Contents: it would be more obvious to users when they do make latexpdf the first time why they get something funny after table of contents. When one sees a blank page with "Contents:" one may take time to understand it comes from index.rst.

I think when I first started with Sphinx I followed examples were index.rst was only for toctree and one must use other files. Only later when starting experimenting with issues reported here did I understand I could put material directly in index.rst. Thus it seems you think new users have the opposite idea to the initial mine and they will use only index.rst by default ;-)

jfbu added a commit that referenced this issue Jun 8, 2016
Fix #2622: Latex produces empty pages after title and table of contents
@jfbu jfbu closed this as completed in 78589b0 Jun 8, 2016
tgraf pushed a commit to cilium/cilium that referenced this issue Apr 19, 2017
When printing out this really adds no value and seeing TOC earlier is
more interesting.

Reference: sphinx-doc/sphinx#2622
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
@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

No branches or pull requests

3 participants