%E3%83%A9%E3%83%99%E3%83%AB%E3%81%AE%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%A0%E5%8F%82%E7%85%A7%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%20(%E3%81%93%E3%81%93%E3%81%A7%E3%81%AF%E3%82%B5%E3%83%96%E5%9B%B3%E3%81%AE%E3%82%88%E3%81%86%E3%81%AA%20tcolorbox%20%E7%94%A8).png)
理由としてはtcolorbox ではフロートをネストできませんそして、私の(サブ)フィギュアをもっと派手にしたかったので、newFigure
とSubfigure
newtcolorbox環境をコーディングしました。以下は私のコードの簡略版です。
\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}
出力で
結果は気に入っていますが、サブ図のタイトルを変更せずに、 のFigure 1a
代わりにテキストを印刷したいと思います。より正確には、サブ図のカウンターとしてを持つように newtcolorbox の引数を変更することができますが、これによりタイトルが から に変更され、これは望ましくありません。Figure (a)
number freestyle
1a
(a) blabla
1a 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
。