図のキャプションを変更

図のキャプションを変更

次の図のキャプションは来ますFigure 1: abc

\begin{figure}[!h]
\centering
\includegraphics[width=12cm]{Fig.jpg}
\caption{abcd}
\label{fig}
\end{figure}

キャプションを変更したいFigure S1: abc

答え1

私はあなたのコードを完成させましたムウェ(必ず自分で行ってください)。目標は、次の方法で達成できます。

\documentclass{report}
\usepackage{graphicx}
\begin{document}
   \let\oldthefigure\thefigure % Store old \thefigure-command.
   \renewcommand{\thefigure}{S\oldthefigure}  % Create new \thefigure-command by prepending an "S".
   \begin{figure}[!h]
      \centering
      \includegraphics[width=12cm]{example-image-duck}
      \caption{abcd}
      \label{fig}
   \end{figure}
   See Figure~\ref{fig}.
\end{document}

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

答え2

をロードするとキャプションパッケージでは、 を使ってキャプションを調整できます\captionsetup。変更方法は、このマクロをどこに置くかによって異なります。図のすべてのキャプションを変更したい場合は、プリアンブルに次の行を追加します。

\DeclareCaptionLabelFormat{<<the name>>}{#1 S#2}
\captionsetup[figure]{labelformat=<<the name>>}

ただし、選択した図形のみに影響を与えたい場合は、\DeclareCaptionLabelFormatプリアンブルを残して、figureオプションの引数なしで環境に他のコマンドを追加します。

\captionsetup{labelformat=<<the name>>}

グローバル設定を含む完全なコード:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{caption}

\DeclareCaptionLabelFormat{labelwiths}{#1 S#2}
\captionsetup[figure]{labelformat=labelwiths}


\begin{document}
\begin{figure}[!h]
  \centering
  \includegraphics[width=12cm]{Fig.jpg}
  \caption{abcd}
  \label{fig}
\end{figure}

\begin{figure}[!h]
  \centering
  \includegraphics[width=12cm]{Fig.jpg}
  \caption{Sample sample sample}
  \label{fig}
\end{figure}
\end{document}

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

関連情報