Я использую Quarto и рендеринг в PDF. У меня есть цифры с подцифрами. Подрисуночные подписи длинные (много слов). Проблема в том, что подписи подрисунков не разделены в PDF. Вот иллюстрация проблемы; обратите внимание, что между подписями подрисунков нет разделения (пробелов):
Я пытался использовать команды LaTeX, такие как \captionsetup{width=0.9\textwidth}, но это влияет только на основную подпись под обоими подрисунками и не влияет на подписи подрисунков.
Ниже я привожу полное содержание минимального примера.
---
title: "Test of long captions in two sub-figures"
format:
pdf:
documentclass: article
papersize: letter
geometry:
- top=1.75in
- bottom=1.75in
- left=1.75in
- right=1.75in
html:
theme: default
---
\captionsetup{width=0.9\textwidth}
```{r include=FALSE, echo=FALSE, message=FALSE}
# Make dummy image
png("DummyFigure.png")
plot( c(0,1) , c(0,10) , xlim=c(0,1) , ylim=c(0,10) , type = "b" )
dev.off()
```
::: {#fig-TheFigure layout-nrow = "1" layout-ncol = "2"}
{#fig-panelA width = "200px"}
{#fig-panelB width = "200px"}
**Here is the main caption below both subfigures.** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
:::
**This is the main document text. @fig-TheFigure shows two subfigures with long captions, and an overall captions beneath them. *I want the subfigure captions to be separated, not bumping into each other as they are here.* As one attempt, before the figure I inserted inline \LaTeX\ code: `\captionsetup{width=0.9\textwidth}`. Notice that the main caption has the reduced width, but not the subfigure captions.** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


После обширных поисков и погони за кроличьими норами я нашел это как одно из решений. Вместо
::: {#fig-TheFigure layout-ncol = "2"}
использовать
::: {#fig-TheFigure layout = "[10,-1,10]"}
Отрицательное число указывает на пробел между фигурами. Хм.
Если есть другое решение, мне интересно узнать о нем.
Вы можете использовать команду \captionsetup вместо subfigure для управления субтитрами. Вы можете использовать \captionsetup[subfigure]{margin=15pt} или \captionsetup[subfigure]{width=0.8\textwidth}, чтобы настроить поля между субтитрами.
---
title: "Test of long captions in two sub-figures"
format:
pdf:
documentclass: article
papersize: letter
geometry:
- top=1.75in
- bottom=1.75in
- left=1.75in
- right=1.75in
include-before-body:
text: |
\captionsetup[subfigure]{margin=15pt}
html:
theme: default
---
```{r include=FALSE, echo=FALSE, message=FALSE}
# Make dummy image
png("DummyFigure.png")
plot( c(0,1) , c(0,10) , xlim=c(0,1) , ylim=c(0,10) , type = "b" )
dev.off()
```
::: {#fig-TheFigure layout-ncol=2}
{#fig-panelA width = "200px"}
{#fig-panelB width = "200px"}
**Here is the main caption below both subfigures.** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
:::
**This is the main document text. @fig-TheFigure shows two subfigures with long captions, and an overall captions beneath them. *I want the subfigure captions to be separated, not bumping into each other as they are here.* As one attempt, before the figure I inserted inline \LaTeX\ code: `\captionsetup{width=0.9\textwidth}`. Notice that the main caption has the reduced width, but not the subfigure captions.** Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@ JohnK.Kruschke Да, \captionsetup - это решение только для латекса. Для HTML я бы попробовал с CSS
Для моих целей, подчеркивающих гибкость вывода PDF, мне нравится решение \captionsetup. Я «приму» этот ответ. Если кто-то еще захочет предложить альтернативу CSS, которая делает то же самое для HTML и PDF, это было бы здорово. В любом случае, @shafee: Спасибо!
Приятно видеть это решение с использованием
\captionsetup[subfigure]! Приятно, что это глобальное решение, затрагивающее весь документ. Но это влияет только на (LateX-ed) вывод PDF, а не на вывод HTML. Решениеlayout = "[10,-1,10]"влияет как на PDF, так и на HTML, но должно быть указано локально на каждом рисунке. Такжеlayoutне влияет на размер полей или шрифта. Если оба используются вместе, PDF-файл получает дополнительное пространство за счет макета и уменьшенных полей. Компромиссы!