(하위)레이블에 대한 사용자 정의 참조 텍스트(하위 그림과 같은 tcolorbox의 경우)

(하위)레이블에 대한 사용자 정의 참조 텍스트(하위 그림과 같은 tcolorbox의 경우)

이유로부동 소수점은 tcolorbox에 중첩될 수 없습니다.그리고 나는 내 (하위)그림을 더 멋지게 만들고 싶었고 새롭고 새로운 colorbox 환경을 코딩 Figure했습니다 Subfigure. 내 코드의 단순화된 버전은 다음과 같습니다.

\documentclass[12pt,a4paper]{book}
\usepackage{lipsum}
\usepackage[skins, breakable]{tcolorbox}


\newcommand{\figref}[1]{Figure \ref{fig:#1}}

\newtcolorbox[auto counter]{Figure}[1]{
    title = {Figure~\thetcbcounter~$-$ #1}
    }
    
\newtcolorbox[
        auto counter,
        number within=tcb@cnt@Figure,
        number freestyle = {(\noexpand\alph{\tcbcounter})}
        ]
        {Subfigure}[3][]{
    width = (\linewidth - 4\dimexpr (#2pt - 1pt)\relax)/#2,
    before =,
    after = \hfill,
    box align = center,
    title = {\thetcbcounter~#3},
    #1
    }


\begin{document}

\begin{Figure}
    {Title figure}
    \begin{Subfigure}[label={fig:a}]{2}
        {Title again}
        \lipsum[1]
    \end{Subfigure}%
    %
    \begin{Subfigure}{2}
        {A nice Subfigure}
        \lipsum[2]
    \end{Subfigure}
\end{Figure}


See \figref{a}.

\end{document}

출력과 함께

MWE

결과는 마음에 들지만 하위 그림의 제목을 변경하지 않고 대신 Figure 1a텍스트 를 인쇄하고 싶습니다 . 보다 정확하게는 newtcolorbox의 인수를 내 하위 그림의 카운터로 Figure (a)변경할 수 있지만 이로 인해 내가 원하지 않는 제목이 변경됩니다.number freestyle1a(a) blabla1a blabla

hyperref최소 작업 예제에서 패키지를 제거한 경우에도 패키지를 사용합니다 .

나는 알고있다비슷한 질문질문을 받았지만 무엇을 이해하지 못하기 때문에 내 질문과 얼마나 가까운지 모르겠습니다.

\makeatletter
\newcommand{\customlabel}[2]{%
\protected@write \@auxout {}{\string \newlabel {#1}{{#2}{}}}}
\makeatother

하고있다...

답변1

다음을 사용하여 라벨 형식을 변경할 수 있습니다 \labelformat(참조:ltnews30.pdf자세한 내용은):

\documentclass[12pt,a4paper]{book}
\usepackage{lipsum}
\usepackage[skins, breakable]{tcolorbox}


\newcommand{\figref}[1]{Figure \ref{fig:#1}}

\newtcolorbox[auto counter]{Figure}[1]{
    title = {Figure~\thetcbcounter~$-$ #1}
    }
    
\newtcolorbox[
        auto counter,
        number within=tcb@cnt@Figure,
        number freestyle = {(\noexpand\alph{\tcbcounter})}
        ]
        {Subfigure}[3][]{
    width = (\linewidth - 4\dimexpr (#2pt - 1pt)\relax)/#2,
    before =,
    after = \hfill,
    box align = center,
    title = {\thetcbcounter~#3},
    #1
    }

\labelformat{tcb@cnt@Subfigure}{\arabic{tcb@cnt@Figure}\alph{tcb@cnt@Subfigure}}

\begin{document}

\begin{Figure}
    {Title figure}
    \begin{Subfigure}[label={fig:a}]{2}
        {Title again}
        \lipsum[1]
    \end{Subfigure}%
    %
    \begin{Subfigure}{2}
        {A nice Subfigure}
        \lipsum[2]
    \end{Subfigure}
\end{Figure}


See \figref{a}.

\end{document}

여기에 이미지 설명을 입력하세요

그런데: cleveref자신만의 \figref.

관련 정보