如何更改圖像的標題格式?

如何更改圖像的標題格式?

我將圖片貼到我的文件中。預設情況下,標題對齊方式(圖 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}

在此輸入影像描述

相關內容