-
Notifications
You must be signed in to change notification settings - Fork 77
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
numbers of subfigures are off by one #392
Comments
okay, I did a little more digging and it seems to be related with how you setup \usepackage[
font={stretch=1.2,small},
textfont={color=caption-color},
figureposition=top,
skip=2mm,
labelfont=bf,
singlelinecheck=false,
justification=$if(caption-justification)$$caption-justification$$else$raggedright$endif$
]{caption} I remember this being quite a mess and having some sort of design flaw... I'm not sure if this can actually be handled in any way? |
Did pandoc change the latex template at some point? Because pandoc-crossref doesn't do this kind of caption setup... Ugh. That's pretty annoying, there seems to be no good way to test for regressions like this. Yes, there's a design flaw with certain subfigure packages in latex, I remember having trouble with this a long time ago. Didn't touch latex in any meaningful capacity since, so not sure if e.g. switching to a different subfigure package would help. FWIW there's #182. |
I was using my own, modified template, so when using pandoc-crossref without any template or the default eisvogel template everything works as expected. I got suspicious of what I was doing when I saw this test, which should catch any regression... https://github.com/lierdakil/pandoc-crossref/blob/master/test/m2m/subfigures-grid/input.md?plain=1 . but I'm still kinda surprised it gets the parent figure number right, but the subfigure ones not. What I was also wondering is why the subfigures get no respective subfigure labels when placing them side by side i.e. like this <div id="fig:niceFig">
{#fig:nfa width=49%}
{#fig:nfb width=49%}
Nice figure!
</div> they do get the correct labels, if a third one, on a separate line is present |
Ah, I see. You got me worried for a minute there that it's broken by default and I need to scramble to make a patch-release.
Yeah, see, the problem is, this test checks that Markdown and raw LaTeX outputs match the expectation after applying pandoc-crossref, but it doesn't check that rendered LaTeX is correct, as there's no way in general to compare PDFs, at least not without jumping through a lot of hoops.
I've spent some time refreshing my memories of this mess, and basically here's the gist of it:
So...
They should? The example you've provided works fine with the default latex template, or at least it works as I would expect (ignore the fact there aren't actual images, I'm being a little lazy): Could you elaborate on what you expect to happen and what actually happens? |
To be clear, latex code for subfigures is generated by pandoc-crossref, so I can bodge something together to support |
the reproducer is this - the difference is whether the image is found or not
</div>
<div id="fig:niceFig_img_not_found">
{#fig:nfa width=33%}
{#fig:nfb width=33%}
Nice figure without images found
</div>
</div>
<div id="fig:niceFig_img_found">
{#fig:nfc width=20%}
{#fig:nfd width=20%}
Nice figure with images
</div>
<div id="fig:niceFig_img_found_three">
{#fig:nfe width=20%}
{#fig:nff width=20%}
{#fig:nfg width=20%}
Nice figure with images
</div> I build using docker run --rm \
--volume "$PWD/..:/data" \
--user $(id -u):$(id -g) \
--workdir /data/docs \
pandoc/extra:latest-ubuntu \
--filter pandoc-crossref \
t.md \
--output t.pdf |
okay, so I went down the entire rabbit hole and built everything from source in my own dockerfile: FROM ubuntu:jammy
ENV DEBIAN_FRONTEND=noninteractive
RUN : \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y \
build-essential \
curl \
libffi-dev \
libgmp-dev \
libgmp10 \
libncurses-dev \
libncurses5 \
libtinfo5 \
libffi8ubuntu1 \
zlib1g-dev \
texlive-latex-base \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-latex-extra \
lmodern \
pkg-config \
ca-certificates \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=1
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
ENV PATH="/root/.ghcup/bin:${PATH}"
RUN : \
&& ghcup install ghc 9.6.2 \
&& ghcup install cabal 3.10.1.0 \
&& ghcup install stack 2.11.1 \
&& cabal v2-update
RUN : \
&& cabal v2-install --install-method=copy pandoc pandoc-crossref --minimize-conflict-set \
&& cabal install pandoc-cli
ARG TEMPLATES_DIR=/.pandoc/templates
ENV PATH="/root/.cabal/bin:${PATH}"
RUN mkdir -p ${TEMPLATES_DIR} && \
ln -s /.pandoc /root/.pandoc
ENTRYPOINT [ "/root/.cabal/bin/pandoc" ] an guess what: everything works as expected: So the image pandoc/extra:latest-ubuntu is somewhat broken in regard to Sorry for wasting your time here. I was not expecting the docker image to be the problem and was hesitant to build the world from source... Thank you so much for your time and effort here. Do you think it makes sense to report this upstream? Happy to hear your thoughts on this. Is it likely that it's just a crooked template? |
I don't personally use If you only need LaTeX, chances are, you don't need pandoc-crossref, raw latex syntax will work. If you want to target multiple formats, and latex is a bit of an afterthought, pandoc-crossref will work out of the box with pandoc's default template. If you need fancy formatting in your latex output, you'll probably want to roll your own template by hand. |
sorry - I missclicked and submitted the issue too early.
this reproduces it
As you can see, the figure numbers itself are correct, but the sub figures are off by one

The text was updated successfully, but these errors were encountered: