A couple of things:

The trailing backslash has to be followed by a space character, i.e. `\<space><newline>` which will give you a no-break space at the end of the paragraph, which is distinct from `\<newline>` which will give you a soft line break. In Vim you can say `:let b:backslash_space_hl=matchadd('Search','\\ \?$')` to make them more visible and distinguishable in the current window. You might want to add that to `~/.vim/after/ftplugin/markdown.vim`. Other editors may or may not offer anything similar.

The trick John mentions to style a paragraph with an image without a caption as Figure in DOCX output merits some explanation. It should look like this:

``````markdown
:::{custom-style=Figure}
![](path/to/image.ext)\<space>
:::
``````

where the lines with backticks are not part of the syntax and `<space>` is a literal space character.

HTH,

/bpj

Den lör 10 juli 2021 05:16John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> skrev:

Sorry, it won't actually work for an image.

Does the style need to be on the image, though, or on the
paragraph containing it? In the latter case using a fenced
div with custom-style attribute might work.

There is documentation in the manual under --reference-doc
that tells you which styles pandoc uses (thus, which ones
you can modify in the reference.docx).

If you want to add other styles to the reference.docx,
you'll need to use custom-style explicitly to access them.


John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes:

> As I understand it, you want an inline image and you also want it
> to have a special style, "Image".
>
> Have you looked in the manual under "custom styles"?
>
> You should be able to do
>
> ![my alt text](img.jpg){custom-style="Image"}\
>
>
>
> Andrew Voelkel <jandyman.voelkel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
>
>> As far as I could tell, the trailing backslash solution didn’t seem to work. I had created a Figure style in my docx template, and yet the figure seemed to be the Normal style in the generated document
>>
>> So on a related note, and since most of my issues with Pandoc seem to be related either understanding the mapping between Markdown and the docx styles, two questions:
>>
>> Is there documentation anywhere that describes how markdown is mapped to docx styles?
>> Is there a way to “debug” this? It seems that if the docx files that Pandoc creates reference a style that doesn’t exist in the template, then that style defaults to Normal when you open it in Word. So is there any way or any output I could look at that tells me what Pandoc is “trying” to do?
>>
>> Pandoc seems to be a fantastic tool, I’m grateful for it and it looks like it will solve a problem I have no other solution for. The biggest stumbling block seems to be this docx style mapping. I wish I could avoid needing docx output, but in this situation I cannot.
>>
>> - Andy
>>
>>> On Jul 9, 2021, at 11:45 AM, John MacFarlane <jgm@berkeley.edu> wrote:
>>>
>>>
>>> If you just want an inline image, then you need to make sure it's
>>> not by itself in the paragraph (that triggers implicit_figures).
>>> You can, as the manual suggests, follow it with a nonbreaking
>>> space or something.
>>>
>>> Andrew Voelkel <jandyman.voelkel@gmail.com> writes:
>>>
>>>> UPDATE: I discovered that I can get a centered image caption by creating an
>>>> Image Caption style in the docx template. That's a big relief. But I'd
>>>> still like to know how to get an uncaptioned image which emits the image
>>>> into the docx with the Image style instead of the Normal style.
>>>> On Thursday, July 8, 2021 at 2:27:56 PM UTC-7 Andrew Voelkel wrote:
>>>>
>>>>> Pandoc newbie here. Very pleased with what I'm seeing for plain text
>>>>> documents, including docx output using the reference-doc feature. I've also
>>>>> succeeded in getting a figure in the docx output with a caption:
>>>>>
>>>>> ![caption](SystemDrawings.png){width=500px}
>>>>>
>>>>> It's problematic though since if I want a caption I want it centered like
>>>>> the figure (I modified the Captioned Figure style to center, but that
>>>>> doesn't center the actual caption, just the figure. It's a shame).
>>>>>
>>>>> So OK, I tried skipping the captions. I figured this would create a figure
>>>>> with style Figure, but it doesn't, it seems to create the figure with style
>>>>> Normal. Feels like I can't get there from here, but this seems like such
>>>>> and obvious and normal thing to do that it surprises me. I've tried the
>>>>> following, but neither works, they both create a figure with style Normal.
>>>>>
>>>>> ![](SystemDrawings.png){width=500px}
>>>>> ![caption](SystemDrawings.png){width=500px} \
>>>>>
>>>>> Is there any way to solve this issue?
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b8286c97-446d-48d0-9fd9-f095ef9168c4n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m2y2aesvue.fsf%40MacBook-Pro-2.hsd1.ca.comcast.net.

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCRfXYXZUUDSFpD2k%3DmZNDHj-Pj0O7ozf0Sz6ctKHNQdg%40mail.gmail.com.