quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.69k stars 298 forks source link

Allow to pass option to subcaption package in latex (e.g list of figures inclusion) #5347

Open DhruvaSambrani opened 1 year ago

DhruvaSambrani commented 1 year ago

Bug description

Import the subcaption package as

\usepackage[list=true]{subcaption}

to allow for subcaptions being included in the list of figures.

Checklist

cderv commented 1 year ago

Just a comment because I saw this new feature in Pandoc 3.0 and quarto 1.3 uses it now

list=true can't be added to this line by pandoc's variable. So if this is related to this new addition, maybe this is something to add upstream. cc @tarleb

Just sharing in case it is relevant for the upcoming work

cscheid commented 1 year ago

@DhruvaSambrani Can you share a document where you wish this feature was enabled? I'm otherwise inclined to agree with @cderv, and think this has been solved. Thanks!

DhruvaSambrani commented 1 year ago

test.zip

In this document, I would like the subcaptions (Hanno and Sarus) to also be in the List Of Figures.

❯ quarto check

[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.1.1: OK
      Dart Sass version 1.55.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.3.353
      Path: /opt/quarto/bin

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.10.9 (Conda)
      Path: /home/dhruva/.julia/conda/3/x86_64/bin/python3.10
      Jupyter: 5.2.0
      Kernels: julia-1.9, python3

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
cderv commented 1 year ago

Thanks for sharing this !

It seems Quarto itself is handling the insertion of subcaption https://github.com/quarto-dev/quarto-cli/blob/db9b963758ea3bca30c998054c00589e092b2f63/src/resources/filters/layout/meta.lua#L9-L14

So we could add the list=true option maybe

diff --git a/src/resources/filters/layout/meta.lua b/src/resources/filters/layout/meta.lua
index 611c8b041..f3348d49b 100644
--- a/src/resources/filters/layout/meta.lua
+++ b/src/resources/filters/layout/meta.lua
@@ -5,12 +5,11 @@
 function layout_meta_inject_latex_packages()
   return {
     Meta = function(meta)
-
       -- inject caption, subfig, tikz
       metaInjectLatex(meta, function(inject)
         inject(
           usePackage("caption") .. "\n" ..
-          usePackage("subcaption")
+          usePackageWithOption("subcaption", "list=true")
         )
         if layoutState.usingTikz then
           inject(usePackage("tikz"))

The above fix is working.

@cscheid @dragonstyle Do you think we should add subcaption title in list of figure always ? Or should it be by default and with a new lof option to opt-out ?

cderv commented 10 months ago

Current workaround for this : use a header include

    include-in-header: 
      text: |
        \PassOptionsToPackage{list=true}{subcaption}