在「\makenote」中,如何讓「\captionof」著色?

在「\makenote」中,如何讓「\captionof」著色?

我可以讓我的\captionofs 變成藍色。
我可以讓我的\makenotes 變成藍色。
但似乎無論我如何嘗試,我永遠無法讓\captionofs 裡面的\makenotes 變成藍色。

例子

\documentclass[]{scrbook}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{caption}%
\captionsetup{compatibility=false}%

\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn} %must be loaded ``Lastest''
\RedeclareNoteColumn[font = \color{blue}]{marginpar} %default

\DeclareCaptionFont{bluecaptionfont}{\color{blue}}
\captionsetup{font={bluecaptionfont}, labelfont=bluecaptionfont}

\begin{document}

    here is the main text
    \makenote*{
        \includegraphics[width=3cm]{example-grid-100x100pt}
        \captionof{figure}{This should be blue}
    }

    \begin{minipage}{0.5\textwidth}
        \includegraphics[width=8cm]{example-grid-100x100pt}
        \captionof{figure}{Normal captionof's are blue}
    \end{minipage}

    \makenote*{
        Normal notes are blue
    }
\end{document}

遠親關係:如何將 vspace 插入 scrlayer-notecolumn marginnote?

輸出

輸出文檔的螢幕截圖

答案1

scrlayer-notecolumnv0.2.3085 起SourceForge 上的 KOMA-Script 原始碼儲存庫已經支援 LuaLaTeX 或 PDFLaTeX 註解欄中的顏色(但不支援 XeLaTeX)。因此,問題中的範例結果如下:

scrlayer-notecolumn v0.2.3085 的結果

答案2

\makenote*重新定義\color為不執行任何操作,因此標題的內部程式碼無法變更顏色。您可以使用另一個命令,但請注意,這\makenote*可能有重新定義的原因:藍色很可能會洩漏。

\documentclass[]{scrbook}
\usepackage{graphicx}
\usepackage{xcolor}

\usepackage{caption}%
\captionsetup{compatibility=false}%

\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn} %must be loaded ``Lastest''
\RedeclareNoteColumn[font = \color{blue}]{marginpar} %default

\let\mycolorcommand\color
\DeclareCaptionFont{bluecaptionfont}{\mycolorcommand{blue}}
\captionsetup{font={bluecaptionfont}, labelfont=bluecaptionfont}

\begin{document}

    here is the main text
    \makenote*{ 
        \includegraphics[width=3cm]{example-grid-100x100pt}
        \captionof{figure}{This should be blue}
    }

    \begin{minipage}{0.5\textwidth}
        \includegraphics[width=8cm]{example-grid-100x100pt}
        \tracingmacros=1 \captionof{figure}{Normal captionof's are blue}
    \end{minipage}

    \makenote*{
        Normal notes are blue
    }
\end{document}

也許更安全的替代方案是在本地重新定義\normalcolor.那麼標題無法重置顏色並且註釋中的顏色獲勝:

\makenote*{ 
    \includegraphics[width=3cm]{example-grid-100x100pt}
    \let\normalcolor\relax
    \captionof{figure}{This should be blue}
}

在此輸入影像描述

相關內容