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

Undefined control sequence \chapter on ePub -> LaTeX PDF #4076

Open
adius opened this issue Nov 15, 2017 · 5 comments
Open

Undefined control sequence \chapter on ePub -> LaTeX PDF #4076

adius opened this issue Nov 15, 2017 · 5 comments

Comments

@adius
Copy link

adius commented Nov 15, 2017

I'm trying to convert the 2. edition of ProGit (https://git-scm.com/book/en/v2) to PDF, but it fails.

~/D/Books $ pandoc --version
pandoc 2.0.2
Compiled with pandoc-types 1.17.3, texmath 0.10, skylighting 0.4.3.2
Default user data directory: /Users/adrian/.pandoc
Copyright (C) 2006-2017 John MacFarlane
Web:  http://pandoc.org
This is free software; see the source for copying conditions.
There is no warranty, not even for merchantability or fitness
for a particular purpose.
~/D/Books $ pandoc \
              --output 2014_progit.pdf \
              2014_progit.epub
[WARNING] Duplicate identifier '_git_p4' at input line 2162 column 24
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
[WARNING] Could not fetch resource 'images/avatars/default.jpg': replacing image with description
Error producing PDF.
! Undefined control sequence.
l.84 \chapter
@mb21 mb21 changed the title Undefined control sequence Undefined control sequence \chapter Nov 16, 2017
@mb21
Copy link
Collaborator

mb21 commented Nov 16, 2017

I can reproduce this with current master:

wget https://github.com/progit/progit2/releases/download/2.1.15/progit.epub
pandoc progit.epub -o progit.pdf

And two minimal examples. Put the following two HTML snippets in an epub file (e.g. generate one with pandoc, then open with vim and edit contained html file).

  1. This one produces the \chapter even though the default article class doesn't define the chapter environment.

    <section epub:type="chapter">
      <div>
        <h1>title</h1>
      </div>
    </section>
    
  2. And the following is even worse:

    <section epub:type="chapter">
      <h1>title</h1>
    </section>
    

    -t native on it produces the snipped below:

    $ pandoc -f native -t latex
    [Para [Span ("ch001.xhtml",[],[]) []]
    ,Header 0 ("",[],[]) [Str "title"]]
    ^D
    

    which with -t latex gives pandoc: Prelude.init: empty list

@mb21 mb21 changed the title Undefined control sequence \chapter Undefined control sequence \chapter on ePub -> LaTeX PDF Nov 16, 2017
@jgm
Copy link
Owner

jgm commented Nov 16, 2017

Support for chapters was added in 266e197

@jgm
Copy link
Owner

jgm commented Nov 16, 2017

I don't think any reader should generate level-0 headers.
Maybe @mpickering can offer some insight about why it works this way and how it could be fixed?

@jgm jgm added the bug label Nov 16, 2017
@jgm
Copy link
Owner

jgm commented Nov 16, 2017

I suppose one approach would be to have the HTML/epub reader set some flag in the internal PandocMonad state. This can then be checked (probably in App) and the base header level top level section can be set to "chapter."

With this change, we'd change the HTML reader so that instead of changing header levels when it sees the "chapter" annotation on section, it sets this special flag in the internal PandocMonad state.

@jgm
Copy link
Owner

jgm commented Nov 16, 2017

@adius as a workaround, you could try adding --top-level-division=chapter to your command line.
(EDIT: you may also need --base-header-level=2.)

jgm added a commit that referenced this issue Nov 18, 2017
even for chapter sections in epubs.

This causes problems because writers aren't set up to
expect these.

This fixes the most immediate problem in #4076.
It would be good to think more about how to propagate
the information that top-level headers are chapters
from the reader to the writer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants