Open kohenkatz opened 1 year ago
I should note that this is with v0.3.14.0 and pandoc v2.19.2, because some of my other filters still require pandoc 2.x.
Took me a while to figure out what's going on, but this is basically a quirk of subfig
package. You need \captionsetup[figure]{position=bottom}
, because pandoc-crossref will put the figure caption after subfigures, and subfig
will attach different code to the caption depending on where it expects to see it (before or after subfigures).
I'm contemplating setting this automatically, but this also affects caption spacing, which may lead to more subtle issues, so I'm tempted to opt for "if you write raw tex you know what you're doing" approach. What do you think?
Also, side note, generally you'd want to put setup into header-includes
, in this case, wrapped in \AtEndPreamble
, e.g.:
---
header-includes: |
\AtEndPreamble{%
\floatstyle{ruled}
\restylefloat{figure}
\restylefloat{table}
\captionsetup[figure]{position=bottom}
}
---
@lierdakil Thanks for the quick reply. The "if you write raw TeX you know what you're doing" approach makes sense to me, though it would be good to document this tweak.
I will test this in my document today.
Thanks for the tip about header-includes
. In my actual document, I'm putting these commands into the template itself (which had to be customized anyway for my university's requirements), and for the example that demonstrates the issue, I just did it as simply as possible.
Someone on the tex.stackexchange.com site figured out a way to do it and keep the subfigure captions on the bottom, by replacing subfig
with subcaption
.
subfig.sty
\ProvidesPackage{subfig}[2023/03/20 v1.0 subfig -> subcaption]
\expandafter\let\csname ver@subfig.sty\endcsname\@undefined % needed for older versions of subcaption package
\RequirePackageWithOptions{subcaption}
\endinput
That seems a somewhat brittle hack.
The issue AFAIU isn't that the caption is on the bottom of figures, but rather that subfig thinks it's on the top (because ruled
style typesets captions on the top). Now that highlights the fact that subfig
is a bit of a bodge in more ways than one, but the workaround itself is relatively simple if a bit obscure.
There's an argument for switching pandoc-crossref to use subcaption
altogether (there's even #182 asking for that, now that I think about it). I guess I'll give it some thought.
By default, this package applies the
ruled
style to code blocks. I want to apply the same style to tables and figures. I have some figures which have subfigures.I followed the instructions from the
float
package to use these commands to apply the style:However, applying this style causes all subfigure references to be off by one.
Here is an example document that reproduces this error:
Here is the build command I used:
Here is the rendered output, which shows references in the text to
1a
and1b
instead of2a
and2b
:How can I resolve this apparent conflict between pandoc-crossref and the restylefloat command?