Wandmalfarbe / pandoc-latex-template

A pandoc LaTeX template to convert markdown files to PDF or LaTeX.
BSD 3-Clause "New" or "Revised" License
6.21k stars 968 forks source link

Counting Images in Books #170

Open MAWSpitau opened 4 years ago

MAWSpitau commented 4 years ago

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:

But the result looks like:

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

cagix commented 4 years ago

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 commented 4 years ago

seems to be working, when using scrreport ...

Wandmalfarbe commented 4 years ago

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.

MAWSpitau commented 4 years ago

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

cagix commented 4 years ago

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 commented 4 years ago

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?

MAWSpitau commented 4 years ago

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?

cagix commented 4 years ago

hmmm, using scrbook as document class:

however (using default document class):

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 commented 4 years ago

testing further:

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 ...

MAWSpitau commented 4 years ago

So it is a koma Problem?

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

cagix commented 4 years ago

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 ...

MAWSpitau commented 4 years ago

mhm... yeah. :D

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

cagix commented 4 years ago

maybe this is connected to #116?