如何将 vspaces 插入到 scrlayer-notecolumn marginnote 中?

如何将 vspaces 插入到 scrlayer-notecolumn marginnote 中?

目前我正在写一本包含大量图片的书。至于字幕,我用 模拟了tufe-latex的侧字幕功能scrlayer-notecolumn。问题是全宽图的字幕垂直对齐不齐。它们可能与图的内容重叠(参见编译的 MWE)。

至于典型的建议:

  • 无法切换到tufte-book课程或类似内容,因为它与我为我的书所做的许多其他配置相冲突。
  • 我的目的是保留原有的代码,仅更改/重新定义命令,因为我不想将所有\caption命令转换为可能的替代方案,例如\sidecaption

所以我的问题是,是否可以在 scrlayer-notecolumn 中的注释中插入一些垂直空间,以将标题放在图像下方。

梅威瑟:

\documentclass[twoside=semi,DIV=calc,BCOR=15mm,blocks]{scrartcl}
\usepackage{scrlayer-notecolumn,xparse,etoolbox} % for implementation
\usepackage[strict]{changepage} % for implementation
\usepackage{blindtext,graphicx} % for demonstration

% scrlayer-notecolumn for twoside=semi
\RedeclareNoteColumn[position=\oddsidemargin+1in+\textwidth+\marginparsep,width=\marginparwidth,font=\footnotesize]{marginpar}
% write something into margin (better marginpar)
\DeclareDocumentCommand{\xmarginnote}{O{0pt} +m}{%
    \makenote[marginpar]{\hbox{}\vspace*{#1}\setlength{\parindent}{0.5pc}\setlength{\parskip}{0pt}\noindent #2}%
}
% make env* ``fullwidth'' (tufte-like)
\AtEndPreamble{%
    \DeclareDocumentEnvironment{figure*}{o}{\begin{figure}[#1]\begin{adjustwidth}{}{-\dimexpr\marginparwidth+\marginparsep}}
        {\end{adjustwidth}\end{figure}}
    \DeclareDocumentEnvironment{table*}{o}{\begin{table}[#1]\begin{adjustwidth}{}{-\dimexpr\marginparwidth+\marginparsep}}
        {\end{adjustwidth}\end{table}}
}%

% redefine captions to fit into margin
\usepackage{caption}%
\usepackage{subcaption}%
\captionsetup{compatibility=false}%
\DeclareCaptionFormat{sidenote}{\protect\xmarginnote{#1#2#3}}%
\DeclareCaptionFormat{sidenotebelow}{\protect\xmarginnote[\baselineskip]{#1#2#3}}%  the critical point
\DeclareCaptionStyle{sidecap}{parskip=0pt,skip=0pt,position=below,labelfont={footnotesize,bf},font=footnotesize,%
    singlelinecheck=off}%
\DeclareCaptionStyle{subsidecap}{format=plain,parskip=0pt,skip=0pt,position=below,labelfont={scriptsize,bf},labelformat=parens,labelsep=space,%
    font=scriptsize,justification=centering,singlelinecheck=off}%
\captionsetup[figure]{style=sidecap,format=sidenote}\captionsetup[table]{style=sidecap,format=sidenote}%
\captionsetup[figure*]{style=sidecap,format=sidenotebelow,skip=2\baselineskip}\captionsetup[table*]{style=sidecap,format=sidenote,skip=2\baselineskip}%
\captionsetup[sub]{style=subsidecap}%

\begin{document}
  This is the text with a \xmarginnote{See here.}.
  \begin{figure}[h]
    \centering
    \includegraphics[width=.5\textwidth]{example-image-A.pdf}
    \caption{Caption is working fine}
  \end{figure}
  \begin{figure}[h]
    \centering
    \begin{subfigure}{.475\textwidth}
        \includegraphics[width=\textwidth]{example-image-A.pdf}
        \caption{Subcaption great}
    \end{subfigure}\hfill
    \begin{subfigure}{.475\textwidth}
        \includegraphics[width=\textwidth]{example-image-B.pdf}
        \caption{Subcaption great}
    \end{subfigure}
    \caption{Caption is working fine}
  \end{figure}
  \begin{figure*}[h]
    \raggedleft
    \includegraphics[width=.5\textwidth]{example-image-A.pdf}
    \caption{Caption is not working}
  \end{figure*}
  \begin{figure*}[h]
    \centering
    \begin{subfigure}{.35\paperwidth}
        \includegraphics[width=\textwidth]{example-image-A.pdf}
        \caption{Even a long subcaption is great}
    \end{subfigure}\hfill
    \begin{subfigure}{.35\paperwidth}
        \includegraphics[width=\textwidth]{example-image-B.pdf}
        \caption{Even a long subcaption is (nearly) great}
    \end{subfigure}
    \caption{Caption is not working}
  \end{figure*}
\end{document}

答案1

使用\vskip而不是\vspace*

\DeclareDocumentCommand{\xmarginnote}{O{0pt} +m}{%
    \makenote[marginpar]{\vskip #1 \setlength{\parindent}{0.5pc}\setlength{\parskip}{0pt}\noindent #2}%
}

结果是:

在此处输入图片描述

或者\par在之后添加\vspace*{…}

相关内容