diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,20 @@
+## 0.3.17.1
+
+-   Fix images roundtripping through Markdown
+
+    Since a few versions ago, Makrdown images were not round-tripped properly.
+    This has been addressed. More information at
+    <https://github.com/jgm/pandoc/issues/9720>
+
 ## 0.3.17.0
 
 -   Bump minimal pandoc version to 3.1.8
 
 
-    Pandoc doesn't use hypertarget since 3.1.7, and inserts `label`s for named spans. This was messing with pandoc-crossref logic, hence required some changes. 3.1.7 has an unfortunate bug which prevents figures from working in LaTeX, hence the minimal version is 3.1.8.
+    Pandoc doesn't use hypertarget since 3.1.7, and inserts `label`s for named
+    spans. This was messing with pandoc-crossref logic, hence required some
+    changes. 3.1.7 has an unfortunate bug which prevents figures from working in
+    LaTeX, hence the minimal version is 3.1.8.
 
 -   Bump dependencies for GHC to 9.6.2, bump GHC to 9.6.2 on CI for Linux and macOS
 
diff --git a/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs b/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs
--- a/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs
+++ b/lib-internal/Text/Pandoc/CrossRef/References/Blocks/Subfigures.hs
@@ -205,9 +205,12 @@
   opts <- ask
   let label' = normalizeLabel label
   let title = blocksToInlines [btitle]
-      attrs = case blocksToInlines content of
-        [Image (_, _, as) _ _] -> fattrs <> as
-        _ -> fattrs
+      (attrs, content') = case blocksToInlines content of
+        [Image attr@(_, _, as) _ tgt] ->
+            -- the second argument is a fix for
+            -- https://github.com/jgm/pandoc/issues/9720
+            (fattrs <> as, \capt -> [Plain [Image attr capt tgt]])
+        _ -> (fattrs, const content)
   idxStr <- replaceAttr label' attrs title SPfxImg
   let title'
         | isLatexFormat opts = title
@@ -216,5 +219,5 @@
   replaceNoRecurse $
     if subFigure && isLatexFormat opts
     then Plain $ latexSubFigure (head $ blocksToInlines content) label
-    else Figure (label,cls,setLabel opts idxStr fattrs) caption' content
+    else Figure (label,cls,setLabel opts idxStr fattrs) caption' (content' title')
 runFigure _ _ _ _ = noReplaceNoRecurse
diff --git a/pandoc-crossref.cabal b/pandoc-crossref.cabal
--- a/pandoc-crossref.cabal
+++ b/pandoc-crossref.cabal
@@ -1,11 +1,11 @@
 cabal-version: 2.0
 
--- This file has been generated from package.yaml by hpack version 0.34.4.
+-- This file has been generated from package.yaml by hpack version 0.36.0.
 --
 -- see: https://github.com/sol/hpack
 
 name:           pandoc-crossref
-version:        0.3.17.0
+version:        0.3.17.1
 synopsis:       Pandoc filter for cross-references
 description:    pandoc-crossref is a pandoc filter for numbering figures, equations, tables and cross-references to them.
 category:       Text
@@ -136,7 +136,7 @@
     , pandoc >=3.1.8 && <3.2
     , pandoc-crossref-internal
     , pandoc-types ==1.23.*
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
   default-language: Haskell2010
 
 library pandoc-crossref-internal
@@ -181,7 +181,7 @@
     , pandoc-types ==1.23.*
     , syb >=0.4 && <0.8
     , template-haskell >=2.7.0.0 && <3.0.0.0
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
     , utility-ht >=0.0.11 && <0.1.0
   default-language: Haskell2010
 
@@ -203,7 +203,7 @@
     , pandoc-types ==1.23.*
     , template-haskell >=2.7.0.0 && <3.0.0.0
     , temporary >=1.2 && <1.4
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
   default-language: Haskell2010
 
 test-suite test-integrative
@@ -222,10 +222,10 @@
     , pandoc >=3.1.8 && <3.2
     , pandoc-crossref
     , pandoc-types ==1.23.*
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
+  default-language: Haskell2010
   if flag(enable_flaky_tests)
     cpp-options: -DFLAKY
-  default-language: Haskell2010
 
 test-suite test-pandoc-crossref
   type: exitcode-stdio-1.0
@@ -249,10 +249,10 @@
     , pandoc-crossref
     , pandoc-crossref-internal
     , pandoc-types ==1.23.*
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
+  default-language: Haskell2010
   if flag(enable_flaky_tests)
     cpp-options: -DFLAKY
-  default-language: Haskell2010
 
 benchmark simple
   type: exitcode-stdio-1.0
@@ -268,5 +268,5 @@
     , pandoc >=3.1.8 && <3.2
     , pandoc-crossref
     , pandoc-types ==1.23.*
-    , text >=1.2.2 && <2.1
+    , text >=1.2.2 && <2.2
   default-language: Haskell2010
diff --git a/test/demo-chapters.inc b/test/demo-chapters.inc
--- a/test/demo-chapters.inc
+++ b/test/demo-chapters.inc
@@ -86,7 +86,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "A" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "1:"
+              , Space
+              , Str "A"
+              , Space
+              , Str "figure"
+              ]
               ( "img1.jpg" , "" )
           ]
       ]
@@ -319,7 +328,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "First" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "1.1:"
+              , Space
+              , Str "First"
+              , Space
+              , Str "figure"
+              ]
               ( "img1.jpg" , "" )
           ]
       ]
@@ -342,7 +360,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "Second" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "1.2:"
+              , Space
+              , Str "Second"
+              , Space
+              , Str "figure"
+              ]
               ( "img2.jpg" , "" )
           ]
       ]
@@ -365,7 +392,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "Third" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "1.3:"
+              , Space
+              , Str "Third"
+              , Space
+              , Str "figure"
+              ]
               ( "img3.jpg" , "" )
           ]
       ]
@@ -417,21 +453,13 @@
           ( "" , [] , [] )
           (Caption Nothing [ Plain [ Str "a" ] ])
           [ Plain
-              [ Image
-                  ( "" , [] , [] )
-                  [ Str "Subfigure" , Space , Str "a" ]
-                  ( "img1.jpg" , "" )
-              ]
+              [ Image ( "" , [] , [] ) [ Str "a" ] ( "img1.jpg" , "" ) ]
           ]
       , Figure
           ( "fig:subfigureB" , [] , [] )
           (Caption Nothing [ Plain [ Str "b" ] ])
           [ Plain
-              [ Image
-                  ( "" , [] , [] )
-                  [ Str "Subfigure" , Space , Str "b" ]
-                  ( "img1.jpg" , "" )
-              ]
+              [ Image ( "" , [] , [] ) [ Str "b" ] ( "img1.jpg" , "" ) ]
           ]
       ]
   , Header
diff --git a/test/demo.inc b/test/demo.inc
--- a/test/demo.inc
+++ b/test/demo.inc
@@ -86,7 +86,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "A" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "1:"
+              , Space
+              , Str "A"
+              , Space
+              , Str "figure"
+              ]
               ( "img1.jpg" , "" )
           ]
       ]
@@ -319,7 +328,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "First" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "2:"
+              , Space
+              , Str "First"
+              , Space
+              , Str "figure"
+              ]
               ( "img1.jpg" , "" )
           ]
       ]
@@ -342,7 +360,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "Second" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "3:"
+              , Space
+              , Str "Second"
+              , Space
+              , Str "figure"
+              ]
               ( "img2.jpg" , "" )
           ]
       ]
@@ -365,7 +392,16 @@
       [ Plain
           [ Image
               ( "" , [] , [] )
-              [ Str "Third" , Space , Str "figure" ]
+              [ Str "Figure"
+              , Space
+              , Str "#"
+              , Space
+              , Str "4:"
+              , Space
+              , Str "Third"
+              , Space
+              , Str "figure"
+              ]
               ( "img3.jpg" , "" )
           ]
       ]
@@ -417,21 +453,13 @@
           ( "" , [] , [] )
           (Caption Nothing [ Plain [ Str "a" ] ])
           [ Plain
-              [ Image
-                  ( "" , [] , [] )
-                  [ Str "Subfigure" , Space , Str "a" ]
-                  ( "img1.jpg" , "" )
-              ]
+              [ Image ( "" , [] , [] ) [ Str "a" ] ( "img1.jpg" , "" ) ]
           ]
       , Figure
           ( "fig:subfigureB" , [] , [] )
           (Caption Nothing [ Plain [ Str "b" ] ])
           [ Plain
-              [ Image
-                  ( "" , [] , [] )
-                  [ Str "Subfigure" , Space , Str "b" ]
-                  ( "img1.jpg" , "" )
-              ]
+              [ Image ( "" , [] , [] ) [ Str "b" ] ( "img1.jpg" , "" ) ]
           ]
       ]
   , Header
diff --git a/test/m2m/emptyChapterLabels/expect.md b/test/m2m/emptyChapterLabels/expect.md
--- a/test/m2m/emptyChapterLabels/expect.md
+++ b/test/m2m/emptyChapterLabels/expect.md
@@ -2,13 +2,7 @@
 
 ## 1 Subsection {#sec:subsection label=""}
 
-::: {#fig:figure1 .figure}
-![Figure1](./image.png)
-
-::: caption
-Figure 1: Figure1
-:::
-:::
+![Figure 1: Figure1](./image.png){#fig:figure1}
 
 ### 1.1 Subsubsection {#sec:subsubsection}
 
diff --git a/test/m2m/label-precedence/expect.md b/test/m2m/label-precedence/expect.md
--- a/test/m2m/label-precedence/expect.md
+++ b/test/m2m/label-precedence/expect.md
@@ -2,25 +2,13 @@
 
 text
 
-::: {#fig:fig1 .figure}
-![A figure](image.png)
-
-::: caption
-Figure α: A figure
-:::
-:::
+![Figure α: A figure](image.png){#fig:fig1}
 
 ## \*.A Subsection {#subsection}
 
 other text
 
-::: {#fig:fig2 .figure}
-![A figure with custom label](image.png){label="+"}
-
-::: caption
-Figure +: A figure with custom label
-:::
-:::
+![Figure +: A figure with custom label](image.png){#fig:fig2 label="+"}
 
 ### \*.A.A Subsubsection {#subsubsection}
 
@@ -28,13 +16,7 @@
 
 # B Custom on other elements {#custom-on-other-elements}
 
-::: {#fig:fig3 .figure}
-![Figure](fig.png){label="F"}
-
-::: caption
-Figure F: Figure
-:::
-:::
+![Figure F: Figure](fig.png){#fig:fig3 label="F"}
 
 ::: {#tbl:table label="T"}
   a   b   c
diff --git a/test/m2m/listOfTemplates-buillet-list/expect.md b/test/m2m/listOfTemplates-buillet-list/expect.md
--- a/test/m2m/listOfTemplates-buillet-list/expect.md
+++ b/test/m2m/listOfTemplates-buillet-list/expect.md
@@ -1,74 +1,20 @@
-::: {#fig:1 .figure}
-![1](fig1.png)
-
-::: caption
-Figure 1: 1
-:::
-:::
-
-::: {#fig:2 .figure}
-![2](fig2.png)
-
-::: caption
-Figure 2: 2
-:::
-:::
-
-::: {#fig:3 .figure}
-![3](fig3.png)
-
-::: caption
-Figure 3: 3
-:::
-:::
-
-::: {#fig:4 .figure}
-![4](fig4.png)
-
-::: caption
-Figure 4: 4
-:::
-:::
-
-::: {#fig:5 .figure}
-![5](fig5.png)
-
-::: caption
-Figure 5: 5
-:::
-:::
+![Figure 1: 1](fig1.png){#fig:1}
 
-::: {#fig:6 .figure}
-![6](fig6.png)
+![Figure 2: 2](fig2.png){#fig:2}
 
-::: caption
-Figure 6: 6
-:::
-:::
+![Figure 3: 3](fig3.png){#fig:3}
 
-::: {#fig:7 .figure}
-![7](fig7.png)
+![Figure 4: 4](fig4.png){#fig:4}
 
-::: caption
-Figure 7: 7
-:::
-:::
+![Figure 5: 5](fig5.png){#fig:5}
 
-::: {#fig:8 .figure}
-![8](fig8.png)
+![Figure 6: 6](fig6.png){#fig:6}
 
-::: caption
-Figure 8: 8
-:::
-:::
+![Figure 7: 7](fig7.png){#fig:7}
 
-::: {#fig:9 .figure}
-![9](fig9.png)
+![Figure 8: 8](fig8.png){#fig:8}
 
-::: caption
-Figure 9: 9
-:::
-:::
+![Figure 9: 9](fig9.png){#fig:9}
 
 # List of Figures
 
diff --git a/test/m2m/listOfTemplates-ord-list/expect.md b/test/m2m/listOfTemplates-ord-list/expect.md
--- a/test/m2m/listOfTemplates-ord-list/expect.md
+++ b/test/m2m/listOfTemplates-ord-list/expect.md
@@ -1,74 +1,20 @@
-::: {#fig:1 .figure}
-![1](fig1.png)
-
-::: caption
-Figure 1: 1
-:::
-:::
-
-::: {#fig:2 .figure}
-![2](fig2.png)
-
-::: caption
-Figure 2: 2
-:::
-:::
-
-::: {#fig:3 .figure}
-![3](fig3.png)
-
-::: caption
-Figure 3: 3
-:::
-:::
-
-::: {#fig:4 .figure}
-![4](fig4.png)
-
-::: caption
-Figure 4: 4
-:::
-:::
-
-::: {#fig:5 .figure}
-![5](fig5.png)
-
-::: caption
-Figure 5: 5
-:::
-:::
+![Figure 1: 1](fig1.png){#fig:1}
 
-::: {#fig:6 .figure}
-![6](fig6.png)
+![Figure 2: 2](fig2.png){#fig:2}
 
-::: caption
-Figure 6: 6
-:::
-:::
+![Figure 3: 3](fig3.png){#fig:3}
 
-::: {#fig:7 .figure}
-![7](fig7.png)
+![Figure 4: 4](fig4.png){#fig:4}
 
-::: caption
-Figure 7: 7
-:::
-:::
+![Figure 5: 5](fig5.png){#fig:5}
 
-::: {#fig:8 .figure}
-![8](fig8.png)
+![Figure 6: 6](fig6.png){#fig:6}
 
-::: caption
-Figure 8: 8
-:::
-:::
+![Figure 7: 7](fig7.png){#fig:7}
 
-::: {#fig:9 .figure}
-![9](fig9.png)
+![Figure 8: 8](fig8.png){#fig:8}
 
-::: caption
-Figure 9: 9
-:::
-:::
+![Figure 9: 9](fig9.png){#fig:9}
 
 # List of Figures
 
diff --git a/test/m2m/listOfTemplates/expect.md b/test/m2m/listOfTemplates/expect.md
--- a/test/m2m/listOfTemplates/expect.md
+++ b/test/m2m/listOfTemplates/expect.md
@@ -1,74 +1,20 @@
-::: {#fig:1 .figure}
-![1](fig1.png)
-
-::: caption
-Figure 1: 1
-:::
-:::
-
-::: {#fig:2 .figure}
-![2](fig2.png)
-
-::: caption
-Figure 2: 2
-:::
-:::
-
-::: {#fig:3 .figure}
-![3](fig3.png)
-
-::: caption
-Figure 3: 3
-:::
-:::
-
-::: {#fig:4 .figure}
-![4](fig4.png)
-
-::: caption
-Figure 4: 4
-:::
-:::
-
-::: {#fig:5 .figure}
-![5](fig5.png)
-
-::: caption
-Figure 5: 5
-:::
-:::
+![Figure 1: 1](fig1.png){#fig:1}
 
-::: {#fig:6 .figure}
-![6](fig6.png)
+![Figure 2: 2](fig2.png){#fig:2}
 
-::: caption
-Figure 6: 6
-:::
-:::
+![Figure 3: 3](fig3.png){#fig:3}
 
-::: {#fig:7 .figure}
-![7](fig7.png)
+![Figure 4: 4](fig4.png){#fig:4}
 
-::: caption
-Figure 7: 7
-:::
-:::
+![Figure 5: 5](fig5.png){#fig:5}
 
-::: {#fig:8 .figure}
-![8](fig8.png)
+![Figure 6: 6](fig6.png){#fig:6}
 
-::: caption
-Figure 8: 8
-:::
-:::
+![Figure 7: 7](fig7.png){#fig:7}
 
-::: {#fig:9 .figure}
-![9](fig9.png)
+![Figure 8: 8](fig8.png){#fig:8}
 
-::: caption
-Figure 9: 9
-:::
-:::
+![Figure 9: 9](fig9.png){#fig:9}
 
 ::: {#lst:code1 .listing .haskell}
 Listing 1: Listing caption 1
diff --git a/test/m2m/loxItemTitle/expect.md b/test/m2m/loxItemTitle/expect.md
--- a/test/m2m/loxItemTitle/expect.md
+++ b/test/m2m/loxItemTitle/expect.md
@@ -1,74 +1,20 @@
-::: {#fig:1 .figure}
-![1](fig1.png)
-
-::: caption
-Figure 1: 1
-:::
-:::
-
-::: {#fig:2 .figure}
-![2](fig2.png)
-
-::: caption
-Figure 2: 2
-:::
-:::
-
-::: {#fig:3 .figure}
-![3](fig3.png)
-
-::: caption
-Figure 3: 3
-:::
-:::
-
-::: {#fig:4 .figure}
-![4](fig4.png)
-
-::: caption
-Figure 4: 4
-:::
-:::
-
-::: {#fig:5 .figure}
-![5](fig5.png)
-
-::: caption
-Figure 5: 5
-:::
-:::
+![Figure 1: 1](fig1.png){#fig:1}
 
-::: {#fig:6 .figure}
-![6](fig6.png)
+![Figure 2: 2](fig2.png){#fig:2}
 
-::: caption
-Figure 6: 6
-:::
-:::
+![Figure 3: 3](fig3.png){#fig:3}
 
-::: {#fig:7 .figure}
-![7](fig7.png)
+![Figure 4: 4](fig4.png){#fig:4}
 
-::: caption
-Figure 7: 7
-:::
-:::
+![Figure 5: 5](fig5.png){#fig:5}
 
-::: {#fig:8 .figure}
-![8](fig8.png)
+![Figure 6: 6](fig6.png){#fig:6}
 
-::: caption
-Figure 8: 8
-:::
-:::
+![Figure 7: 7](fig7.png){#fig:7}
 
-::: {#fig:9 .figure}
-![9](fig9.png)
+![Figure 8: 8](fig8.png){#fig:8}
 
-::: caption
-Figure 9: 9
-:::
-:::
+![Figure 9: 9](fig9.png){#fig:9}
 
 ::: {#lst:code1 .listing .haskell}
 Listing 1: Listing caption 1
diff --git a/test/m2m/numberOverride/expect.md b/test/m2m/numberOverride/expect.md
--- a/test/m2m/numberOverride/expect.md
+++ b/test/m2m/numberOverride/expect.md
@@ -2,62 +2,22 @@
 
 ## 1.1 Earlier Subsection
 
-::: {#fig:img1 .figure}
-![Image 1](img2.png)
-
-::: caption
-Figure 1.1.1: Image 1
-:::
-:::
+![Figure 1.1.1: Image 1](img2.png){#fig:img1}
 
 ## 1.6 Title of Subsection {#title-of-subsection number="6"}
 
-::: {#fig:img2 .figure}
-![Image 1.6.2](img2.png)
-
-::: caption
-Figure 1.6.1: Image 1.6.2
-:::
-:::
-
-::: {#fig:img3 .figure}
-![Image 1.6.100500](img2.png){number="100500"}
-
-::: caption
-Figure 1.6.100500: Image 1.6.100500
-:::
-:::
+![Figure 1.6.1: Image 1.6.2](img2.png){#fig:img2}
 
-::: {#fig:img4 .figure}
-![Image 1.6.100501](img2.png)
+![Figure 1.6.100500: Image 1.6.100500](img2.png){#fig:img3
+number="100500"}
 
-::: caption
-Figure 1.6.100501: Image 1.6.100501
-:::
-:::
+![Figure 1.6.100501: Image 1.6.100501](img2.png){#fig:img4}
 
 ## 1.7 Title of Subsection
 
-::: {#fig:img21 .figure}
-![Image 1.7.1](img2.png)
-
-::: caption
-Figure 1.7.1: Image 1.7.1
-:::
-:::
-
-::: {#fig:img31 .figure}
-![Image 1.7.100500](img2.png){number="100500"}
-
-::: caption
-Figure 1.7.100500: Image 1.7.100500
-:::
-:::
+![Figure 1.7.1: Image 1.7.1](img2.png){#fig:img21}
 
-::: {#fig:img41 .figure}
-![Image 1.7.100501](img2.png)
+![Figure 1.7.100500: Image 1.7.100500](img2.png){#fig:img31
+number="100500"}
 
-::: caption
-Figure 1.7.100501: Image 1.7.100501
-:::
-:::
+![Figure 1.7.100501: Image 1.7.100501](img2.png){#fig:img41}
diff --git a/test/m2m/secLabels/expect.md b/test/m2m/secLabels/expect.md
--- a/test/m2m/secLabels/expect.md
+++ b/test/m2m/secLabels/expect.md
@@ -2,13 +2,7 @@
 
 ## a.a Second Level Section {#second-level-section}
 
-::: {#fig:myfig .figure}
-![my figure](myfig.png)
-
-::: caption
-Figure a: my figure
-:::
-:::
+![Figure a: my figure](myfig.png){#fig:myfig}
 
 ## a.b Other Second Level Section {#other-second-level-section}
 
diff --git a/test/m2m/setLabelAttribute/expect.md b/test/m2m/setLabelAttribute/expect.md
--- a/test/m2m/setLabelAttribute/expect.md
+++ b/test/m2m/setLabelAttribute/expect.md
@@ -1,12 +1,12 @@
 # Section {#section label="1"}
 
-::: {#fig:1 .figure label="1.1"}
-![Figure](./image.png)
+:::: {#fig:1 .figure label="1.1"}
+![Figure 1.1: Figure](./image.png)
 
 ::: caption
 Figure 1.1: Figure
 :::
-:::
+::::
 
 [$$equation\qquad{(1.1)}$$]{#eq:1 label="(1.1)"}
 
diff --git a/test/m2m/subfigures-ccsDelim/expect.md b/test/m2m/subfigures-ccsDelim/expect.md
--- a/test/m2m/subfigures-ccsDelim/expect.md
+++ b/test/m2m/subfigures-ccsDelim/expect.md
@@ -1,6 +1,6 @@
 You can define subfigures:
 
-::: {#fig:subfigures .figure .subfigures}
+:::: {#fig:subfigures .figure .subfigures}
 ![a](fig1.png){#fig:subfig1} ![b](fig2.png){#fig:subfig2} ![c](fig3.png)
 
 ![d](fig4.png){#fig:subfig4} ![e](fig5.png) ![f](fig6.png){#fig:subfig6}
@@ -11,86 +11,32 @@
 Figure 1: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---
 6; g --- 7; h --- 8; i --- 9
 :::
-:::
-
-::: {#fig:subfigures2 .figure .subfigures}
-::: {#fig:subfig21 .figure}
-![1](fig1.png)
-
-::: caption
-a
-:::
-:::
-
-::: {#fig:subfig22 .figure}
-![2](fig2.png)
-
-::: caption
-b
-:::
-:::
-
-::: figure
-![3](fig3.png)
-
-::: caption
-c
-:::
-:::
-
-::: {#fig:subfig24 .figure}
-![4](fig4.png)
-
-::: caption
-d
-:::
-:::
-
-::: figure
-![5](fig5.png)
+::::
 
-::: caption
-e
-:::
-:::
+:::: {#fig:subfigures2 .figure .subfigures}
+![a](fig1.png){#fig:subfig21}
 
-::: {#fig:subfig26 .figure}
-![6](fig6.png)
+![b](fig2.png){#fig:subfig22}
 
-::: caption
-f
-:::
-:::
+![c](fig3.png)
 
-::: {#fig:subfig27 .figure}
-![7](fig7.png)
+![d](fig4.png){#fig:subfig24}
 
-::: caption
-g
-:::
-:::
+![e](fig5.png)
 
-::: figure
-![8](fig8.png)
+![f](fig6.png){#fig:subfig26}
 
-::: caption
-h
-:::
-:::
+![g](fig7.png){#fig:subfig27}
 
-::: {#fig:subfig29 .figure}
-![9](fig9.png)
+![h](fig8.png)
 
-::: caption
-i
-:::
-:::
+![i](fig9.png){#fig:subfig29}
 
 ::: caption
 Figure 2: Caption. a --- 1; b --- 2; c --- 3; d --- 4; e --- 5; f ---
 6; g --- 7; h --- 8; i --- 9
 :::
-:::
+::::
 
 Figures themselves can be referenced fig. 2, as well as individual
 subfigures: figs. 1 (a), 1 (b), 2 (i)
diff --git a/test/m2m/subfigures-grid/expect.md b/test/m2m/subfigures-grid/expect.md
--- a/test/m2m/subfigures-grid/expect.md
+++ b/test/m2m/subfigures-grid/expect.md
@@ -1,124 +1,70 @@
 You can define subfigures:
 
-::: {#fig:subfigures .figure .subfigures}
+:::: {#fig:subfigures .figure .subfigures}
 +:------------------:+:------------------:+:------------------:+
-| ::: {#fi           | ::: {#fi           | ::: figure         |
+| :::: {#fi          | :::: {#fi          | :::: figure        |
 | g:subfig1 .figure} | g:subfig2 .figure} | ![c](fig3.         |
 | ![a](fig1.         | ![b](fig2.         | png){width="100%"} |
 | png){width="100%"} | png){width="100%"} |                    |
 |                    |                    | ::: caption        |
 | ::: caption        | ::: caption        | c                  |
 | a                  | b                  | :::                |
-| :::                | :::                | :::                |
-| :::                | :::                |                    |
+| :::                | :::                | ::::               |
+| ::::               | ::::               |                    |
 +--------------------+--------------------+--------------------+
-| ::: {#fi           | ::: figure         | ::: {#fi           |
+| :::: {#fi          | :::: figure        | :::: {#fi          |
 | g:subfig4 .figure} | ![e](fig5.         | g:subfig6 .figure} |
 | ![d](fig4.         | png){width="100%"} | ![f](fig6.         |
 | png){width="100%"} |                    | png){width="100%"} |
 |                    | ::: caption        |                    |
 | ::: caption        | e                  | ::: caption        |
 | d                  | :::                | f                  |
-| :::                | :::                | :::                |
-| :::                |                    | :::                |
+| :::                | ::::               | :::                |
+| ::::               |                    | ::::               |
 +--------------------+--------------------+--------------------+
-| ::: {#fi           | ::: figure         | ::: {#fi           |
+| :::: {#fi          | :::: figure        | :::: {#fi          |
 | g:subfig7 .figure} | ![h](fig8.         | g:subfig9 .figure} |
 | ![g](fig7.         | png){width="100%"} | ![i](fig9.         |
 | png){width="100%"} |                    | png){width="100%"} |
 |                    | ::: caption        |                    |
 | ::: caption        | h                  | ::: caption        |
 | g                  | :::                | i                  |
-| :::                | :::                | :::                |
-| :::                |                    | :::                |
+| :::                | ::::               | :::                |
+| ::::               |                    | ::::               |
 +--------------------+--------------------+--------------------+
 
 ::: caption
 Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
 g --- 7, h --- 8, i --- 9
 :::
-:::
+::::
 
-::: {#fig:subfigures2 .figure .subfigures}
+:::: {#fig:subfigures2 .figure .subfigures}
 +:--------------------------------------------------------------------:+
-| ::: {#fig:subfig21 .figure}                                          |
-| ![1](fig1.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| a                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![a](fig1.png){#fig:subfig21}                                        |
 +----------------------------------------------------------------------+
-| ::: {#fig:subfig22 .figure}                                          |
-| ![2](fig2.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| b                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![b](fig2.png){#fig:subfig22}                                        |
 +----------------------------------------------------------------------+
-| ::: figure                                                           |
-| ![3](fig3.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| c                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![c](fig3.png)                                                       |
 +----------------------------------------------------------------------+
-| ::: {#fig:subfig24 .figure}                                          |
-| ![4](fig4.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| d                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![d](fig4.png){#fig:subfig24}                                        |
 +----------------------------------------------------------------------+
-| ::: figure                                                           |
-| ![5](fig5.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| e                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![e](fig5.png)                                                       |
 +----------------------------------------------------------------------+
-| ::: {#fig:subfig26 .figure}                                          |
-| ![6](fig6.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| f                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![f](fig6.png){#fig:subfig26}                                        |
 +----------------------------------------------------------------------+
-| ::: {#fig:subfig27 .figure}                                          |
-| ![7](fig7.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| g                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![g](fig7.png){#fig:subfig27}                                        |
 +----------------------------------------------------------------------+
-| ::: figure                                                           |
-| ![8](fig8.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| h                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![h](fig8.png)                                                       |
 +----------------------------------------------------------------------+
-| ::: {#fig:subfig29 .figure}                                          |
-| ![9](fig9.png)                                                       |
-|                                                                      |
-| ::: caption                                                          |
-| i                                                                    |
-| :::                                                                  |
-| :::                                                                  |
+| ![i](fig9.png){#fig:subfig29}                                        |
 +----------------------------------------------------------------------+
 
 ::: caption
 Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
 g --- 7, h --- 8, i --- 9
 :::
-:::
+::::
 
 Figures themselves can be referenced fig. 2, as well as individual
 subfigures: figs. 1 (a), 1 (b), 2 (i)
diff --git a/test/m2m/subfigures-one-row/expect.md b/test/m2m/subfigures-one-row/expect.md
--- a/test/m2m/subfigures-one-row/expect.md
+++ b/test/m2m/subfigures-one-row/expect.md
@@ -3,7 +3,7 @@
 Regression test for
 [#381](https://github.com/lierdakil/pandoc-crossref/issues/381)
 
-::: {#fig:latex .figure .subfigures}
+:::: {#fig:latex .figure .subfigures}
 ![a](/tmp/LaTeX_logo.svg.png){#fig:logo1 width="40%"}
 ![b](/tmp/LaTeX_logo.svg.png){#fig:logo2 width="40%"}
 
@@ -11,6 +11,6 @@
 Figure 1: Copies of the LaTeX logo. a --- cool caption, b --- cooler
 caption
 :::
-:::
+::::
 
 Those logos are different I swear. Especially fig. 1 (a) and fig. 1 (b).
diff --git a/test/m2m/subfigures/expect.md b/test/m2m/subfigures/expect.md
--- a/test/m2m/subfigures/expect.md
+++ b/test/m2m/subfigures/expect.md
@@ -1,6 +1,6 @@
 You can define subfigures:
 
-::: {#fig:subfigures .figure .subfigures}
+:::: {#fig:subfigures .figure .subfigures}
 ![a](fig1.png){#fig:subfig1} ![b](fig2.png){#fig:subfig2} ![c](fig3.png)
 
 ![d](fig4.png){#fig:subfig4} ![e](fig5.png) ![f](fig6.png){#fig:subfig6}
@@ -11,86 +11,32 @@
 Figure 1: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
 g --- 7, h --- 8, i --- 9
 :::
-:::
-
-::: {#fig:subfigures2 .figure .subfigures}
-::: {#fig:subfig21 .figure}
-![1](fig1.png)
-
-::: caption
-a
-:::
-:::
-
-::: {#fig:subfig22 .figure}
-![2](fig2.png)
-
-::: caption
-b
-:::
-:::
-
-::: figure
-![3](fig3.png)
-
-::: caption
-c
-:::
-:::
-
-::: {#fig:subfig24 .figure}
-![4](fig4.png)
-
-::: caption
-d
-:::
-:::
-
-::: figure
-![5](fig5.png)
+::::
 
-::: caption
-e
-:::
-:::
+:::: {#fig:subfigures2 .figure .subfigures}
+![a](fig1.png){#fig:subfig21}
 
-::: {#fig:subfig26 .figure}
-![6](fig6.png)
+![b](fig2.png){#fig:subfig22}
 
-::: caption
-f
-:::
-:::
+![c](fig3.png)
 
-::: {#fig:subfig27 .figure}
-![7](fig7.png)
+![d](fig4.png){#fig:subfig24}
 
-::: caption
-g
-:::
-:::
+![e](fig5.png)
 
-::: figure
-![8](fig8.png)
+![f](fig6.png){#fig:subfig26}
 
-::: caption
-h
-:::
-:::
+![g](fig7.png){#fig:subfig27}
 
-::: {#fig:subfig29 .figure}
-![9](fig9.png)
+![h](fig8.png)
 
-::: caption
-i
-:::
-:::
+![i](fig9.png){#fig:subfig29}
 
 ::: caption
 Figure 2: Caption. a --- 1, b --- 2, c --- 3, d --- 4, e --- 5, f --- 6,
 g --- 7, h --- 8, i --- 9
 :::
-:::
+::::
 
 Figures themselves can be referenced fig. 2, as well as individual
 subfigures: figs. 1 (a), 1 (b), 2 (i)
diff --git a/test/m2m/titlesInRefs/expect.md b/test/m2m/titlesInRefs/expect.md
--- a/test/m2m/titlesInRefs/expect.md
+++ b/test/m2m/titlesInRefs/expect.md
@@ -1,12 +1,6 @@
 # Section {#sec:section}
 
-::: {#fig:figure .figure}
-![A Figure](figure.png)
-
-::: caption
-Figure 1: A Figure
-:::
-:::
+![Figure 1: A Figure](figure.png){#fig:figure}
 
 sec. 1 (Section)
 
diff --git a/test/test-pandoc-crossref.hs b/test/test-pandoc-crossref.hs
--- a/test/test-pandoc-crossref.hs
+++ b/test/test-pandoc-crossref.hs
@@ -90,7 +90,7 @@
     describe "References.Blocks.replaceBlocks" $ do
       it "Labels images" $
         testAll (figure "test.jpg" "" "Test figure" Nothing "figure")
-        (figure "test.jpg" "" "Figure 1: Test figure" (Just "Test figure") "figure",
+        (figure "test.jpg" "" "Figure 1: Test figure" (Just "Figure 1: Test figure") "figure",
           PfxImg =: M.fromList $ refRec' "fig:figure" 1 "Test figure")
       it "Labels subfigures" $
         testAll (
@@ -319,7 +319,7 @@
           table' "A table" "some_table1"
             <> para (citeGen "tbl:some_table" [1])
             `test` concat (
-              [ "\\begin{longtable}[]{@{}@{}}\n"
+              [ "\\begin{longtable}[]{@{}l@{}}\n"
               , "\\caption{\\label{tbl:some_table1}A table}\\tabularnewline\n"
               , "\\toprule\\noalign{}\n"
               , "\\endfirsthead\n"
