pandoc-latex-template icon indicating copy to clipboard operation
pandoc-latex-template copied to clipboard

Counting Images in Books

Open MAWSpitau opened this issue 4 years ago • 13 comments

Hi there,

there is a problem with the counting in the book-variant of eisvogel.

This is my minimal Example:

---
title: Ein Minimalbeispiel
author: MAWSpitau
date: 2020
lang: de-DE
book: true
---

# Kapitel 1

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

![Bild eins in Kapitel eins](https://i.imgur.com/018rQFV.png)

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

# Kapitel 2

sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

![Bild eins in Kaiptel zwei](https://i.imgur.com/YjrBUUk.png)

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

![Bild zwei in Kapitel zwei](https://i.imgur.com/CV3u3ho.png)

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

I would have expected the numbering something like this:

  • Abbildung 1.1
  • Abbildung 2.1
  • Abbildung 2.2

But the result looks like:

  • Abbildung 0.1
  • Abbildung 0.2
  • Abbildung 0.3

That is kind of a weird counting... I my opinion ;)

This is how the PDF is rendered.

pandoc minimalBsp.md --pdf-engine=xelatex --template eisvogel --top-level-division=chapter -o minimalBsp.pdf

Which infos do oyou else need for some troubleshooting?

minimalBsp.pdf

MAWSpitau avatar Apr 28 '20 08:04 MAWSpitau

that's strange. i also use eisvogel.tex in my bachelor thesis template, where it works just fine. tested the latest version, works still fine in my setup.

i tried your mwe with --pdf-engine=pdflatex and also with -V documentclass=scrbook to be sure. also tested with local images, again with the same result: the numbers are off. must be some small detail here, that we've overlooked?

cagix avatar May 11 '20 14:05 cagix

seems to be working, when using scrreport ...

cagix avatar May 11 '20 15:05 cagix

Interestingly LaTeX behaves differently if I compile via pandoc with --number-sections or without the flag.

Your command

pandoc minimalBsp.md --pdf-engine=xelatex --template eisvogel --number-sections --top-level-division=chapter -o minimalBsp.pdf

produces the desired result with --number-sections while the numbers before the headings are undesired. I'll have to experiment a bit because this behavior seems strange to me.

Wandmalfarbe avatar May 11 '20 21:05 Wandmalfarbe

At least this is kind of a workaround! Thanks for looking at it!

MAWSpitau avatar May 12 '20 04:05 MAWSpitau

well, the difference between --number-sections and your version is just

\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

(line 113, compiled with pandoc minimalBsp.md --template eisvogel.tex --top-level-division=chapter -o eisvogel_chapter.tex)

and

\setcounter{secnumdepth}{3}

(line 113, compiled with pandoc minimalBsp.md --template eisvogel.tex --top-level-division=chapter -o eisvogel_number.tex --number-sections)

cagix avatar May 12 '20 08:05 cagix

btw, when using the pandoc default latex template, you get the same behaviour.

pandoc minimalBsp.md --top-level-division=chapter -o standard.tex --standalone yields also

\setcounter{secnumdepth}{-\maxdimen} % remove section numbering

and the wrong figure offset is to be observed in the generated pdf. (update: when using document class scrbook ...)

seems to be an upstream bug?

cagix avatar May 12 '20 09:05 cagix

Ah - I see. So it is not a problem with eisvogel at all? It is more an LaTeX issue? Where can we report the bug?

MAWSpitau avatar May 12 '20 14:05 MAWSpitau

hmmm, using scrbook as document class:

  • pandoc minimalBsp.md --top-level-division=chapter --pdf-engine=pdflatex -o scrbook_numbered.pdf -V documentclass=scrbook --number-sections looks good

  • pandoc minimalBsp.md --top-level-division=chapter --pdf-engine=pdflatex -o scrbook.pdf -V documentclass=scrbook figure numbers show wrong offset

however (using default document class):

  • pandoc minimalBsp.md --top-level-division=chapter --pdf-engine=pdflatex -o book_numbered.pdf --number-sections looks good (ok, same as above, using --number-sections)

  • pandoc minimalBsp.md --top-level-division=chapter --pdf-engine=pdflatex -o book.pdf figure numbers are as expected

seems, i got it mixed up in my last comment. sry.

so, when using the pandoc default latex template (w/o specifiying a document class), everything is as expected. however, using the default latex template in combination with a book document class like scrbook, we can observe the reported behaviour.

cagix avatar May 12 '20 15:05 cagix

testing further:

  • pandoc minimalBsp.md --pdf-engine=pdflatex -o standard.pdf: numbers are ok, but default class seems to be "report" (i.e. book: true seem to be ignored?)
  • pandoc minimalBsp.md --pdf-engine=pdflatex -o standard.pdf -V book=true dito
  • pandoc minimalBsp.md --pdf-engine=pdflatex -o standard.pdf -V documentclass=book is ok (and proper book)
  • pandoc minimalBsp.md --pdf-engine=pdflatex -o standard.pdf -V documentclass=scrbook is book, but wrong figure offset ...
  • pandoc minimalBsp.md --pdf-engine=pdflatex -o standard.pdf --template eisvogel.tex dito (nice eisvogel book, but wrong figure numbers)

maybe some document classes don't like the generated \setcounter{secnumdepth}{-\maxdimen}?


to summarize: using book document class and the default pandoc latex template is working without further options. when using scrbook document class (and the default pandoc latex template), the option --number-sections will do the trick. however, when using eisvogel.tex template you would need --number-sections and --top-level-division=chapter ...

cagix avatar May 12 '20 16:05 cagix

So it is a koma Problem?

I will fix my scripts producing my pdf with this option. Thanks for figure it out!

MAWSpitau avatar May 13 '20 05:05 MAWSpitau

well, as long as you can live with numbered sections :)

i'm not sure, if this is just a koma issue. eisvogel seems to be affected as well, so it may be connected to this generated line \setcounter{secnumdepth}{-\maxdimen} when using unnumbered sections ...

cagix avatar May 13 '20 07:05 cagix

mhm... yeah. :D

It's not like it supposed to be, but it's a workaround, that helps. Thanks for everything.

MAWSpitau avatar May 14 '20 05:05 MAWSpitau

maybe this is connected to #116?

cagix avatar Sep 05 '20 16:09 cagix