画像のキャプション形式を変更するにはどうすればよいですか?

画像のキャプション形式を変更するにはどうすればよいですか?

ドキュメントに画像を貼り付けます。デフォルトでは、キャプションの配置 (図 3) は中央揃えになり、キャプションの前にコロンが付きます。

ラベルを左揃えにして、フォーマットをFig. 3:オンに変更するにはどうすればよいですかFig. 3?

私のコード:

\setcounter{figure}{2}
\begin{figure}
    \centering
    \includegraphics[width=1\linewidth]{75_02-45.jpeg}\caption{}
    \label{fig}
\end{figure}

答え1

それは大丈夫ですか?


\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}

\makeatletter
\renewcommand{\fnum@figure}{Fig. \thefigure} % Changing the prefix to 'Fig.'
\makeatother

\begin{document}
Example:

\setcounter{figure}{2}
\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\linewidth]{frog.jpg}
    \captionsetup{justification=raggedright,singlelinecheck=false} % Left align the label
    \caption{} 
    \label{fig}
\end{figure}

\end{document}

出力:

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

答え2

\captionsetup[figure]{
  justification=raggedright,
  singlelinecheck=false, % <<< raggadright also when the caption is shorterthan a single line
  name={Fig.}
  }

完全なコード

\documentclass{article}
\usepackage{showframe}% comment in the final document
\usepackage{graphicx}
\usepackage{caption}
\captionsetup[figure]{
  justification=raggedright,
  singlelinecheck=false, % <<< raggadright also when the caption is shorterthan a single line
  name={Fig.}
  }

\begin{document}
%\noindent
Example:

\setcounter{figure}{2}
\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\linewidth]{example-image-duck}
    \caption{} 
    \label{fig}
\end{figure}

\end{document}

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

関連情報