異なるキャプション設定コマンドを持つ複数の図

異なるキャプション設定コマンドを持つ複数の図

そこで、中央の図だけでなく、余白の図も配置しようと思います。余白の図については、次のようなものを作成したいと思います。 ここに画像の説明を入力してください

しかし、中央の図については、キャプション ラベルを以下のようにし、番号を章から取得し、図番号を 1 に更新します。 ここに画像の説明を入力してください

それぞれ作成してみましたが、どちらか一方しか作成されません。両方試すと、プリアンブル エラーが発生します。何が間違っているのでしょうか? 教えてください。MWE は以下のとおりです。

\documentclass[graybox,envcountchap,sectrefs,12pt]{svmono}
\usepackage[utf8]{inputenc}
\usepackage[labelfont=bf,sf,font=small,figurewithin=chapter]{caption}
\captionsetup{labelformat=empty,skip=1pt,font={bf,sf}}
\usepackage{chngcntr}
\counterwithout{figure}{chapter}
\begin{document}

\chapter{Introduction to Chemistry Laboratory}
\marginpar{  
    \centering     
    \includegraphics[width=2cm,height=2.75cm]{Beaker.png}  
     \captionof{figure}{Beaker}
    } 

\begin{figure}
\centering
\begin{tikzpicture}
\foreach \x in {0,1,...,2}{
            \draw (\x,0) -- (\x,-0.2)node[below,scale=0.4]{\x};
            }
            \foreach \x in {0.1,0.2,...,1.9}{
            \draw (\x,0) -- (\x,-0.075);
            }
            \foreach \x in {0.5,1,...,1.5}{
            \draw (\x,0) -- (\x,-0.15);
            };
\draw (0,0)--(2,0);
\draw[fill=lightgray] (0,0.05) rectangle (1.625,0.45);
\end{tikzpicture}
\captionsetup{labelsep=period,labelformat={simple}}
\caption{This}\label{fig:1}
\end{figure}
\end{document}

答え1

上記のコメントを回答にまとめると次のようになります。

余白の画像にテキストを追加するには、 を使用せずにそこにテキストを入力するだけです\captionof。すべてのテキストに統一されたスタイルを適用する場合は、次の MWE で行ったように独自のコマンドを定義できます。

他の図に章番号.図番号を付けたい場合は、\counterwithout{chapter}{figure}と を削除します\usepackage{chngcntr}svmonoクラスのデフォルトでは、図、表、数式に章ごとに番号が付けられます。

以下の MWE では、パッケージに関連するものもすべて削除しましたcaption。使用するドキュメントクラスは発行元によって提供されたものなので、発行元で公開する場合は、その設計の選択に従う必要がある場合があります。

grayboxこれは有効なクラス オプションではないため、対応する警告がスローされるため、も削除しました。

最後に、画像の歪みを避けるために、画像の幅または高さのいずれかを指定することをお勧めします。

ここに画像の説明を入力してください

\documentclass[envcountchap,sectrefs,12pt]{svmono}
\usepackage[utf8]{inputenc}
%\usepackage[labelfont=bf,sf,font=small,figurewithin=chapter]{caption}
%\captionsetup{labelformat=empty,skip=1pt,font={bf,sf}}
\usepackage[demo]{graphicx} % Remove demo option in actual document.
\usepackage{tikz}
\newcommand{\unnumberedcaption}[1]{\bfseries \sffamily #1}
\begin{document}

\chapter{Introduction to Chemistry Laboratory}
\marginpar{  
    \centering     
    \includegraphics[width=2cm,height=2.75cm]{Beaker.png}  
    \unnumberedcaption{Beaker}
    } 

\begin{figure}
\centering
\begin{tikzpicture}
\foreach \x in {0,1,...,2}{
            \draw (\x,0) -- (\x,-0.2)node[below,scale=0.4]{\x};
            }
            \foreach \x in {0.1,0.2,...,1.9}{
            \draw (\x,0) -- (\x,-0.075);
            }
            \foreach \x in {0.5,1,...,1.5}{
            \draw (\x,0) -- (\x,-0.15);
            };
\draw (0,0)--(2,0);
\draw[fill=lightgray] (0,0.05) rectangle (1.625,0.45);
\end{tikzpicture}
%\captionsetup{labelsep=period,labelformat={simple}}
\caption{This}\label{fig:1}
\end{figure}
\end{document}

関連情報